mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Another commit
This commit is contained in:
parent
ac7a68da17
commit
a071c64242
@ -1,4 +1,31 @@
|
||||
#!/usr/bin/python3
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
# mari von steinkirch @2013
|
||||
# steinkirch at gmail
|
||||
|
||||
|
||||
def reverse_str(s):
|
||||
''' in place '''
|
||||
sr_ls = []
|
||||
for i in range(len(s)-1, -1, -1):
|
||||
sr_ls.append(s[i])
|
||||
return ''.join(sr_ls)
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
s1 = 'abcdefg'
|
||||
s2 = 'buffy'
|
||||
s3 = ''
|
||||
print(reverse_str(s1))
|
||||
print(reverse_str(s2))
|
||||
print(reverse_str(s3))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
>>>>>>> parent of 7b79f58... Faster, better, stronger
|
||||
|
||||
# Mari von Steinkirch @ 2013
|
||||
# mari.wahl9@gmail.com
|
||||
@ -60,4 +87,4 @@ for function in (reverse_1, reverse_2, reverse_3, reverse_lambda):
|
||||
# We print the function's name and its benchmark result.
|
||||
print("{:<30}:".format(name), timeit(name + "('string')", setup='from __main__ import ' + name))
|
||||
# We print the output so that we can check if the function is working as expected.
|
||||
print(', '.join(map(function, strings)), '\n')
|
||||
print(', '.join(map(function, strings)), '\n')
|
||||
|
Loading…
x
Reference in New Issue
Block a user