-
-
Save orisano/7f545e0da49beab62973cf47f9aad6b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import itertools as it | |
def pipe(x, fn): | |
for f in fn: | |
x = f(x) | |
return x | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("n", type=int) | |
args = parser.parse_args() | |
pipe(it.count(1), [ | |
lambda x: map(lambda y: str(y).count("1"), x), | |
it.accumulate, | |
lambda x: enumerate(x, 1), | |
lambda x: filter(lambda y: y[0] == y[1], x), | |
lambda x: it.islice(x, args.n), | |
list, | |
reversed, | |
next, | |
iter, | |
next, | |
print, | |
]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment