-
Notifications
You must be signed in to change notification settings - Fork 0
/
fib.py
33 lines (26 loc) · 830 Bytes
/
fib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
class Fib():
def __init__(self,chars,wordwise=True):
if wordwise:
self.chars = chars.split()
else:
self.chars = chars
self.current_fib = 0
self.next_fib = 1
def _increment_ptr(self):
self.ptr +=1
def _increment_fib(self):
temp = self.current_fib + self.next_fib
self.current_fib = self.next_fib
self.next_fib = temp
def fibo_read(self):
while self.current_fib < (len(self.chars) -2):
print(self.chars[self.current_fib])
self._increment_fib()
if __name__ == "__main__":
print(sys.argv)
with open(sys.argv[1], "r") as file:
program = file.read()
print(program)
fibonacci = Fib(program,wordwise=True)
fibonacci.fibo_read()