Skip to content

Commit 5d1f726

Browse files
authored
Improved Code and removed Warnings (TheAlgorithms#483)
1 parent 07451a6 commit 5d1f726

36 files changed

+67
-67
lines changed

Graphs/basic-graphs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def topo(G, ind=None, Q=[1]):
168168

169169

170170
def adjm():
171-
n, a = input(), []
171+
n, a = raw_input(), []
172172
for i in xrange(n):
173173
a.append(map(int, raw_input().split()))
174174
return a, n

Graphs/minimum_spanning_tree_kruskal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import print_function
2-
num_nodes, num_edges = list(map(int,input().split()))
2+
num_nodes, num_edges = list(map(int,raw_input().split()))
33

44
edges = []
55

66
for i in range(num_edges):
7-
node1, node2, cost = list(map(int,input().split()))
7+
node1, node2, cost = list(map(int,raw_input().split()))
88
edges.append((i,node1,node2,cost))
99

1010
edges = sorted(edges, key=lambda edge: edge[3])

Graphs/scc_kosaraju.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from __future__ import print_function
22
# n - no of nodes, m - no of edges
3-
n, m = list(map(int,input().split()))
3+
n, m = list(map(int,raw_input().split()))
44

55
g = [[] for i in range(n)] #graph
66
r = [[] for i in range(n)] #reversed graph
77
# input graph data (edges)
88
for i in range(m):
9-
u, v = list(map(int,input().split()))
9+
u, v = list(map(int,raw_input().split()))
1010
g[u].append(v)
1111
r[v].append(u)
1212

Maths/SieveOfEratosthenes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import math
2-
n = int(input("Enter n: "))
2+
n = int(raw_input("Enter n: "))
33

44
def sieve(n):
55
l = [True] * (n+1)

Neural_Network/perceptron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,5 @@ def sign(self, u):
120120
while True:
121121
sample = []
122122
for i in range(3):
123-
sample.insert(i, float(input('value: ')))
123+
sample.insert(i, float(raw_input('value: ')))
124124
network.sort(sample)

Project Euler/Problem 02/sol3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
e.g. for n=10, we have {2,8}, sum is 10.
88
'''
99
"""Python 3"""
10-
n = int(input())
10+
n = int(raw_input())
1111
a=0
1212
b=2
1313
count=0

Project Euler/Problem 03/sol1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def isprime(no):
1919
return True
2020

2121
maxNumber = 0
22-
n=int(input())
22+
n=int(raw_input())
2323
if(isprime(n)):
2424
print(n)
2525
else:

Project Euler/Problem 03/sol2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
55
'''
66
from __future__ import print_function
7-
n=int(input())
7+
n=int(raw_input())
88
prime=1
99
i=2
1010
while(i*i<=n):

Project Euler/Problem 04/sol1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
55
'''
66
from __future__ import print_function
7-
limit = int(input("limit? "))
7+
limit = int(raw_input("limit? "))
88

99
# fetchs the next number
1010
for number in range(limit-1,10000,-1):

Project Euler/Problem 04/sol2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
arr.append(i*j)
1313
arr.sort()
1414

15-
n=int(input())
15+
n=int(raw_input())
1616
for i in arr[::-1]:
1717
if(i<n):
1818
print(i)

0 commit comments

Comments
 (0)