結果

問題 No.355 数当てゲーム(2)
コンテスト
ユーザー MitI_7
提出日時 2016-04-04 12:54:16
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 554 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 345 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 34,580 KB
平均クエリ数 5.52
最終ジャッジ日時 2026-03-31 13:32:19
合計ジャッジ時間 8,596 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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