Skip to content

Instantly share code, notes, and snippets.

@yusufusta
Created January 27, 2023 19:49
Show Gist options
  • Save yusufusta/4cee04407005e08604e080449ea9a3b0 to your computer and use it in GitHub Desktop.
Save yusufusta/4cee04407005e08604e080449ea9a3b0 to your computer and use it in GitHub Desktop.
A python code solves social media math cases :D written by @gaikyou/telegram
def checker(case, digits, n, m):
x = y = 0
for a, b in zip(case, digits):
x += b in case
y += a == b
return x == n and y == m
cases = {
'9285': (1, 0),
'1937': (2, 0),
'5201': (1, 1),
'6507': (0, 0),
'8524': (2, 0)
}
b = len(next(iter(
cases.keys()
)))
for i in range(10**b):
case = f'{i:0{b}}'
for current, (num, place) in cases.items():
if not checker(case, current, num, place):
break
else:
print(case)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment