#! /usr/bin/env python3
from itertools import accumulate, repeat, takewhile
from random import randint
def foo(x):
if x % 5 == 0:
print("スキップ")
return False
else:
return True
def bar(x, y):
print('hoge' if y % 7 == 0 else y)
return x + y
def baz(x):
if x > 500:
print('break')
return False
else:
return True
if __name__ == '__main__':
for i in takewhile(baz,
accumulate(filter(foo, (randint(*i) for i in repeat((0, 100)))),
func = bar,
initial = 0)):
i
IyEgL3Vzci9iaW4vZW52IHB5dGhvbjMKCmZyb20gaXRlcnRvb2xzIGltcG9ydCBhY2N1bXVsYXRlLCByZXBlYXQsIHRha2V3aGlsZQpmcm9tIHJhbmRvbSBpbXBvcnQgcmFuZGludAoKZGVmIGZvbyh4KToKICAgIGlmIHggJSA1ID09IDA6CiAgICAgICAgcHJpbnQoIuOCueOCreODg+ODlyIpCiAgICAgICAgcmV0dXJuIEZhbHNlCiAgICBlbHNlOgogICAgICAgIHJldHVybiBUcnVlCgpkZWYgYmFyKHgsIHkpOgogICAgcHJpbnQoJ2hvZ2UnIGlmIHkgJSA3ID09IDAgZWxzZSB5KQogICAgcmV0dXJuIHggKyB5CgpkZWYgYmF6KHgpOgogICAgaWYgeCA+IDUwMDoKICAgICAgICBwcmludCgnYnJlYWsnKQogICAgICAgIHJldHVybiBGYWxzZQogICAgZWxzZToKICAgICAgICByZXR1cm4gVHJ1ZQoKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzoKICAgIGZvciBpIGluIHRha2V3aGlsZShiYXosCiAgICAgICAgICAgICAgICAgICAgICAgYWNjdW11bGF0ZShmaWx0ZXIoZm9vLCAocmFuZGludCgqaSkgZm9yIGkgaW4gcmVwZWF0KCgwLCAxMDApKSkpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVuYyA9IGJhciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluaXRpYWwgPSAwKSk6CiAgICAgICAgaQo=