What this inspired by 20170810-dojo-stairs.ipynb?


In [1]:
s = 'to/stairway/heaven'
s


Out[1]:
'to/stairway/heaven'

In [2]:
terms = s.split('/')
terms


Out[2]:
['to', 'stairway', 'heaven']

In [3]:
'to' in terms


Out[3]:
True

In [4]:
'to' in terms[1:]


Out[4]:
False

In [5]:
from collections import deque

In [6]:
d = deque(terms)
d


Out[6]:
deque(['to', 'stairway', 'heaven'])

In [7]:
while d:
    print(d)
    d.popleft()


deque(['to', 'stairway', 'heaven'])
deque(['stairway', 'heaven'])
deque(['heaven'])

In [8]:
import math

In [9]:
math.gcd(256, 10**6)


Out[9]:
64