mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00:00
Merge pull request #477 from ParthS007/patch1
Fixes#476 : Remove Multiple Unused Imports and Variable
This commit is contained in:
commit
fedb3e70ab
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ __pycache__/
|
|||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.vscode/
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
|
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"python.pythonPath": "/usr/bin/python3"
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import math
|
||||
import numpy
|
||||
|
||||
def LUDecompose (table): #table that contains our data
|
||||
def LUDecompose (table):
|
||||
#table that contains our data
|
||||
#table has to be a square array so we need to check first
|
||||
rows,columns=numpy.shape(table)
|
||||
L=numpy.zeros((rows,columns))
|
||||
|
|
|
@ -3,16 +3,14 @@
|
|||
|
||||
from sympy import diff
|
||||
from decimal import Decimal
|
||||
from math import sin, cos, exp
|
||||
|
||||
def NewtonRaphson(func, a):
|
||||
''' Finds root from the point 'a' onwards by Newton-Raphson method '''
|
||||
while True:
|
||||
x = a
|
||||
c = Decimal(a) - ( Decimal(eval(func)) / Decimal(eval(str(diff(func)))) )
|
||||
|
||||
x = c
|
||||
a = c
|
||||
|
||||
# This number dictates the accuracy of the answer
|
||||
if abs(eval(func)) < 10**-15:
|
||||
return c
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import print_function
|
||||
import heapq
|
||||
import numpy as np
|
||||
import math
|
||||
import copy
|
||||
|
||||
try:
|
||||
xrange # Python 2
|
|
@ -140,7 +140,7 @@ from collections import deque
|
|||
|
||||
|
||||
def topo(G, ind=None, Q=[1]):
|
||||
if ind == None:
|
||||
if ind is None:
|
||||
ind = [0] * (len(G) + 1) # SInce oth Index is ignored
|
||||
for u in G:
|
||||
for v in G[u]:
|
||||
|
|
|
@ -3,7 +3,6 @@ a^2+b^2=c^2
|
|||
Given N, Check if there exists any Pythagorean triplet for which a+b+c=N
|
||||
Find maximum possible value of product of a,b,c among all such Pythagorean triplets, If there is no such Pythagorean triplet print -1."""
|
||||
#!/bin/python3
|
||||
import sys
|
||||
|
||||
product=-1
|
||||
d=0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from __future__ import print_function
|
||||
from math import factorial, ceil
|
||||
from math import factorial
|
||||
|
||||
def lattice_paths(n):
|
||||
n = 2*n #middle entry of odd rows starting at row 3 is the solution for n = 1, 2, 3,...
|
||||
|
|
|
@ -24,7 +24,7 @@ class LinkedList:
|
|||
temp = self.head
|
||||
self.head = self.head.next # oldHead <--> 2ndElement(head)
|
||||
self.head.previous = None # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed
|
||||
if(self.head == None):
|
||||
if(self.head is None):
|
||||
self.tail = None
|
||||
return temp
|
||||
|
||||
|
@ -58,7 +58,7 @@ class LinkedList:
|
|||
current.next.previous = current.previous # 1 <--> 3
|
||||
|
||||
def isEmpty(self): #Will return True if the list is empty
|
||||
return(self.head == None)
|
||||
return(self.head is None)
|
||||
|
||||
def display(self): #Prints contents of the list
|
||||
current = self.head
|
||||
|
|
|
@ -19,4 +19,4 @@ class LinkedList:
|
|||
return item
|
||||
|
||||
def is_empty(self):
|
||||
return self.head == None
|
||||
return self.head is None
|
||||
|
|
|
@ -67,3 +67,4 @@ class Linked_List:
|
|||
current = next_node
|
||||
# Return prev in order to put the head at the end
|
||||
Head = prev
|
||||
return Head
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import tensorflow as tf
|
||||
from random import choice, shuffle
|
||||
from random import shuffle
|
||||
from numpy import array
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ def sum_of_square_error(data_x, data_y, len_data, theta):
|
|||
:param theta : contains the feature vector
|
||||
:return : sum of square error computed from given feature's
|
||||
"""
|
||||
error = 0.0
|
||||
prod = np.dot(theta, data_x.transpose())
|
||||
prod -= data_y.transpose()
|
||||
sum_elem = np.sum(np.square(prod))
|
||||
|
|
|
@ -28,9 +28,8 @@ Game-Of-Life Rules:
|
|||
comes a live cell, as if by reproduction.
|
||||
'''
|
||||
import numpy as np
|
||||
import random, time, sys
|
||||
import random, sys
|
||||
from matplotlib import pyplot as plt
|
||||
import matplotlib.animation as animation
|
||||
from matplotlib.colors import ListedColormap
|
||||
|
||||
usage_doc='Usage of script: script_nama <size_of_canvas:int>'
|
||||
|
|
|
@ -290,7 +290,7 @@ def goldbach(number):
|
|||
|
||||
while (i < lenPN and loop):
|
||||
|
||||
j = i+1;
|
||||
j = i+1
|
||||
|
||||
|
||||
while (j < lenPN and loop):
|
||||
|
@ -300,8 +300,7 @@ def goldbach(number):
|
|||
ans.append(primeNumbers[i])
|
||||
ans.append(primeNumbers[j])
|
||||
|
||||
j += 1;
|
||||
|
||||
j += 1
|
||||
|
||||
i += 1
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
This is pure python implementation of interpolation search algorithm
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import bisect
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import collections
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import math
|
||||
|
||||
"""
|
||||
A python implementation of the quick select algorithm, which is efficient for calculating the value that would appear in the index of a list if it would be sorted, even if it is not already sorted
|
||||
https://en.wikipedia.org/wiki/Quickselect
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# Sort large text files in a minimum amount of memory
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
class FileSplitter(object):
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import print_function
|
|||
from random import randint
|
||||
from tempfile import TemporaryFile
|
||||
import numpy as np
|
||||
import math
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ class node():
|
|||
def insert(self,val):
|
||||
if self.val:
|
||||
if val < self.val:
|
||||
if self.left == None:
|
||||
if self.left is None:
|
||||
self.left = node(val)
|
||||
else:
|
||||
self.left.insert(val)
|
||||
elif val > self.val:
|
||||
if self.right == None:
|
||||
if self.right is None:
|
||||
self.right = node(val)
|
||||
else:
|
||||
self.right.insert(val)
|
||||
|
|
|
@ -68,7 +68,6 @@ def assemble_transformation(ops, i, j):
|
|||
return seq
|
||||
|
||||
if __name__ == '__main__':
|
||||
from time import sleep
|
||||
_, operations = compute_transform_tables('Python', 'Algorithms', -1, 1, 2, 2)
|
||||
|
||||
m = len(operations)
|
||||
|
|
Loading…
Reference in New Issue
Block a user