Skip to content

Instantly share code, notes, and snippets.

@nkoneko
Created March 20, 2014 17:08
Show Gist options
  • Save nkoneko/9668855 to your computer and use it in GitHub Desktop.
Save nkoneko/9668855 to your computer and use it in GitHub Desktop.
import itertools as I
import functools as F
import operator as O
FROM=3
TO=117
_=lambda m,f,g:I.cycle(I.chain(I.repeat(g,m-1),[f]))
_id=lambda x:x
_th=lambda x:x+2
_fv=lambda x:x+4
a=_(3,_th,_id)
b=_(5,_fv,_id)
result = F.reduce(O.add,I.islice((_b(_a(1))%6 for (_a,_b) in I.izip(a,b)),FROM-1,TO))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment