Created
January 8, 2022 02:18
-
-
Save aoisensi/fa6d525cb068fbcb0222889d2b9aace6 to your computer and use it in GitHub Desktop.
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
epsilon = 1e-6 | |
def check_kmb(s: str): | |
result = eval(s) | |
if (686+epsilon) > result and result > (686-epsilon): | |
print(s, '=', result) | |
def func(s: str, n: int): | |
if n == 10: | |
check_kmb(s) | |
return | |
for op in ['', '+', '-', '*', '/']: | |
func(s + op + str(n), n + 1) | |
func('1', 2) |
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
123-4-56+7*89 = 686 | |
12*3+4-56+78*9 = 686 | |
1+23+45-6+7*89 = 686 | |
1+23*4-5*6+7*89 = 686 | |
1+2-3+4-5+678+9 = 686 | |
1+2*345+67-8*9 = 686 | |
1+2*34*5+6*7*8+9 = 686 | |
1-23-4+56/7*89 = 686.0 | |
1-2+34+5*6+7*89 = 686 | |
1*23-45+6+78*9 = 686 | |
1*2+3*4-5*6+78*9 = 686 | |
1*2-3-4-5-6+78*9 = 686 | |
1*2*345+6+7-8-9 = 686 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment