removing fibonacci and fizzbuzz and moving them to their own repo.
This commit is contained in:
parent
10c3d47550
commit
3c635464d8
2 changed files with 0 additions and 81 deletions
40
fibonacci.py
40
fibonacci.py
|
@ -1,40 +0,0 @@
|
||||||
# Lmao I wrote this while I was drunk.
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def parse_command_line(argv):
|
|
||||||
if(len(argv) == 1):
|
|
||||||
print('Default value: 5')
|
|
||||||
return 5
|
|
||||||
|
|
||||||
elif(len(argv) > 2):
|
|
||||||
print('Too many arguments!')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
num = int(argv[1])
|
|
||||||
return num
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(str(e))
|
|
||||||
print('Non-integer input.')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
return int(argv[1])
|
|
||||||
|
|
||||||
def fibonacci(n):
|
|
||||||
if(n > 0):
|
|
||||||
f = [1, 0]
|
|
||||||
for i in range(n):
|
|
||||||
print(f[0] + f[1])
|
|
||||||
if(i%2 == 1):
|
|
||||||
f[1] = f[0] + f[1]
|
|
||||||
else:
|
|
||||||
f[0] = f[0] + f[1]
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
num = parse_command_line(argv)
|
|
||||||
fibonacci(num)
|
|
||||||
|
|
||||||
main(sys.argv)
|
|
41
fizzbuzz.py
41
fizzbuzz.py
|
@ -1,41 +0,0 @@
|
||||||
# This is a really dumb idea this code is gonna be shit
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def parse_command_line(argv):
|
|
||||||
if(len(argv) == 1):
|
|
||||||
print('Default value: 5')
|
|
||||||
return 100
|
|
||||||
|
|
||||||
elif(len(argv) > 2):
|
|
||||||
print('Too many arguments!')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
num = int(argv[1])
|
|
||||||
return num
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(str(e))
|
|
||||||
print('Non-integer input.')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
return int(argv[1])
|
|
||||||
|
|
||||||
def fizzbuzz(n):
|
|
||||||
for i in range(1, n + 1):
|
|
||||||
output = ''
|
|
||||||
if(i%3 == 0):
|
|
||||||
output += 'Fizz'
|
|
||||||
if(i%5 == 0):
|
|
||||||
output += 'Buzz'
|
|
||||||
if(output == ''):
|
|
||||||
output = str(i)
|
|
||||||
print(output)
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
num = parse_command_line(argv)
|
|
||||||
fizzbuzz(num)
|
|
||||||
|
|
||||||
main(sys.argv)
|
|
Reference in a new issue