Created
May 26, 2021 04:28
-
-
Save heiwa4126/9c8f0b645d7ffcd7bff16bb60751c420 to your computer and use it in GitHub Desktop.
baa + ba = abb
This file contains hidden or 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
#!/usr/bin/env python3 | |
""" | |
baa + ba = abb | |
https://twitter.com/koujounodenki/status/1397188516044541955 | |
""" | |
for b in range(1, 10): | |
for a in range(0, 10): | |
x = b * 100 + a * 10 + a | |
y = b * 10 + a | |
t = a * 100 + b * 10 + b | |
if t == x + y: | |
print(f"a={a}, b={b}, {x}+{y}={t}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
しらみつぶしでない解法例
くりあがりは最高でも10だから、100のケタをみると A=B または A=B+1 のはず。
また1のケタを見ると A+A=B または A+A=B+10
この2x2の4通りを全部ためすと、成立するのはB=8、A=9のときのみ。