mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
Resovle conflicts
This commit is contained in:
commit
c7de76deda
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
@ -99,8 +99,8 @@ def prime_implicant_chart(prime_implicants, binary):
|
|||
return chart
|
||||
|
||||
def main():
|
||||
no_of_variable = int(raw_input("Enter the no. of variables\n"))
|
||||
minterms = [int(x) for x in raw_input("Enter the decimal representation of Minterms 'Spaces Seprated'\n").split()]
|
||||
no_of_variable = int(input("Enter the no. of variables\n"))
|
||||
minterms = [int(x) for x in input("Enter the decimal representation of Minterms 'Spaces Seprated'\n").split()]
|
||||
binary = decimal_to_binary(no_of_variable, minterms)
|
||||
|
||||
prime_implicants = check(binary)
|
|
@ -4,9 +4,9 @@ import sys, random, cryptomath_module as cryptoMath
|
|||
SYMBOLS = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""
|
||||
|
||||
def main():
|
||||
message = raw_input('Enter message: ')
|
||||
key = int(raw_input('Enter key [2000 - 9000]: '))
|
||||
mode = raw_input('Encrypt/Decrypt [E/D]: ')
|
||||
message = input('Enter message: ')
|
||||
key = int(input('Enter key [2000 - 9000]: '))
|
||||
mode = input('Encrypt/Decrypt [E/D]: ')
|
||||
|
||||
if mode.lower().startswith('e'):
|
||||
mode = 'encrypt'
|
||||
|
|
|
@ -44,7 +44,7 @@ def decrypt(message):
|
|||
print("Decryption using Key #%s: %s" % (key, translated))
|
||||
|
||||
def main():
|
||||
message = raw_input("Encrypted message: ")
|
||||
message = input("Encrypted message: ")
|
||||
message = message.upper()
|
||||
decrypt(message)
|
||||
|
|
@ -40,25 +40,25 @@ def main():
|
|||
print("3.BruteForce")
|
||||
print("4.Quit")
|
||||
while True:
|
||||
choice = raw_input("What would you like to do?: ")
|
||||
choice = input("What would you like to do?: ")
|
||||
if choice not in ['1', '2', '3', '4']:
|
||||
print ("Invalid choice")
|
||||
elif choice == '1':
|
||||
strng = raw_input("Please enter the string to be ecrypted: ")
|
||||
strng = input("Please enter the string to be ecrypted: ")
|
||||
while True:
|
||||
key = int(input("Please enter off-set between 1-94: "))
|
||||
if key in range(1, 95):
|
||||
print (encrypt(strng, key))
|
||||
main()
|
||||
elif choice == '2':
|
||||
strng = raw_input("Please enter the string to be decrypted: ")
|
||||
strng = input("Please enter the string to be decrypted: ")
|
||||
while True:
|
||||
key = raw_int(input("Please enter off-set between 1-94: "))
|
||||
if key > 0 and key <= 94:
|
||||
print(decrypt(strng, key))
|
||||
main()
|
||||
elif choice == '3':
|
||||
strng = raw_input("Please enter the string to be decrypted: ")
|
||||
strng = input("Please enter the string to be decrypted: ")
|
||||
brute_force(strng)
|
||||
main()
|
||||
elif choice == '4':
|
||||
|
|
|
@ -6,7 +6,7 @@ BYTE_SIZE = 256
|
|||
|
||||
def main():
|
||||
filename = 'encrypted_file.txt'
|
||||
response = raw_input('Encrypte\Decrypt [e\d]: ')
|
||||
response = input('Encrypte\Decrypt [e\d]: ')
|
||||
|
||||
if response.lower().startswith('e'):
|
||||
mode = 'encrypt'
|
||||
|
|
|
@ -4,9 +4,9 @@ import sys, random
|
|||
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
def main():
|
||||
message = raw_input('Enter message: ')
|
||||
message = input('Enter message: ')
|
||||
key = 'LFWOAYUISVKMNXPBDCRJTQEGHZ'
|
||||
resp = raw_input('Encrypt/Decrypt [e/d]: ')
|
||||
resp = input('Encrypt/Decrypt [e/d]: ')
|
||||
|
||||
checkValidKey(key)
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ from __future__ import print_function
|
|||
import math
|
||||
|
||||
def main():
|
||||
message = raw_input('Enter message: ')
|
||||
key = int(raw_input('Enter key [2-%s]: ' % (len(message) - 1)))
|
||||
mode = raw_input('Encryption/Decryption [e/d]: ')
|
||||
message = input('Enter message: ')
|
||||
key = int(input('Enter key [2-%s]: ' % (len(message) - 1)))
|
||||
mode = input('Encryption/Decryption [e/d]: ')
|
||||
|
||||
if mode.lower().startswith('e'):
|
||||
text = encryptMessage(key, message)
|
||||
|
|
|
@ -5,15 +5,15 @@ import transposition_cipher as transCipher
|
|||
def main():
|
||||
inputFile = 'Prehistoric Men.txt'
|
||||
outputFile = 'Output.txt'
|
||||
key = int(raw_input('Enter key: '))
|
||||
mode = raw_input('Encrypt/Decrypt [e/d]: ')
|
||||
key = int(input('Enter key: '))
|
||||
mode = input('Encrypt/Decrypt [e/d]: ')
|
||||
|
||||
if not os.path.exists(inputFile):
|
||||
print('File %s does not exist. Quitting...' % inputFile)
|
||||
sys.exit()
|
||||
if os.path.exists(outputFile):
|
||||
print('Overwrite %s? [y/n]' % outputFile)
|
||||
response = raw_input('> ')
|
||||
response = input('> ')
|
||||
if not response.lower().startswith('y'):
|
||||
sys.exit()
|
||||
|
|
@ -2,9 +2,9 @@ from __future__ import print_function
|
|||
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
def main():
|
||||
message = raw_input('Enter message: ')
|
||||
key = raw_input('Enter key [alphanumeric]: ')
|
||||
mode = raw_input('Encrypt/Decrypt [e/d]: ')
|
||||
message = input('Enter message: ')
|
||||
key = input('Enter key [alphanumeric]: ')
|
||||
mode = input('Encrypt/Decrypt [e/d]: ')
|
||||
|
||||
if mode.lower().startswith('e'):
|
||||
mode = 'encrypt'
|
||||
|
|
|
@ -35,8 +35,8 @@ def BellmanFord(graph, V, E, src):
|
|||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
V = int(input("Enter number of vertices: "))
|
||||
E = int(input("Enter number of edges: "))
|
||||
|
||||
graph = [dict() for j in range(E)]
|
||||
|
||||
|
@ -45,10 +45,10 @@ for i in range(V):
|
|||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
src = int(input("Enter source:"))
|
||||
dst = int(input("Enter destination:"))
|
||||
weight = float(input("Enter weight:"))
|
||||
graph[i] = {"src": src,"dst": dst, "weight": weight}
|
||||
|
||||
gsrc = int(raw_input("\nEnter shortest path source:"))
|
||||
gsrc = int(input("\nEnter shortest path source:"))
|
||||
BellmanFord(graph, V, E, gsrc)
|
|
@ -38,8 +38,8 @@ def Dijkstra(graph, V, src):
|
|||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
V = int(input("Enter number of vertices: "))
|
||||
E = int(input("Enter number of edges: "))
|
||||
|
||||
graph = [[float('inf') for i in range(V)] for j in range(V)]
|
||||
|
||||
|
@ -48,10 +48,10 @@ for i in range(V):
|
|||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
src = int(input("Enter source:"))
|
||||
dst = int(input("Enter destination:"))
|
||||
weight = float(input("Enter weight:"))
|
||||
graph[src][dst] = weight
|
||||
|
||||
gsrc = int(raw_input("\nEnter shortest path source:"))
|
||||
gsrc = int(input("\nEnter shortest path source:"))
|
||||
Dijkstra(graph, V, gsrc)
|
|
@ -30,8 +30,8 @@ def FloydWarshall(graph, V):
|
|||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
V = int(input("Enter number of vertices: "))
|
||||
E = int(input("Enter number of edges: "))
|
||||
|
||||
graph = [[float('inf') for i in range(V)] for j in range(V)]
|
||||
|
||||
|
@ -40,9 +40,9 @@ for i in range(V):
|
|||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
src = int(input("Enter source:"))
|
||||
dst = int(input("Enter destination:"))
|
||||
weight = float(input("Enter weight:"))
|
||||
graph[src][dst] = weight
|
||||
|
||||
FloydWarshall(graph, V)
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import print_function
|
||||
num_nodes, num_edges = list(map(int,raw_input().split()))
|
||||
num_nodes, num_edges = list(map(int,input().split()))
|
||||
|
||||
edges = []
|
||||
|
||||
for i in range(num_edges):
|
||||
node1, node2, cost = list(map(int,raw_input().split()))
|
||||
node1, node2, cost = list(map(int,input().split()))
|
||||
edges.append((i,node1,node2,cost))
|
||||
|
||||
edges = sorted(edges, key=lambda edge: edge[3])
|
|
@ -101,8 +101,8 @@ def PrimsAlgorithm(l):
|
|||
return TreeEdges
|
||||
|
||||
# < --------- Prims Algorithm --------- >
|
||||
n = int(raw_input("Enter number of vertices: "))
|
||||
e = int(raw_input("Enter number of edges: "))
|
||||
n = int(input("Enter number of vertices: "))
|
||||
e = int(input("Enter number of edges: "))
|
||||
adjlist = defaultdict(list)
|
||||
for x in range(e):
|
||||
l = [int(x) for x in input().split()]
|
|
@ -1,12 +1,12 @@
|
|||
from __future__ import print_function
|
||||
# n - no of nodes, m - no of edges
|
||||
n, m = list(map(int,raw_input().split()))
|
||||
n, m = list(map(int,input().split()))
|
||||
|
||||
g = [[] for i in range(n)] #graph
|
||||
r = [[] for i in range(n)] #reversed graph
|
||||
# input graph data (edges)
|
||||
for i in range(m):
|
||||
u, v = list(map(int,raw_input().split()))
|
||||
u, v = list(map(int,input().split()))
|
||||
g[u].append(v)
|
||||
r[v].append(u)
|
||||
|
|
@ -120,5 +120,5 @@ network.trannig()
|
|||
while True:
|
||||
sample = []
|
||||
for i in range(3):
|
||||
sample.insert(i, float(raw_input('value: ')))
|
||||
sample.insert(i, float(input('value: ')))
|
||||
network.sort(sample)
|
|
@ -1,5 +1,5 @@
|
|||
import math
|
||||
n = int(raw_input("Enter n: "))
|
||||
n = int(input("Enter n: "))
|
||||
|
||||
def sieve(n):
|
||||
l = [True] * (n+1)
|
|
@ -120,5 +120,5 @@ network.trannig()
|
|||
while True:
|
||||
sample = []
|
||||
for i in range(3):
|
||||
sample.insert(i, float(raw_input('value: ')))
|
||||
sample.insert(i, float(input('value: ')))
|
||||
network.sort(sample)
|
|
@ -37,7 +37,7 @@ def is_balanced(S):
|
|||
|
||||
def main():
|
||||
|
||||
S = raw_input("Enter sequence of brackets: ")
|
||||
S = input("Enter sequence of brackets: ")
|
||||
|
||||
if is_balanced(S):
|
||||
print((S, "is balanced"))
|
||||
|
|
|
@ -19,7 +19,7 @@ def moveDisk(fp,tp):
|
|||
print(('moving disk from', fp, 'to', tp))
|
||||
|
||||
def main():
|
||||
height = int(raw_input('Height of hanoi: '))
|
||||
height = int(input('Height of hanoi: '))
|
||||
moveTower(height, 'A', 'B', 'C')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user