0
0

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 3 years have passed since last update.

ABC201 C - Secret Number から学んだ

Last updated at Posted at 2021-09-27

abc201_1.png
abc201_2.png
abc201_3.png

うーん、if 文で条件を分けようとしたが、
途中でとん挫。。!? production で行けるかも。

うん、行けた。

SecretNumber.py
from itertools import product
S = input()
cnt = 0
Ccnt = S.count("o")
for i0,i1,i2,i3 in product(range(10),repeat=4):
    #print(i0,i1,i2,i3)
    key = [S[i0],S[i1],S[i2],S[i3]]
    if "x" in key:
        continue
    #print(i0,i1,i2,i3,key)
    nums = []
    if S[i0] == "o":
        nums.append(i0)
    if S[i1] == "o":
        nums.append(i1)
    if S[i2] == "o":
        nums.append(i2)
    if S[i3] == "o":
        nums.append(i3)

    if len(set(nums)) != Ccnt:
        continue
    #print(len(nums), Ccnt)
    #print(i0,i1,i2,i3,key)
    cnt += 1

print(cnt)

C 問題、diff 茶色最弱問題に四苦八苦したが
自力で解けた。うれし---!!


サッパリ忘れて解き直し。

abc201c.py
S = list(input())
ans = 0
cntC = S.count("o")
from itertools import product
for nums in product(range(10),repeat=4):
    nums_ = list(set(list(nums)))
    check = ""
    for i in range(len(nums_)):
        check += S[nums_[i]]
    if check.count("o") == cntC and check.count("x") == 0:
        ans += 1
print(ans)
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?