Last active
June 9, 2020 11:57
-
-
Save joonas-yoon/2c29589552510e2ed9f4172e502a67ef to your computer and use it in GitHub Desktop.
문제적 남자 95화 - 리모트 뷰잉 뇌풀기 - 4번 문제
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
# AB*C = DE-F = GH/I | |
def validate(a): | |
ABC = (10*a[0] + a[1]) * a[2] | |
DEF = (10*a[3] + a[4]) - a[5] | |
if ABC != DEF: | |
return False | |
GH, I = 10*a[6] + a[7], a[8] | |
if GH % I != 0 or ABC != (GH / I): | |
return False | |
return True | |
a = [i for i in range(1, 10)] | |
for p in permutations(a): | |
if validate(p): | |
print(p) | |
for i in range(len(p)): | |
print("{} = {}".format(chr(ord('A') + i), p[i])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment