Simplify code by dropping support for legacy Python (#1143)

* Simplify code by dropping support for legacy Python

* sort() --> sorted()
This commit is contained in:
Christian Clauss
2019-08-19 15:37:49 +02:00
committed by GitHub
parent 32aa7ff081
commit 47a9ea2b0b
145 changed files with 367 additions and 976 deletions

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
import collections, pprint, time, os
start_time = time.time()

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
# https://en.wikipedia.org/wiki/Euclidean_algorithm
def euclidean_gcd(a, b):

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
__author__ = "Tobias Carryer"
from time import time
@@ -7,11 +6,11 @@ class LinearCongruentialGenerator(object):
"""
A pseudorandom number generator.
"""
def __init__( self, multiplier, increment, modulo, seed=int(time()) ):
"""
These parameters are saved and used when nextNumber() is called.
modulo is the largest number that can be generated (exclusive). The most
efficent values are powers of 2. 2^32 is a common value.
"""
@@ -19,7 +18,7 @@ class LinearCongruentialGenerator(object):
self.increment = increment
self.modulo = modulo
self.seed = seed
def next_number( self ):
"""
The smallest number that can be generated is zero.

View File

@@ -13,9 +13,6 @@ The function called is_balanced takes as input a string S which is a sequence of
returns true if S is nested and false otherwise.
'''
from __future__ import print_function
def is_balanced(S):
stack = []

View File

@@ -1,5 +1,4 @@
"""Password generator allows you to generate a random password of length N."""
from __future__ import print_function
from random import choice
from string import ascii_letters, digits, punctuation

View File

@@ -1,5 +1,4 @@
from __future__ import print_function
def moveTower(height, fromPole, toPole, withPole):
def moveTower(height, fromPole, toPole, withPole):
'''
>>> moveTower(3, 'A', 'B', 'C')
moving disk from A to B

View File

@@ -9,8 +9,6 @@ Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
"""
from __future__ import print_function
def twoSum(nums, target):
"""
:type nums: List[int]
@@ -20,7 +18,7 @@ def twoSum(nums, target):
chk_map = {}
for index, val in enumerate(nums):
compl = target - val
if compl in chk_map:
if compl in chk_map:
indices = [chk_map[compl], index]
print(indices)
return [indices]

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
import pprint, time
def getWordPattern(word):