Skip to content

Instantly share code, notes, and snippets.

@heiwa4126
Created May 26, 2021 04:28
Show Gist options
  • Save heiwa4126/9c8f0b645d7ffcd7bff16bb60751c420 to your computer and use it in GitHub Desktop.
Save heiwa4126/9c8f0b645d7ffcd7bff16bb60751c420 to your computer and use it in GitHub Desktop.
baa + ba = abb
#!/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}")
@heiwa4126
Copy link
Author

しらみつぶしでない解法例

くりあがりは最高でも10だから、100のケタをみると A=B または A=B+1 のはず。
また1のケタを見ると A+A=B または A+A=B+10
この2x2の4通りを全部ためすと、成立するのはB=8、A=9のときのみ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment