LoginSignup
1

More than 3 years have passed since last update.

日能研の問題を解く(2018/11)

Posted at

今日は。
電車に乗っていたら、日能研の広告の問題が算数だったので、Pythonで愚直に解いてみました。6!=720通りなので、人間にはしんどくてもコンピュータならいけそうですね。

# coding: utf-8

import itertools
from functools import reduce

def f(a, b): return a*10 + b

def main():
    for m in itertools.permutations([1,2,3,4,5,6]):
        if all([reduce(f, m[:k]) % k == 0 for k in range(2,7)]):
            print(reduce(f, m))

main()

reduce便利でした。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
1