3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 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便利でした。

3
1
0

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
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?