結果

問題 No.355 数当てゲーム(2)
ユーザー MitI_7
提出日時 2016-04-04 12:54:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 28,104 KB
平均クエリ数 5.52
最終ジャッジ日時 2024-07-16 23:31:49
合計ジャッジ時間 6,248 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations, filterfalse


def judge(a, b):
    x, y = 0, 0
    for i in range(len(a)):
        if a[i] == b[i]:
            x += 1
    y = 8 - len(set(list(a) + list(b))) - x
    return x, y


def main():
    ans = list(permutations("0123456789", 4))
    while True:
        q = ans[0]
        print(" ".join(q))
        x, y = map(int, input().split())

        if (x, y) == (4, 0):
            return
        else:
            ans = list(filterfalse(lambda n: judge(n, q) != (x, y), ans))

if __name__ == '__main__':
    main()
0