diff --git a/ipynb/Countdown.ipynb b/ipynb/Countdown.ipynb index 2466f5f..b6c20a9 100644 --- a/ipynb/Countdown.ipynb +++ b/ipynb/Countdown.ipynb @@ -32,10 +32,8 @@ "from math import sqrt, factorial, floor, ceil\n", "from operator import add, sub, mul, neg, truediv as div\n", "from typing import List, Tuple, Dict, Union, Sequence, Collection, Set, Optional\n", - "from functools import lru_cache\n", - "import re\n", - "\n", - "cache = lru_cache(None)" + "from functools import cache\n", + "import re" ] }, { @@ -208,8 +206,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 19.4 s, sys: 511 ms, total: 19.9 s\n", - "Wall time: 19.9 s\n" + "CPU times: user 12.3 s, sys: 263 ms, total: 12.6 s\n", + "Wall time: 12.6 s\n" ] }, { @@ -274,7 +272,9 @@ " 2027: '((((10+((((9*8)*7)*(6-5))*4))+3)-2)*1)',\n", " 2028: '((((10+((((9*8)*7)*(6-5))*4))+3)-2)+1)',\n", " 2029: '(((((((10*9)+8)*7)*6)-((5*4)*3))/2)+1)',\n", - " 2030: '(((((((10-(9/8))+(7*6))*5)*4)-3)*2)+1)'}" + " 2030: '(((((((10-(9/8))+(7*6))*5)*4)-3)*2)+1)',\n", + " 2031: '(((((10+9)+((((8*7)-6)*5)*4))-3)*2)-1)',\n", + " 2032: '((((((((10*9)*8)-(7*6))-5)+4)*3)+2)-1)'}" ] }, "execution_count": 5, @@ -283,7 +283,7 @@ } ], "source": [ - "{y: expressions(c10)[y] for y in range(2010, 2031)}" + "{y: expressions(c10)[y] for y in range(2010, 2033)}" ] }, { @@ -412,7 +412,7 @@ "\n", "**I think 30,066 is wrong.** The trouble is: round-off error.\n", "\n", - "Let's find all the values in `expressions(c10)` that are very near to 2016, within ±0.0000000001:" + "Let's find all the values in `expressions(c10)` that are very near to 2016, within ±0.0000000001, and show them with their expression count and expression:" ] }, { @@ -431,17 +431,17 @@ { "data": { "text/plain": [ - "{2016.0000000000002: '((((10*((9*(8+7))-(6/(5+4))))*3)/2)+1)',\n", - " 2016.0: '(((((((((10*9)+8)*7)-6)-5)-4)*3)+2)+1)',\n", - " 2015.9999999999995: '((((((10*9)*8)*7)*((6/5)-(4-3)))*2)*1)',\n", - " 2015.999999999997: '(((10*9)*8)/(7-(6-(((5/(4+3))/2)-1))))',\n", - " 2016.0000000000005: '(((((10*9)*8)*((((7*6)/5)-4)-3))*2)*1)',\n", - " 2016.0000000000018: '((((((10*9)*8)*7)*(((6/5)-4)+3))*2)*1)',\n", - " 2016.0000000000023: '(10*((9*8)/((7-(6-((5/(4+3))/2)))-1)))',\n", - " 2015.9999999999998: '((10*((9*(((8-(7/6))*5)-(4*3)))+2))+1)',\n", - " 2015.9999999999993: '(10*(((((9*8)*7)*6)/5)*(((4/3)-2)+1)))',\n", - " 2016.000000000002: '(((10*9)*8)/((7-(6-((5/(4+3))/2)))-1))',\n", - " 2015.999999999999: '((((10*9)*(8+7))-6)/(((5-(4/3))-2)-1))'}" + "{2016.0000000000002: (5792, '((((10*((9*(8+7))-(6/(5+4))))*3)/2)+1)'),\n", + " 2016.0: (30066, '(((((((((10*9)+8)*7)-6)-5)-4)*3)+2)+1)'),\n", + " 2015.9999999999995: (1930, '((((((10*9)*8)*7)*((6/5)-(4-3)))*2)*1)'),\n", + " 2015.999999999997: (15, '(((10*9)*8)/(7-(6-(((5/(4+3))/2)-1))))'),\n", + " 2016.0000000000005: (510, '(((((10*9)*8)*((((7*6)/5)-4)-3))*2)*1)'),\n", + " 2016.0000000000018: (264, '((((((10*9)*8)*7)*(((6/5)-4)+3))*2)*1)'),\n", + " 2016.0000000000023: (12, '(10*((9*8)/((7-(6-((5/(4+3))/2)))-1)))'),\n", + " 2015.9999999999998: (5868, '((10*((9*(((8-(7/6))*5)-(4*3)))+2))+1)'),\n", + " 2015.9999999999993: (14, '(10*(((((9*8)*7)*6)/5)*(((4/3)-2)+1)))'),\n", + " 2016.000000000002: (18, '(((10*9)*8)/((7-(6-((5/(4+3))/2)))-1))'),\n", + " 2015.999999999999: (10, '((((10*9)*(8+7))-6)/(((5-(4/3))-2)-1))')}" ] }, "execution_count": 9, @@ -450,7 +450,7 @@ } ], "source": [ - "{y: expressions(c10)[y]\n", + "{y: (expression_counts(c10)[y], expressions(c10)[y])\n", " for y in expressions(c10)\n", " if abs(y - 2016) < 1e-10}" ] @@ -625,10 +625,10 @@ "|Binary Operations|Unary Operations|Digit Operations|\n", "|--------------|--------------|-------|\n", "|`+` addition: 1 + 2 = 3 |`_` unary minus: -4 = -4|`.` decimal point: 1.23|\n", - "|`-` subtraction: 3 - 2 = 1 |`√` square root: √4 = 2|`,` concatenation of digits: 123|\n", - "|`*` multiplication: 2 * 3 = 6|`!` factorial: 4! = 24 |\n", - "|`/` division: 6 / 3 = 2 |`⌊` floor:⌊4.4⌋ = 4|\n", - "|`^` exponentiation: 2 ^ 3 = 8|`⌈` ceiling: ⌈4.4⌉ = 5|\n", + "|`-` subtraction: 3 - 2 = 1 |`√` square root: √4 = 2|`,` digit concatenation: 123|\n", + "|`*` multiplication: 2 * 3 = 6|`!` factorial: 4! = 24 | |\n", + "|`/` division: 6 / 3 = 2 |`⌊` floor:⌊4.4⌋ = 4 | |\n", + "|`^` exponentiation: 2 ^ 3 = 8|`⌈` ceiling: ⌈4.4⌉ = 5 | |\n", "\n", "\n", "I will define the data type `Operation` to hold a description of each operation: the code symbol; the arity (binary or unary); a Python function to call to do the calculation; a format string (for unary operations); and a predicate that says when the operation is applicable. The applicability test can avoid both errors and results that are unlikely to be helpful. For example:\n", @@ -636,7 +636,7 @@ " - Square root is only applicable to a small range of positive numbers that become integers when multiplied by 10!.\n", " - Factorial is only applicable to integers 0 to 9 (bigger numbers are unlikely to be useful).\n", "\n", - "For binary operations, the symbol is used to construct the expression string, but for unary ops the `fmt` field gives a format string; this allows us to have prefix and postfix unary operations. " + "For binary operations, the symbol is used to construct the expression string, but for unary ops the `fmt` field gives a format string; this allows us to have prefix, postfix, or bracketing unary operations. " ] }, { @@ -649,17 +649,21 @@ "source": [ "Operation = namedtuple('Operation', 'symbol, func, fmt, applicable', defaults=[None, lambda *args: True])\n", "\n", + "def fact(n: float) -> int:\n", + " \"\"\"Convert n to int and take factorial.\"\"\"\n", + " return factorial(int(n))\n", + "\n", "OPERATIONS = {\n", " 2: {Operation('+', add),\n", " Operation('-', sub),\n", " Operation('*', mul),\n", - " Operation('/', div, None, lambda L, R: R != 0),\n", - " Operation('^', pow, None, lambda L, R: (-10 <= R <= 10) and (L > 0 or R == int(R)))},\n", - " 1: {Operation('√', sqrt, '√{}', lambda v: 0 < v <= 256 and (3628800. * v).is_integer()),\n", - " Operation('!', factorial, '{}!', lambda v: v in range(10)),\n", - " Operation('_', neg, '-{}'),\n", - " Operation('⌊', floor, '⌊{}⌋'),\n", - " Operation('⌈', ceil, '⌈{}⌉')}}" + " Operation('/', div, None, lambda L, R: R != 0),\n", + " Operation('^', pow, None, lambda L, R: (-10 <= R <= 10) and (L > 0 or R == int(R)))},\n", + " 1: {Operation('√', sqrt, '√{}', lambda v: 0 < v <= 256 and (3628800. * v).is_integer()),\n", + " Operation('!', fact, '{}!', lambda v: v in range(10)),\n", + " Operation('_', neg, '-{}'),\n", + " Operation('⌊', floor, '⌊{}⌋'),\n", + " Operation('⌈', ceil, '⌈{}⌉')}}\n" ] }, { @@ -668,7 +672,7 @@ "id": "GbpkLTRLKEA_" }, "source": [ - "I'll define the function `operate` to compute an arithmetic operation, catch any errors, and try to correct round-off errors. The idea is that since my expressions start with integers, results that are very close to an integer probably are an integer. So I'll correct `(49*(1/49))` to be `1.0`. Of course, an expression like `(1+(10^-99))` is also very close to `1.0`, but is not equal to `1`. I'll try to avoid such expressions by silently dropping (returning `None` from `operate`) any intermediate value whose absolute value is outside the range of 10-10 to 1010 (except of course I will accept an exact 0)." + "I'll define the function `operate` to compute an arithmetic operation, catch any errors, and try to correct round-off errors. The idea is that since my expressions start with integers, results that are very close to an integer probably are an integer. So I'll correct `(49*(1/49))` to be `1.0`. Of course, an expression like `(1+(10^-99))` is also very close to `1.0`, but is not equal to `1`. I'll try to avoid such expressions by silently dropping (returning `None` from `operate`) any intermediate value whose absolute value is outside the range of 10-10 to 1010." ] }, { @@ -684,7 +688,7 @@ " if operation.applicable(*args):\n", " try:\n", " val = operation.func(*args)\n", - " except (ArithmeticError, ValueError):\n", + " except (ArithmeticError, ValueError, TypeError):\n", " return None\n", " return (0.0 if val == 0 else\n", " None if isinstance(val, complex) else\n", @@ -736,7 +740,8 @@ "def expressions(numbers: Numbers, ops=OPS, nesting=2, permute=False) -> ExpTable:\n", " \"Return {value: expr} for all expressions that can be made from numbers using ops.\"\n", " table = {}\n", - " orderings = (permutations(numbers) if permute else [numbers]) # Handle permutations once at top level\n", + " # Handle permutations once at top level; recursive calls will have permute=False\n", + " orderings = (permutations(numbers) if permute else [numbers]) \n", " for nums in orderings:\n", " table.update(digit_expressions(nums, ops))\n", " add_binary_expressions(table, nums, ops, nesting)\n", @@ -762,8 +767,8 @@ " \"Add binary expressions by splitting numbers and combining with an op.\"\n", " binary_ops = operations(2, ops)\n", " for (Lnums, Rnums) in splits(numbers):\n", - " Ltable = expressions(Lnums, ops, nesting, False)\n", - " Rtable = expressions(Rnums, ops, nesting, False)\n", + " Ltable = expressions(Lnums, ops, nesting, permute=False)\n", + " Rtable = expressions(Rnums, ops, nesting, permute=False)\n", " for (L, R) in product(Ltable, Rtable):\n", " Lexp, Rexp = '(' + Ltable[L], Rtable[R] + ')'\n", " for op in binary_ops:\n", @@ -856,7 +861,7 @@ { "data": { "text/plain": [ - "{1: '1', 2: '2', -1: '(1-2)', 0.5: '(1/2)', 3: '(1+2)'}" + "{1: '1', 2: '2', -1: '(1-2)', 3: '(1+2)', 0.5: '(1/2)'}" ] }, "execution_count": 18, @@ -945,7 +950,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Can make 0 to 72 with (4, 4, 4, 4), ops=\"+-*/^_√!.,\", permute=False. [721,700 table entries]\n", + "Can make 0 to 72 with (4, 4, 4, 4), ops=\"+-*/^_√!.,\", permute=False. [721,704 table entries]\n", "\n", " 0: 44-44 15: 4+(44/4) 30: (4*(4+4))-√4 45: 44+(4/4) 60: 44+(4*4) \n", " 1: 44/44 16: .4*(44-4) 31: 4!+((4+4!)/4) 46: 4-(√4-44) 61: (4/4)+(4!/.4) \n", @@ -954,13 +959,13 @@ " 4: 4!-(44-4!) 19: 4!-(4+(4/4)) 34: 44-(4/.4) 49: 44+(√4/.4) 64: 4!-(4-44) \n", " 5: (44-4!)/4 20: (44-4)/√4 35: 4!+(44/4) 50: 4+(√4+44) 65: (4+(4^4))/4 \n", " 6: √(44-(4+4)) 21: (4+4.4)/.4 36: 44-(4+4) 51: (.4-(4-4!))/.4 66: 4!-(√4-44) \n", - " 7: (44/4)-4 22: √4/(4/44) 37: 4!+((4!+√4)/√4) 52: 4+(4+44) 67: √4+((4!+√4)/.4)\n", + " 7: (44/4)-4 22: √4/(4/44) 37: 4!+((√4+4!)/√4) 52: 4+(4+44) 67: √4+((√4+4!)/.4)\n", " 8: 4+(4.4-.4) 23: (√4+44)/√4 38: 44-(4+√4) 53: 4!+(4!+(√4/.4)) 68: 44+√(4*4)! \n", - " 9: (44/4)-√4 24: 4+(44-4!) 39: 44-(√4/.4) 54: 44+(4/.4) 69: 4+((4!+√4)/.4) \n", - " 10: 44/4.4 25: 4!+(4^(4-4)) 40: 44-√(4*4) 55: 44/(.4+.4) 70: 4!+(√4+44) \n", + " 9: (44/4)-√4 24: 4+(44-4!) 39: 44-(√4/.4) 54: 44+(4/.4) 69: 4+((√4+4!)/.4) \n", + " 10: 44/4.4 25: 4!+(4^(4-4)) 40: 44-√(4*4) 55: 44/(.4+.4) 70: √4+(4!+44) \n", " 11: 44/√(4*4) 26: 4+(44/√4) 41: (.4+(4*4))/.4 56: 44+(4!/√4) 71: (4!+4.4)/.4 \n", " 12: (4+44)/4 27: 4+(4!-(4/4)) 42: √4-(4-44) 57: ((.4+4!)/.4)-4 72: 4+(4!+44) \n", - " 13: 4!-(44/4) 28: 44-(4*4) 43: 44-(4/4) 58: ((4^4)-4!)/4 \n", + " 13: √4+(44/4) 28: 44-(4*4) 43: 44-(4/4) 58: ((4^4)-4!)/4 \n", " 14: 4.4+(.4*4!) 29: 4+(4!+(4/4)) 44: √44*√44 59: (4!/.4)-(4/4) \n" ] } @@ -1147,7 +1152,7 @@ " 3: 5.5-(5*.5) 10: 55/5.5 17: 5+(5!/(5+5)) 24: √(5+(55/5))! 31: 55-(5!/5) 38: ((5!/5)-5)/.5 \n", " 4: √(5+(55/5)) 11: 5.5+5.5 18: ((5!-5)/5)-5 25: .5*(55-5) 32: (5.5-5)^-5 \n", " 5: (.5*5!)-55 12: (5+55)/5 19: (5!-(5*5))/5 26: (5*5)+(5/5) 33: .5*(5!*.55) \n", - " 6: (55/5)-5 13: (5!-55)/5 20: 5*(5-(5/5)) 27: (5*5.5)-.5 34: 5+(5+(5!/5)) \n" + " 6: (55/5)-5 13: (5!-55)/5 20: 5+(5+(5+5)) 27: (5*5.5)-.5 34: 5+(5+(5!/5)) \n" ] } ], @@ -1180,6 +1185,22 @@ "cell_type": "code", "execution_count": 25, "metadata": {}, + "outputs": [], + "source": [ + "def countdowns(years: Sequence[int]):\n", + " \"\"\"Print a countdown of expressions with values from 10 to 0, using the digits (in order) of each year.\"\"\"\n", + " def countdown(i, year): return f\"{unbracket(expressions(digits(year), ops='+-*/_√!,')[i]):16}\"\n", + " for i in reversed(range(11)):\n", + " print(f'{i:2d}:', *[countdown(i, year) for year in years])\n", + " \n", + "def digits(n: int) -> Numbers: return tuple(int(d) for d in str(n))\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1200,17 +1221,36 @@ } ], "source": [ - "def countdowns(years: Sequence[int]):\n", - " \"\"\"Print a countdown of expressions with values from 10 to 0, using the digits (in order) of each year.\"\"\"\n", - " def countdown(i, year): return f\"{unbracket(expressions(digits(year), ops='+-*/_√!,')[i]):16}\"\n", - " for i in reversed(range(11)):\n", - " print(f'{i:2d}:', *[countdown(i, year) for year in years])\n", - " \n", - "def digits(n: int) -> Numbers: return tuple(int(d) for d in str(n))\n", - " \n", "countdowns(range(2018, 2025))" ] }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10: 20/√(-2+6) √(20*(-2+7)) 20-(2+8) √(20*(2+√9)) -20+30 20/(3-1) √(20*(3+2)) \n", + " 9: 2-(0!-(2+6)) √((2+0!)*27) (2/(0+2))+8 -20+29 (2+0!)*(3-0) 2-(0-(3!+1)) 2+(0!+(3*2)) \n", + " 8: 20-(2*6) (2/(0+2))+7 -20+28 20-(2*√9!) 2*(0+(3+0!)) √(2*(0!+31)) 20-(3!*2) \n", + " 7: 2+√(-0!+26) -20+27 (2/(0-2))+8 √(20+29) (2*(0+3))+0! (2*(0+3))+1 (20-3!)/2 \n", + " 6: -20+26 20-(2*7) √(20+(2*8)) √(-20+29)! (2+(0*30)!)! (2+(0*31)!)! (2+(0*32)!)! \n", + " 5: 20/(-2+6) √(20-(2-7)) 20*(2/8) √(20+(2+√9)) 20/(3+0!) 20/(3+1) 20/(3!-2) \n", + " 4: (20/2)-6 20/(-2+7) 20-(2*8) 20/(2+√9) 20/(3!-0!) 20/(3!-1) 20/(3+2) \n", + " 3: (20-2)/6 (20/2)-7 2+(0*28)! √(-20+29) 2+(0*30)! 2+(0*31)! 2+(0*32)! \n", + " 2: 2-(0*26) 2-(0*27) 2-(0*28) 2-(0*29) 2-(0*30) 2-(0*31) 2-(0*32) \n", + " 1: 2-(0*26)! 2-(0*27)! 2-(0*28)! (20/2)-9 (203*0)! 2-(0*31)! 2-(0*32)! \n", + " 0: 2*(0*26) 2*(0*27) 2*(0*28) 2*(0*29) 203*0 2*(0*31) 2*(0*32) \n" + ] + } + ], + "source": [ + "countdowns(range(2026, 2033))" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1226,7 +1266,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -1235,7 +1275,7 @@ "'(((3^2)-3)*4)'" ] }, - "execution_count": 26, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -1257,7 +1297,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 29, "metadata": { "id": "dLZMMnH-KEBB", "outputId": "9e964cef-f10d-49fd-faf6-bc171de07344" @@ -1274,7 +1314,7 @@ " '(4*((3^2)-3))'}" ] }, - "execution_count": 27, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -1299,7 +1339,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 30, "metadata": { "id": "snhb7k8OKEBB", "outputId": "44f3cf49-aa56-4900-f510-3eedb4970307" @@ -1316,12 +1356,12 @@ " '(3*((8*2)-8))',\n", " '(3/(2/(8+8)))',\n", " '(3/(8/(8^2)))',\n", + " '(8*(8-(2+3)))',\n", " '(8*(8-(3+2)))',\n", - " '(8+((2^3)+8))',\n", - " '(8+(8+(2^3)))'}" + " '(8+((2^3)+8))'}" ] }, - "execution_count": 28, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -1332,7 +1372,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 31, "metadata": { "id": "gia8RdaUKEBB", "outputId": "46852452-3ebd-4718-ad7a-52d4fc6de9bf" @@ -1350,7 +1390,7 @@ " '(10-(2*(3-10)))'}" ] }, - "execution_count": 29, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -1361,7 +1401,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 32, "metadata": { "id": "VhhMQ33sKEBB", "outputId": "66fe6857-f940-409b-aa2a-04fdb00e064e" @@ -1373,7 +1413,7 @@ "{'(8/(3-(8/3)))'}" ] }, - "execution_count": 30, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1384,7 +1424,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 33, "metadata": { "id": "nbcNqMdFKEBB", "outputId": "e3d17354-e297-4ded-9193-5fe615902072" @@ -1399,15 +1439,15 @@ " '(2*(6*(6/3)))',\n", " '(2*(6/(3/6)))',\n", " '(2/(3/(6*6)))',\n", - " '(6*(2*(6/3)))',\n", - " '(6*(2/(3/6)))',\n", " '(6*(6*(2/3)))',\n", " '(6*(6/(3/2)))',\n", + " '(6+(2*(3+6)))',\n", + " '(6+(2*(6+3)))',\n", " '(6/(3/(2*6)))',\n", " '(6/(3/(6*2)))'}" ] }, - "execution_count": 31, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -1418,7 +1458,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 34, "metadata": { "id": "L8SAsmSrKEBB", "outputId": "33874782-4dcd-460e-dfaf-140fe71bf502" @@ -1430,7 +1470,7 @@ "{'((5^2)-(0^0))'}" ] }, - "execution_count": 32, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1452,7 +1492,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 35, "metadata": { "id": "VDlW5eWVKEBB", "outputId": "d2d3e78c-485f-407a-8888-579ba423f1d2" @@ -1464,7 +1504,7 @@ "{'(10-(6/(13-11))!)!'}" ] }, - "execution_count": 33, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -1475,7 +1515,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 36, "metadata": { "id": "5GYEEXhnKEBB", "outputId": "bdee3db6-f560-4b4f-ba2a-036b4d8ee1b3" @@ -1487,7 +1527,7 @@ "{'(8/((1^9)+1))!', '(8/(1+(1^9)))!'}" ] }, - "execution_count": 34, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -1498,7 +1538,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 37, "metadata": { "id": "pqZLLXXCKEBB", "outputId": "97da7ef1-2033-45d0-f636-1ea7bc14d126" @@ -1510,7 +1550,7 @@ "{'(9!/(7!+(7!+7!)))'}" ] }, - "execution_count": 35, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1522,10 +1562,11 @@ { "cell_type": "markdown", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ + "# License Plate Game\n", + "\n", "**Aarati Marino** writes \"the kids and I just devised a cool game to play in the car this morning. Just take the last 4 digits of the license plate in front of you, and use addition, subtraction, multiplication, and division to make 24.\" \n", "\n", "We can find all the license plates for which there is a solution:" @@ -1533,22 +1574,22 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "466 out of 715 distinct license plates can be solved:\n", + "466 out of 715 distinct license plates (65%) can be solved:\n", "\n", "0038: 0-(0-(3*8)) 1149: (1-4)*(1-9) 1458: (1+5)*(8-4) 2348: (2-(3-4))*8 3355: (5*5)-(3/3) 4477: (4-(4/7))*7 \n", "0046: 0-(0-(4*6)) 1155: 1*((5*5)-1) 1459: ((4-1)*5)+9 2349: 2/(3/(4*9)) 3356: 3+((3*5)+6) 4478: 4+((4*7)-8) \n", "0128: 0+((1+2)*8) 1156: 1*((5-1)*6) 1466: ((1+4)*6)-6 2355: 2-(3-(5*5)) 3357: 3*((3*5)-7) 4479: 4*(4-(7-9)) \n", - "0136: 0+((1+3)*6) 1157: (1+1)*(5+7) 1467: (1-(4-7))*6 2356: (2*(3*5))-6 3359: (3+3)*(9-5) 4488: 4+(4+(8+8)) \n", + "0136: 0+((1+3)*6) 1157: (1+1)*(5+7) 1467: (1-(4-7))*6 2356: (2-(3-5))*6 3359: (3+3)*(9-5) 4488: 4+(4+(8+8)) \n", "0137: 0+((1+7)*3) 1158: (5-(1+1))*8 1468: (1-(4-6))*8 2357: 2+((3*5)+7) 3366: 3*((6/3)+6) 4489: (4*9)-(4+8) \n", "0138: 0+(1*(3*8)) 1166: (1+1)*(6+6) 1469: 6*(9-(1+4)) 2358: (2*(3+5))+8 3367: 3-((3-6)*7) 4555: 4-(5-(5*5)) \n", - "0139: 0-((1-9)*3) 1168: 6/((1+1)/8) 1477: (1+7)*(7-4) 2359: 2*(3*(9-5)) 3368: ((3*3)-6)*8 4556: 4/(5/(5*6)) \n", + "0139: 0-((1-9)*3) 1168: 6/((1+1)/8) 1477: (1+7)*(7-4) 2359: 2*(3*(9-5)) 3368: ((3*3)-6)*8 4556: 4*(5-(5-6)) \n", "0145: 0+((1+5)*4) 1169: ((1+1)*9)+6 1478: 1*((7-4)*8) 2366: 2/(3/(6*6)) 3369: (3*3)+(6+9) 4557: 4*(7-(5/5)) \n", "0146: 0+(1*(4*6)) 1188: ((1+1)*8)+8 1479: (1-9)*(4-7) 2367: ((2*7)-6)*3 3377: (3+(3/7))*7 4558: (4-(5/5))*8 \n", "0147: 0-((1-7)*4) 1224: (1+2)*(2*4) 1488: 1*((4*8)-8) 2368: ((2+8)*3)-6 3378: (3*3)+(7+8) 4559: 4-(5*(5-9)) \n", @@ -1560,9 +1601,9 @@ "0236: 0+((2+6)*3) 1233: (1+3)*(2*3) 1567: 1+((5*6)-7) 2389: 8/(2/(9-3)) 3445: 3+((4*4)+5) 4578: 4*(5-(7-8)) \n", "0238: (0*2)+(3*8) 1234: 1*(2*(3*4)) 1568: (1-(5-8))*6 2399: (2*3)+(9+9) 3446: (3+(4/4))*6 4579: (4*7)+(5-9) \n", "0239: 0+(2*(3+9)) 1235: (1+2)*(3+5) 1569: 1*(6*(9-5)) 2444: 2*(4+(4+4)) 3447: 3*((4/4)+7) 4588: 4*(5+(8/8)) \n", - "0244: 0+((2+4)*4) 1236: 1*((2+6)*3) 1578: (1-(5-7))*8 2445: ((2*5)-4)*4 3448: 3/(4/(4*8)) 4589: 4*(5-(8-9)) \n", + "0244: 0+((2+4)*4) 1236: 1*((2+6)*3) 1578: (1-(5-7))*8 2445: ((2*5)-4)*4 3448: 3*(4-(4-8)) 4589: 4*(5-(8-9)) \n", "0246: (0*2)+(4*6) 1237: 1+(2+(3*7)) 1579: (1-7)*(5-9) 2446: 2+((4*4)+6) 3449: 3*(9-(4/4)) 4599: 4*(5+(9/9)) \n", - "0248: 0+(2*(4+8)) 1238: (1+3)*(8-2) 1588: 1*((8-5)*8) 2447: 2*(4*(7-4)) 3455: 3-(4-(5*5)) 4666: 4/(6/(6*6)) \n", + "0248: 0+(2*(4+8)) 1238: (1+3)*(8-2) 1588: 1*((8-5)*8) 2447: 2*(4*(7-4)) 3455: 3-(4-(5*5)) 4666: 4*(6-(6-6)) \n", "0257: 0+(2*(5+7)) 1239: 1*(2*(3+9)) 1589: (1-9)*(5-8) 2448: (2*(4*4))-8 3456: (3-(4-5))*6 4667: 4*(6*(7-6)) \n", "0258: 0-((2-5)*8) 1244: 1*((2+4)*4) 1599: 1+(5+(9+9)) 2449: (4*(9-2))-4 3457: (3*4)+(5+7) 4668: 4+(6+(6+8)) \n", "0266: 0+(2*(6+6)) 1245: (2-(1-5))*4 1666: ((6-1)*6)-6 2455: (2*(5+5))+4 3458: 3*((5-4)*8) 4669: (4*9)-(6+6) \n", @@ -1570,14 +1611,14 @@ "0269: 0+((2*9)+6) 1247: (1-(2-7))*4 1669: (1-(6-9))*6 2457: 4/(2/(5+7)) 3466: (3*4)+(6+6) 4678: (4+(6-7))*8 \n", "0288: 0+((2*8)+8) 1248: 1*(2*(4+8)) 1679: (1+7)*(9-6) 2458: 2*((4*5)-8) 3468: 3*(4*(8-6)) 4679: 6/(4/(7+9)) \n", "0334: 0+((3+3)*4) 1249: ((1+9)*2)+4 1688: (1-(6-8))*8 2459: (2+4)*(9-5) 3469: (3-(6-9))*4 4688: 4*(6-(8-8)) \n", - "0335: 0+(3*(3+5)) 1255: 1-(2-(5*5)) 1689: 1+(6+(8+9)) 2466: (2-(4-6))*6 3477: 3+((4*7)-7) 4689: 4*(6*(9-8)) \n", + "0335: 0+(3*(3+5)) 1255: 1-(2-(5*5)) 1689: 1+(6+(8+9)) 2466: (2-(4-6))*6 3477: 3-((4-7)*7) 4689: 4*(6*(9-8)) \n", "0337: 0+(3+(3*7)) 1256: (1-(2-5))*6 1699: 1*(6+(9+9)) 2467: 2+((4*7)-6) 3478: (4*(7-3))+8 4699: 4*(6-(9-9)) \n", "0338: (0*3)+(3*8) 1257: 1*(2*(5+7)) 1779: 1+(7+(7+9)) 2468: 2/(4/(6*8)) 3479: (3*(4+7))-9 4777: 4*(7-(7/7)) \n", "0339: 0-(3-(3*9)) 1258: 1*((5-2)*8) 1788: 1+(7+(8+8)) 2469: (2+(4/6))*9 3489: 3+(4+(8+9)) 4778: 4*(7+(7-8)) \n", "0344: 0+(3*(4+4)) 1259: ((1+2)*5)+9 1789: 1*(7+(8+9)) 2477: (2*(7+7))-4 3499: (3*(9-4))+9 4788: 4*(7-(8/8)) \n", - "0346: (0*3)+(4*6) 1266: 1*(2*(6+6)) 1799: 7-(1-(9+9)) 2478: ((2*7)-8)*4 3556: (3+(5/5))*6 4789: 4*(7+(8-9)) \n", + "0346: (0*3)+(4*6) 1266: 1*(2*(6+6)) 1799: 7-(1-(9+9)) 2478: ((2*7)-8)*4 3556: (3*(5+5))-6 4789: 4*(7+(8-9)) \n", "0348: (0*4)+(3*8) 1267: (1-7)*(2-6) 1888: 1*(8+(8+8)) 2479: (2*4)+(7+9) 3557: 3*((5/5)+7) 4799: 4*(7-(9/9)) \n", - "0349: 0-((3-9)*4) 1268: 1/(2/(6*8)) 1889: 8-(1-(8+9)) 2488: (2*4)+(8+8) 3558: 3/(5/(5*8)) 4888: (4-(8/8))*8 \n", + "0349: 0-((3-9)*4) 1268: 1/(2/(6*8)) 1889: 8-(1-(8+9)) 2488: (2*4)+(8+8) 3558: 3*(5-(5-8)) 4888: (4-(8/8))*8 \n", "0358: (0*5)+(3*8) 1269: 1*((2*9)+6) 2223: 2*(2*(2*3)) 2489: 8*(9-(2+4)) 3559: 3*(9-(5/5)) 4889: (4+(8-9))*8 \n", "0359: 0+((3*5)+9) 1277: ((7*7)-1)/2 2224: 2*(2*(2+4)) 2499: 2+(4+(9+9)) 3566: (3-(5-6))*6 4899: (4-(9/9))*8 \n", "0366: 0+((3*6)+6) 1278: 1+((2*8)+7) 2225: 2*(2+(2*5)) 2557: (2*7)+(5+5) 3567: 3*(6-(5-7)) 5555: (5*5)-(5/5) \n", @@ -1590,7 +1631,7 @@ "0446: (0*4)+(4*6) 1336: ((1+6)*3)+3 2236: 2*((2*3)+6) 2577: (2*5)+(7+7) 3599: (3-9)*(5-9) 5578: (5*5)+(7-8) \n", "0447: 0-(4-(4*7)) 1337: 1*(3+(3*7)) 2237: 2*(2+(3+7)) 2578: ((2*5)-7)*8 3666: (3+(6/6))*6 5588: (5*5)-(8/8) \n", "0448: 0+((4*4)+8) 1338: ((1+8)*3)-3 2238: 2-(2-(3*8)) 2579: (5*7)-(2+9) 3667: 3*((6/6)+7) 5589: (5*5)+(8-9) \n", - "0456: (0*5)+(4*6) 1339: 1*((3*9)-3) 2239: (2+(2/3))*9 2588: (5*8)-(2*8) 3668: 3/(6/(6*8)) 5599: (5*5)-(9/9) \n", + "0456: (0*5)+(4*6) 1339: 1*((3*9)-3) 2239: (2+(2/3))*9 2588: (5*8)-(2*8) 3668: 3*(6-(6-8)) 5599: (5*5)-(9/9) \n", "0466: (0*6)+(4*6) 1344: 1*(3*(4+4)) 2244: 2*((2*4)+4) 2589: 2+(5+(8+9)) 3669: 3+(6+(6+9)) 5666: (5-(6/6))*6 \n", "0467: (0*7)+(4*6) 1345: 1+(3+(4*5)) 2245: 2+(2+(4*5)) 2666: (2*6)+(6+6) 3677: 3*(7-(6-7)) 5667: 5+(6+(6+7)) \n", "0468: 0-((4-8)*6) 1346: 6/(1-(3/4)) 2246: 2-(2-(4*6)) 2667: (6+(6*7))/2 3678: 3+(6+(7+8)) 5668: 6-((5-8)*6) \n", @@ -1598,26 +1639,26 @@ "0478: 0-((4-7)*8) 1348: ((1+3)*4)+8 2248: (2*(2*4))+8 2669: (2+6)*(9-6) 3688: (3+(8/8))*6 5677: (5-(7/7))*6 \n", "0488: 0+((4*8)-8) 1349: 1+((3*9)-4) 2249: 2+((2*9)+4) 2678: (2-(6-7))*8 3689: (3-(8-9))*6 5678: (5+7)*(8-6) \n", "0566: 0+((5*6)-6) 1356: 1+((3*6)+5) 2255: 2*(2+(5+5)) 2679: 2+(6+(7+9)) 3699: (3*9)+(6-9) 5679: 6-((5-7)*9) \n", - "0569: 0-((5-9)*6) 1357: (1+5)*(7-3) 2256: 2+(2*(5+6)) 2688: 2+(6+(8+8)) 3777: 3*(7+(7/7)) 5688: (5+(6-8))*8 \n", - "0588: 0-((5-8)*8) 1358: 1+((3*5)+8) 2257: (2*5)+(2*7) 2689: 2/(6/(8*9)) 3778: 3/(7/(7*8)) 5689: (5+(8-9))*6 \n", + "0569: 0-((5-9)*6) 1357: (1+5)*(7-3) 2256: 2+(2*(5+6)) 2688: 2+(6+(8+8)) 3777: 3+(7+(7+7)) 5688: (5+(6-8))*8 \n", + "0588: 0-((5-8)*8) 1358: 1+((3*5)+8) 2257: (2*5)+(2*7) 2689: 2/(6/(8*9)) 3778: 3*(7-(7-8)) 5689: (5+(8-9))*6 \n", "0689: 0-((6-9)*8) 1359: 1*((3*5)+9) 2258: (2*(5+8))-2 2699: (2+(6/9))*9 3779: 3*(9-(7/7)) 5699: (5*(9-6))+9 \n", "0699: 0+(6+(9+9)) 1366: 1*((3*6)+6) 2259: 2*(5-(2-9)) 2778: 2+(7+(7+8)) 3788: 3*(7+(8/8)) 5779: (5+7)*(9-7) \n", "0789: 0+(7+(8+9)) 1367: 1*(6*(7-3)) 2266: (2*6)+(2*6) 2788: (2-(7-8))*8 3789: 3*(7-(8-9)) 5788: ((7-5)*8)+8 \n", "0888: 0+(8+(8+8)) 1368: 1*((6-3)*8) 2267: (2*(2+7))+6 2789: (2*(7+9))-8 3799: 3*(7+(9/9)) 5789: (5+(7-9))*8 \n", - "1118: (1+(1+1))*8 1369: (1-9)*(3-6) 2268: (2*(2+6))+8 2888: (2+(8/8))*8 3888: 3/(8/(8*8)) 5888: (5*8)-(8+8) \n", + "1118: (1+(1+1))*8 1369: (1-9)*(3-6) 2268: (2*(2+6))+8 2888: (2*(8+8))-8 3888: 3*(8-(8-8)) 5888: (5*8)-(8+8) \n", "1126: (1+1)*(2*6) 1377: (1-7)*(3-7) 2269: 2*((2*9)-6) 2889: (2-(8-9))*8 3889: 3*(8*(9-8)) 5889: 8/((8-5)/9) \n", "1127: (1+2)*(1+7) 1378: 3/(1-(7/8)) 2277: 2*(7-(2-7)) 2899: (2+(9/9))*8 3899: 3*(8-(9-9)) 6666: 6+(6+(6+6)) \n", "1128: 1*((1+2)*8) 1379: (1+7)/(3/9) 2278: 2+((2*7)+8) 3333: (3*(3*3))-3 3999: 3*(9-(9/9)) 6668: 6*(6+(6-8)) \n", "1129: (1+2)*(9-1) 1388: ((1+3)*8)-8 2288: (2*(2*8))-8 3334: 3+(3*(3+4)) 4444: 4+(4+(4*4)) 6669: 6-(6*(6-9)) \n", "1134: (1+1)*(3*4) 1389: 1/(3/(8*9)) 2289: (2*9)-(2-8) 3335: (3*3)+(3*5) 4445: 4*((4/4)+5) 6679: 6*(6+(7-9)) \n", - "1135: (1+3)*(1+5) 1399: (9-1)/(3/9) 2333: 2*(3+(3*3)) 3336: 3+(3+(3*6)) 4446: 4-(4-(4*6)) 6688: 6/((8-6)/8) \n", + "1135: (1+3)*(1+5) 1399: (9-1)/(3/9) 2333: 2*(3+(3*3)) 3336: 3+(3+(3*6)) 4446: 4*(4-(4-6)) 6688: 6/((8-6)/8) \n", "1136: 1*((1+3)*6) 1444: ((1+4)*4)+4 2335: 2*((3*5)-3) 3337: 3*((3/3)+7) 4447: (4+4)*(7-4) 6689: 6-((6-8)*9) \n", - "1137: 1*((1+7)*3) 1445: 1*(4+(4*5)) 2336: 2*(3+(3+6)) 3338: 3-(3-(3*8)) 4448: (4-(4/4))*8 6789: 6*(8/(9-7)) \n", - "1138: 1*(1*(3*8)) 1446: ((1+6)*4)-4 2337: 2*(3*(7-3)) 3339: 3*(9-(3/3)) 4449: 4-(4*(4-9)) 6799: 6-((7-9)*9) \n", + "1137: 1*((1+7)*3) 1445: 1*(4+(4*5)) 2336: 2*(3+(3+6)) 3338: 3*(3-(3-8)) 4448: (4*(4+4))-8 6789: 6*(8/(9-7)) \n", + "1138: 1-(1-(3*8)) 1446: ((1+6)*4)-4 2337: 2*(3*(7-3)) 3339: 3*(9-(3/3)) 4449: 4-(4*(4-9)) 6799: 6-((7-9)*9) \n", "1139: (1+1)*(3+9) 1447: 1+((4*4)+7) 2338: (2+(3/3))*8 3344: 3*((3*4)-4) 4455: (4+(4/5))*5 6888: 8-((6-8)*8) \n", "1144: (1+(1+4))*4 1448: 1*((4*4)+8) 2339: ((2+3)*3)+9 3345: ((3/3)+5)*4 4456: 4*((5-4)*6) 6889: (8+8)/(6/9) \n", "1145: 1*((1+5)*4) 1449: (1-(4-9))*4 2344: ((2+3)*4)+4 3346: 3-(3-(4*6)) 4457: 4*(4-(5-7)) 6899: 8/(6/(9+9)) \n", - "1146: 1*(1*(4*6)) 1455: 4-((1-5)*5) 2345: 2*(3+(4+5)) 3347: 3*(4-(3-7)) 4458: (4+(4-5))*8 7889: 8-((7-9)*8) \n", + "1146: 1-(1-(4*6)) 1455: 4-((1-5)*5) 2345: 2*(3+(4+5)) 3347: 3*(4-(3-7)) 4458: (4+(4-5))*8 7889: 8-((7-9)*8) \n", "1147: 1*(4*(7-1)) 1456: 4/(1-(5/6)) 2346: 2+((3*6)+4) 3348: (3+3)*(8-4) 4468: 4*(4-(6-8)) \n", "1148: (1+1)*(4+8) 1457: 1+((4*7)-5) 2347: (2-(3-7))*4 3349: 3*(3-(4-9)) 4469: 4*(4/(6/9)) \n" ] @@ -1630,12 +1671,273 @@ " def solve(plate): return expressions(plate, ops='+-*/', permute=True).get(24)\n", " solved = [f\"{cat(plate)}: {unbracket(solve(plate))} \" \n", " for plate in plates if solve(plate)]\n", - " print(f'{len(solved)} out of {len(plates)} distinct license plates can be solved:\\n')\n", + " S, P = len(solved), len(plates)\n", + " print(f'{S} out of {P} distinct license plates ({S/P:.0%}) can be solved:\\n')\n", " show_columns(solved)\n", " \n", "show_plates()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "But I remember the game as trying to make an equation: that is, on seeing the plate \"2346\", my game is to find \"6/3 = 4/2\". Let's try that, and let's throw in a few additional operators:" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "714 out of 715 distinct license plates (99.9%) can be solved:\n", + "\n", + "0000: 0 = (0-(0-0)) 0477: 0 = (4*(7-7)) 1569: 1 = ((6-5)^9) 3448: 3 = ((4+8)/4) \n", + "0001: 0 = (0*10) 0478: 0! = ((7-8)^4) 1577: 1 = (5^(7-7)) 3449: 3 = (√49-4) \n", + "0002: 0 = (0*20) 0479: 0 = (√49-7) 1578: 1 = ((8-7)^5) 3455: 3 = √(45/5) \n", + "0003: 0 = (0*30) 0488: 0 = (4*(8-8)) 1579: 1 = (5-(7-√9)) 3456: 3 = (√64-5) \n", + "0004: 0 = (0*40) 0489: 0 = (4!-(8*√9)) 1588: 1 = (5^(8-8)) 3457: 3 = ((5+7)/4) \n", + "0005: 0 = (0*50) 0499: 0 = (4*(9-9)) 1589: 1 = ((9-8)^5) 3458: 3 = √√(85-4) \n", + "0006: 0 = (0*60) 0555: 0 = (5*(5-5)) 1599: 1 = (5^(9-9)) 3459: 3 = √(54/√9!) \n", + "0007: 0 = (0*70) 0556: 0 = ((5-5)*6) 1666: 1 = (6^(6-6)) 3466: 3 = (4-(6/6)) \n", + "0008: 0 = (0*80) 0557: 0 = ((5-5)*7) 1667: 1 = ((6/6)^7) 3467: 3 = (4+(6-7)) \n", + "0009: 0 = (0*90) 0558: 0 = ((5-5)*8) 1668: 1 = ((6/6)^8) 3468: 3 = (4*(6/8)) \n", + "0011: 0 = (0*11) 0559: 0 = ((5-5)*9) 1669: 1 = ((6/6)^9) 3469: 3 = (√4/(6/9)) \n", + "0012: 0 = (0*12) 0566: 0 = (5*(6-6)) 1677: 1 = (6^(7-7)) 3477: 3 = √√(4+77) \n", + "0013: 0 = (0*13) 0567: 0! = ((6-5)^7) 1678: 1 = ((6-7)^8) 3478: 3 = (4+(7-8)) \n", + "0014: 0 = (0*14) 0568: 0 = (6-(8-5)!) 1679: 1 = ((7-6)^9) 3479: 3 = (9/(7-4)) \n", + "0015: 0 = (0*15) 0569: 0 = (5*(6-√9!)) 1688: 1 = (6^(8-8)) 3488: 3 = (4-(8/8)) \n", + "0016: 0 = (0*16) 0577: 0 = (5*(7-7)) 1689: 1 = ((8-9)^6) 3489: 3 = (4+(8-9)) \n", + "0017: 0 = (0*17) 0578: 0! = ((8-7)^5) 1699: 1 = (6^(9-9)) 3499: 3 = (4-(9/9)) \n", + "0018: 0 = (0*18) 0579: 0! = (5-(7-√9)) 1777: 1 = (7^(7-7)) 3555: 3! = (5+(5/5)) \n", + "0019: 0 = (0*19) 0588: 0 = (5*(8-8)) 1778: 1 = ((7/7)^8) 3556: 3 = (6!/(5!+5!)) \n", + "0022: 0 = (0*22) 0589: 0 = (5-(8-√9)) 1779: 1 = ((7/7)^9) 3557: 3 = (5+(5-7)) \n", + "0023: 0 = (0*23) 0599: 0 = (5*(9-9)) 1788: 1 = (7^(8-8)) 3558: 3 = (5!/(5*8)) \n", + "0024: 0 = (0*24) 0666: 0 = (6*(6-6)) 1789: 1 = ((8-7)^9) 3559: 3 = (5-(5-√9)) \n", + "0025: 0 = (0*25) 0667: 0 = ((6-6)*7) 1799: 1 = (7^(9-9)) 3566: √3 = (√√(5/6!)*6) \n", + "0026: 0 = (0*26) 0668: 0 = ((6-6)*8) 1888: 1 = (8^(8-8)) 3567: 3 = √√(5+76) \n", + "0027: 0 = (0*27) 0669: 0 = ((6-6)*9) 1889: 1 = ((8/8)^9) 3568: 3 = √√(86-5) \n", + "0028: 0 = (0*28) 0677: 0 = (6*(7-7)) 1899: 1 = (8^(9-9)) 3569: 3 = ((6+9)/5) \n", + "0029: 0 = (0*29) 0678: 0! = ((6-7)^8) 1999: 1 = (9^(9-9)) 3577: 3 = √(7-(5-7)) \n", + "0033: 0 = (0*33) 0679: 0 = ((6-√9!)*7) 2222: 2 = (2-(2-2)) 3578: 3 = ((7+8)/5) \n", + "0034: 0 = (0*34) 0688: 0 = (6*(8-8)) 2223: 2 = √√(32/2) 3579: 3 = (5+(7-9)) \n", + "0035: 0 = (0*35) 0689: 0 = ((6-√9!)*8) 2224: 2 = (4!-22) 3588: 3 = (√(8*8)-5) \n", + "0036: 0 = (0*36) 0699: 0 = (6*(9-9)) 2225: 2 = √(5-(2/2)) 3589: 3 = (9/(8-5)) \n", + "0037: 0 = (0*37) 0777: 0 = (7*(7-7)) 2226: 2 = √√(22-6) 3599: 3 = ((9+√9!)/5) \n", + "0038: 0 = (0*38) 0778: 0 = ((7-7)*8) 2227: 2 = √√(2+(2*7)) 3666: 3! = (6-(6-6)) \n", + "0039: 0 = (0*39) 0779: 0 = ((7-7)*9) 2228: 2 = (8/(2*2)) 3667: 3! = (6*(7-6)) \n", + "0044: 0 = (0*44) 0788: 0 = (7*(8-8)) 2229: 2 = (2*(√9-2)) 3668: 3 = (6/(8-6)) \n", + "0045: 0 = (0*45) 0789: 0! = ((8-7)^9) 2233: 2 = (2-(3-3)) 3669: 3 = (6+(6-9)) \n", + "0046: 0 = (0*46) 0799: 0 = (7*(9-9)) 2234: 2 = √(24/3!) 3677: 3! = (6-(7-7)) \n", + "0047: 0 = (0*47) 0888: 0 = (8*(8-8)) 2235: 2 = (√25-3) 3678: 3 = √√(87-6) \n", + "0048: 0 = (0*48) 0889: 0 = ((8-8)*9) 2236: 2 = √(√36-2) 3679: 3 = (6/(9-7)) \n", + "0049: 0 = (0*49) 0899: 0 = (8*(9-9)) 2237: 2 = √√(23-7) 3688: 3 = (6/√√(8+8)) \n", + "0055: 0 = (0*55) 0999: 0 = (9*(9-9)) 2238: 2 = √(32/8) 3689: 3 = (6/(8-√9!)) \n", + "0056: 0 = (0*56) 1111: 1 = (1^√11) 2239: 2 = (2-(3-√9)) 3699: 3 = (9/(9-6)) \n", + "0057: 0 = (0*57) 1112: 1 = (1^√12) 2244: 2 = (2-(4-4)) 3777: 3! = (7-(7/7)) \n", + "0058: 0 = (0*58) 1113: 1 = (1^√13) 2245: 2 = (2*(5-4)) 3778: 3 = √((7/7)+8) \n", + "0059: 0 = (0*59) 1114: 1 = (1^√14) 2246: 2 = (26-4!) 3779: 3 = (7-(7-√9)) \n", + "0066: 0 = (0*66) 1115: 1 = (1^√15) 2247: 2 = (√(2+7)!-4) 3788: 3 = √√(88-7) \n", + "0067: 0 = (0*67) 1116: 1 = (1^√16) 2248: 2 = √(28-4!) 3789: 3 = √√(78+√9) \n", + "0068: 0 = (0*68) 1117: 1 = (1^√17) 2249: 2 = √(24/√9!) 3799: 3 = (√√9^(9-7)) \n", + "0069: 0 = (0*69) 1118: 1 = (1^√18) 2255: 2 = (2-(5-5)) 3888: 3 = √(8+(8/8)) \n", + "0077: 0 = (0*77) 1119: 1 = (1^√19) 2256: 2 = √√√256 3889: 3 = √√(89-8) \n", + "0078: 0 = (0*78) 1122: 1 = (1^√22) 2257: 2 = (7-√25) 3899: 3 = ((9-8)*√9) \n", + "0079: 0 = (0*79) 1123: 1 = (1^√23) 2258: 2 = ((2*5)-8) 3999: 3 = (9-(9-√9)) \n", + "0088: 0 = (0*88) 1124: 1 = (1^√24) 2259: 2 = (√25-√9) 4444: 4 = (4-(4-4)) \n", + "0089: 0 = (0*89) 1125: 1 = (1^√25) 2266: 2 = (2-(6-6)) 4445: 4 = (4*(5-4)) \n", + "0099: 0 = (0*99) 1126: 1 = (1^√26) 2267: 2 = (2*(7-6)) 4446: 4 = (√64-4) \n", + "0111: 0 = (1*(1-1)) 1127: 1 = (1^√27) 2268: 2 = (6-(8/2)) 4447: 4 = ((4+4!)/7) \n", + "0112: 0 = (1+(1-2)) 1128: 1 = (1^√28) 2269: 2 = ((2^√9)-6) 4448: 4 = (√4/(4/8)) \n", + "0113: 0 = (1-(1^3)) 1129: 1 = (1^√29) 2277: 2 = (2-(7-7)) 4449: 4 = (4*(4-√9)) \n", + "0114: 0 = (1-(1^4)) 1133: 1 = (1^√33) 2278: 2 = √(28/7) 4455: 4 = (4-(5-5)) \n", + "0115: 0 = (1-(1^5)) 1134: 1 = (1^√34) 2279: 2 = (√2^(9-7)) 4456: 4 = √(6!/45) \n", + "0116: 0 = (1-(1^6)) 1135: 1 = (1^√35) 2288: 2 = (2-(8-8)) 4457: 4 = (√4-(5-7)) \n", + "0117: 0 = (1-(1^7)) 1136: 1 = (1^√36) 2289: 2 = (2*(9-8)) 4458: 4 = ((√4^5)/8) \n", + "0118: 0 = (1-(1^8)) 1137: 1 = (1^√37) 2299: 2 = (2-(9-9)) 4459: 4 = (5-(4-√9)) \n", + "0119: 0 = (1-(1^9)) 1138: 1 = (1^√38) 2333: 2 = (3-(3/3)) 4466: 4 = (4-(6-6)) \n", + "0122: 0 = (1*(2-2)) 1139: 1 = (1^√39) 2334: 2 = (3+(3-4)) 4467: 4 = (4*(7-6)) \n", + "0123: 0 = (1+(2-3)) 1144: 1 = (1^√44) 2335: 2 = (3-(3!-5)) 4468: 4 = √(√64+8) \n", + "0124: 0 = (1*(2-√4)) 1145: 1 = (1^√45) 2336: 2 = (√36/3) 4469: 4 = (96/4!) \n", + "0125: 0 = (2-√(5-1)) 1146: 1 = (1^√46) 2337: 2 = ((3*3)-7) 4477: 4 = (4-(7-7)) \n", + "0126: 0 = (√√16-2) 1147: 1 = (1^√47) 2338: 2 = (8-(3+3)) 4478: 4 = (4*(8-7)) \n", + "0127: 0! = (1^√27) 1148: 1 = (1^√48) 2339: 2 = ((9-3)/3) 4479: 4 = ((7+9)/4) \n", + "0128: 0! = (1^√28) 1149: 1 = (1^√49) 2344: 2 = (3-(4/4)) 4488: 4 = (4-(8-8)) \n", + "0129: 0 = (1+(2-√9)) 1155: 1 = (1^√55) 2345: 2 = (3+(4-5)) 4489: 4 = √(48/√9) \n", + "0133: 0 = (1*(3-3)) 1156: 1 = (1^√56) 2346: 2 = (√36-4) 4499: 4 = (√49-√9) \n", + "0134: 0 = (1+(3-4)) 1157: 1 = (1^√57) 2347: 2 = ((3^√4)-7) 4555: 4 = (5-(5/5)) \n", + "0135: 0 = (1-(3!-5)) 1158: 1 = (1^√58) 2348: 2 = √√(48/3) 4556: 4 = (5+(5-6)) \n", + "0136: 0 = (1*(3!-6)) 1159: 1 = (1^√59) 2349: 2 = √(√49-3) 4557: √4 = (7-√(5*5)) \n", + "0137: 0 = (1+(3!-7)) 1166: 1 = (1^√66) 2355: 2 = (3-(5/5)) 4558: 4 = √((5!/5)-8) \n", + "0138: 0 = (3-√√81) 1167: 1 = (1^√67) 2356: 2 = (3+(5-6)) 4559: 4 = ((5/5)+√9) \n", + "0139: 0 = (1*(3-√9)) 1168: 1 = (1^√68) 2357: 2 = ((3+7)/5) 4566: 4 = (5-(6/6)) \n", + "0144: 0 = (1*(4-4)) 1169: 1 = (1^√69) 2358: 2 = (3!/(8-5)) 4567: 4 = (5+(6-7)) \n", + "0145: 0 = (1+(4-5)) 1177: 1 = (1^√77) 2359: 2 = (5-(9/3)) 4568: 4 = (√(6!/5)-8) \n", + "0146: 0 = (√16-4) 1178: 1 = (1^√78) 2366: 2 = (3-(6/6)) 4569: 4 = (6-(5-√9)) \n", + "0147: 0! = (1^√47) 1179: 1 = (1^√79) 2367: 2 = (3+(6-7)) 4577: 4 = (5-(7/7)) \n", + "0148: 0! = (1^√48) 1188: 1 = (1^√88) 2368: 2 = (8-√36) 4578: 4 = (5+(7-8)) \n", + "0149: 0 = (1-(4-√9)) 1189: 1 = (1^√89) 2369: 2 = √(36/9) 4579: 4 = ((5+7)/√9) \n", + "0155: 0 = (1*(5-5)) 1199: 1 = (1^√99) 2377: 2 = (3-(7/7)) 4588: 4 = (5-(8/8)) \n", + "0156: 0 = (1+(5-6)) 1222: 1 = (2^(2-2)) 2378: 2 = (3+(7-8)) 4589: 4 = (5+(8-9)) \n", + "0157: 0! = (1^√57) 1223: 1 = (2+(2-3)) 2379: 2 = ((3*√9)-7) 4599: 4 = (5-(9/9)) \n", + "0158: 0! = (1^√58) 1224: 1 = (2*(2/4)) 2388: 2 = (3-(8/8)) 4666: √4 = ((6+6)/6) \n", + "0159: 0 = (1+(5-√9!)) 1225: 1 = ((2/2)^5) 2389: 2 = (3+(8-9)) 4667: 6 = (4+(6-7))! \n", + "0166: 0 = (1*(6-6)) 1226: 1 = ((2/2)^6) 2399: 2 = (3-(9/9)) 4668: 4 = (6+(6-8)) \n", + "0167: 0 = (1+(6-7)) 1227: 1 = ((2/2)^7) 2444: 2 = ((4+4)/4) 4669: 4 = √(96/6) \n", + "0168: 0 = (6-√√81!) 1228: 1 = ((2/2)^8) 2445: 2 = (√4*(5-4)) 4677: 6 = √√(4+77)! \n", + "0169: 0 = (1*(6-√9!)) 1229: 1 = ((2/2)^9) 2446: 2 = (√64/4) 4678: √4 = ((6+8)/7) \n", + "0177: 0 = (1*(7-7)) 1233: 1 = (2^(3-3)) 2447: 2 = ((7-4)!-4) 4679: 4 = (6+(7-9)) \n", + "0178: 0 = (1+(7-8)) 1234: 1 = (4!-23) 2448: 2 = (48/4!) 4688: 4 = (8/(8-6)) \n", + "0179: 0 = (1-(7-√9!)) 1235: 1 = (3!-√25) 2449: 2 = (√(4*9)-4) 4689: 4 = (8^(6/9)) \n", + "0188: 0 = (1*(8-8)) 1236: 1 = (2*(3/6)) 2455: 2 = (√4-(5-5)) 4699: 4 = √(96/√9!) \n", + "0189: 0 = (√81-9) 1237: 1 = ((2^3)-7) 2456: 2 = ((4+6)/5) 4777: √4 = ((7+7)/7) \n", + "0199: 0 = (1*(9-9)) 1238: 1 = ((2-3)^8) 2457: 2 = (4+(5-7)) 4778: 4 = (8!/(7!+7!)) \n", + "0222: 0 = (2*(2-2)) 1239: 1 = ((3-2)^9) 2458: 2 = ((√4*5)-8) 4779: 4 = ((7/7)+√9) \n", + "0223: 0 = ((2-2)*3) 1244: 1 = (24/4!) 2459: 2 = (√49-5) 4788: 4 = √((8!/7!)+8) \n", + "0224: 0 = (2+(2-4)) 1245: 1 = (25-4!) 2466: 2 = (√64-6) 4789: 4 = (8/(9-7)) \n", + "0225: 0 = ((2-2)*5) 1246: 1 = ((2+4)/6) 2467: 2 = (6/(7-4)) 4799: 4 = (7-(9/√9)) \n", + "0226: 0 = ((2-2)*6) 1247: 1 = ((2*4)-7) 2468: 2 = (4+(6-8)) 4888: 4 = (8-√(8+8)) \n", + "0227: 0 = ((2-2)*7) 1248: 1 = (2*(4/8)) 2469: 2 = √(96/4!) 4889: 4 = ((8/8)+√9) \n", + "0228: 0 = ((2-2)*8) 1249: 1 = (9-(2*4)) 2477: 2 = (√4-(7-7)) 4899: 4 = (9-(8-√9)) \n", + "0229: 0 = ((2-2)*9) 1255: 1 = (√25/5) 2478: 2 = (√4*(8-7)) 4999: 4 = (√9+(9/9)) \n", + "0233: 0 = (2*(3-3)) 1256: 1 = (6-√25) 2479: 2 = (4+(7-9)) 5555: 5 = (5-(5-5)) \n", + "0234: 0 = (2-(3!-4)) 1257: 1 = ((2+5)/7) 2488: 2 = (8/(8-4)) 5556: 5 = (5*(6-5)) \n", + "0235: 0 = (2+(3-5)) 1258: 1 = (5-(8/2)) 2489: 2 = √√(48/√9) 5557: 5 = (√5^(7-5)) \n", + "0236: 0 = ((2*3)-6) 1259: 1 = ((2*5)-9) 2499: 2 = (9-√49) 5558: None \n", + "0237: 0 = (2-√(7-3)) 1266: 1 = (2^(6-6)) 2555: 2 = ((5+5)/5) 5559: 5 = √(5!-95) \n", + "0238: 0 = ((2^3)-8) 1267: 1 = (2+(6-7)) 2556: 2 = √(5+(5-6)) 5566: 5 = (5-(6-6)) \n", + "0239: 0 = ((3^2)-9) 1268: 1 = ((2+6)/8) 2557: 2 = (7-√(5*5)) 5567: 5 = (5*(7-6)) \n", + "0244: 0 = (24-4!) 1269: 1 = (9-(2+6)) 2558: 2 = (5+(5-8)) 5568: 5 = (√5^(8-6)) \n", + "0245: 0 = ((2-√4)*5) 1277: 1 = (2^(7-7)) 2559: 2 = (√9-(5/5)) 5569: 5 = (5-(6-√9!)) \n", + "0246: 0 = (2+(4-6)) 1278: 1 = (2+(7-8)) 2566: 2 = √(5-(6/6)) 5577: 5 = (5-(7-7)) \n", + "0247: 0 = ((2-√4)*7) 1279: 1 = ((2+7)/9) 2567: 2 = ((5+7)/6) 5578: 5 = (5*(8-7)) \n", + "0248: 0 = ((2*4)-8) 1288: 1 = (2^(8-8)) 2568: 2 = (6/(8-5)) 5579: 5 = √(75/√9) \n", + "0249: 0 = ((2-√4)*9) 1289: 1 = (2+(8-9)) 2569: 2 = (5+(6-9)) 5588: 5 = (5-(8-8)) \n", + "0255: 0 = (√25-5) 1299: 1 = (2^(9-9)) 2577: 2 = (√(7*7)-5) 5589: 5 = (5*(9-8)) \n", + "0256: 0 = ((5-2)!-6) 1333: 1 = (3^(3-3)) 2578: 2 = √(5+(7-8)) 5599: 5 = (5-(9-9)) \n", + "0257: 0 = (2+(5-7)) 1334: 1 = ((3/3)^4) 2579: 2 = ((5+9)/7) 5666: 5 = (6-(6/6)) \n", + "0258: 0! = (5-(8/2)) 1335: 1 = (3+(3-5)) 2588: 2 = (8-(8-5)!) 5667: 5 = (6+(6-7)) \n", + "0259: 0 = (2-(5-√9)) 1336: 1 = (3!/√36) 2589: 2 = (8/(9-5)) 5668: 6 = (5+(6-8))! \n", + "0266: 0 = (2*(6-6)) 1337: 1 = ((3/3)^7) 2599: 2 = (5-(9/√9)) 5669: 5 = (6-(6/√9!)) \n", + "0267: 0 = (√(2+7)!-6) 1338: 1 = ((3*3)-8) 2666: 2 = ((6+6)/6) 5677: 5 = (6-(7/7)) \n", + "0268: 0 = (2+(6-8)) 1339: 1 = (3*(3/9)) 2667: 6 = (2-(6-7))! 5678: 5 = (6+(7-8)) \n", + "0269: 0 = (2-(6/√9)) 1344: 1 = (3^(4-4)) 2668: 2 = (8-√(6*6)) 5679: 5 = (7-(6/√9)) \n", + "0277: 0 = (2*(7-7)) 1345: 1 = ((4-3)^5) 2669: 2 = √√(96/6) 5688: 5 = (6-(8/8)) \n", + "0278: 0! = (2+(7-8)) 1346: 1 = (3+(4-6)) 2677: 6 = (2+(7/7))! 5689: 5 = (6+(8-9)) \n", + "0279: 0 = (2+(7-9)) 1347: 1 = ((3+4)/7) 2678: 2 = ((6+8)/7) 5699: 5 = (6-(9/9)) \n", + "0288: 0 = (2*(8-8)) 1348: 1 = ((3-4)^8) 2679: 2 = (6-(7-√9)) 5777: 7 = (√7^(7-5)) \n", + "0289: 0 = ((2^√9)-8) 1349: 1 = (√49-3!) 2688: 2 = (6-√(8+8)) 5778: 7 = √(57-8) \n", + "0299: 0 = (2*(9-9)) 1355: 1 = (3^(5-5)) 2689: 2 = (√8^(6/9)) 5779: 5 = (7+(7-9)) \n", + "0333: 0 = (3*(3-3)) 1356: 1 = (√36-5) 2699: 2 = (6/(9/√9)) 5788: 5 = (7-√√(8+8)) \n", + "0334: 0 = ((3-3)*4) 1357: 1 = (3+(5-7)) 2777: 2 = ((7+7)/7) 5789: 5 = ((7+8)/√9) \n", + "0335: 0 = ((3-3)*5) 1358: 1 = ((3+5)/8) 2778: 2 = √(8!/(7!+7!)) 5799: 5 = (9-(7-√9)) \n", + "0336: 0 = (3!-√36) 1359: 1 = (9-(3+5)) 2779: 2 = (9-√(7*7)) 5888: 8 = √((√8^5)/√8) \n", + "0337: 0 = ((3-3)*7) 1366: 1 = (√36/6) 2788: 2 = √√((8!/7!)+8) 5889: 5 = (9-√(8+8)) \n", + "0338: 0 = ((3-3)*8) 1367: 1 = (7-√36) 2789: 2 = ((7+9)/8) 5899: 5 = (8-(9/√9)) \n", + "0339: 0 = ((3-3)*9) 1368: 1 = (3+(6-8)) 2799: 2 = (√(9*9)-7) 5999: 5 = (√9!-(9/9)) \n", + "0344: 0 = (3*(4-4)) 1369: 1 = ((3+6)/9) 2888: 2 = ((8+8)/8) 6666: 6 = (6-(6-6)) \n", + "0345: 0 = (3+(√4-5)) 1377: 1 = (3^(7-7)) 2889: 2 = (√9-(8/8)) 6667: 6 = (6*(7-6)) \n", + "0346: 0 = ((3*√4)-6) 1378: 1 = ((8-7)^3) 2899: 2 = (8-(9-√9)) 6668: 6 = (√6^(8-6)) \n", + "0347: 0 = (3+(4-7)) 1379: 1 = (3+(7-9)) 2999: 2 = ((9+9)/9) 6669: 6 = (6+(6-9))! \n", + "0348: 0 = (3-(4!/8)) 1388: 1 = (3^(8-8)) 3333: 3 = (3-(3-3)) 6677: 6 = (6-(7-7)) \n", + "0349: 0 = ((3^√4)-9) 1389: 1 = ((9-8)^3) 3334: 3 = √(33-4!) 6678: 6 = (6*(8-7)) \n", + "0355: 0 = (3*(5-5)) 1399: 1 = (3^(9-9)) 3335: 3 = (3*(3!-5)) 6679: 6 = (√6^(9-7)) \n", + "0356: 0 = ((3!-6)*5) 1444: 1 = (4^(4-4)) 3336: 3 = (√36-3) 6688: 6 = (6-(8-8)) \n", + "0357: 0! = (3+(5-7)) 1445: 1 = ((4/4)^5) 3337: 3 = (3*(7-3!)) 6689: 6 = (6*(9-8)) \n", + "0358: 0 = (3+(5-8)) 1446: 1 = ((4/4)^6) 3338: 3 = √((3/3)+8) 6699: 6 = (6-(9-9)) \n", + "0359: 0 = ((3-√9)*5) 1447: 1 = (4+(4-7)) 3339: 3 = ((3^3)/9) 6777: 6 = (7-(7/7)) \n", + "0366: 0 = (√36-6) 1448: 1 = ((4+4)/8) 3344: 3 = (3-(4-4)) 6778: 6 = (7+(7-8)) \n", + "0367: 0 = ((3!-6)*7) 1449: 1 = ((4/4)^9) 3345: 3 = √(54/3!) 6779: 6 = (7-(7-√9!)) \n", + "0368: 0 = ((3!-6)*8) 1455: 1 = (4^(5-5)) 3346: 3 = √(36/4) 6788: 6 = (7-(8/8)) \n", + "0369: 0 = (3+(6-9)) 1456: 1 = ((4-5)^6) 3347: 3 = (3!+(4-7)) 6789: 6 = (7+(8-9)) \n", + "0377: 0 = (3*(7-7)) 1457: 1 = ((5-4)^7) 3348: 3 = √√(84-3) 6799: 6 = (7-(9/9)) \n", + "0378: 0! = ((8-7)^3) 1458: 1 = (4+(5-8)) 3349: 3 = ((3*4)-9) 6888: 6 = (8-√√(8+8)) \n", + "0379: 0 = ((3-√9)*7) 1459: 1 = ((4+5)/9) 3355: 3 = (3-(5-5)) 6889: 6 = √√(89-8)! \n", + "0388: 0 = (3*(8-8)) 1466: 1 = (4^(6-6)) 3356: 3 = (3*(6-5)) 6899: 6 = ((9-8)*√9!) \n", + "0389: 0 = ((3-√9)*8) 1467: 1 = (√64-7) 3357: 3 = √√(3!+75) 6999: 6 = (9-(9/√9)) \n", + "0399: 0 = (3*(9-9)) 1468: 1 = (√64/8) 3358: 3 = (3!+(5-8)) 7777: 7 = (7-(7-7)) \n", + "0444: 0 = (4*(4-4)) 1469: 1 = (√49-6) 3359: 3 = √√(5!-39) 7778: 7 = (7*(8-7)) \n", + "0445: 0 = ((4-4)*5) 1477: 1 = (4^(7-7)) 3366: 3 = (3-(6-6)) 7779: 7 = (√7^(9-7)) \n", + "0446: 0 = ((4-4)*6) 1478: 1 = ((7-8)^4) 3367: 3 = √(63/7) 7788: 7 = (7-(8-8)) \n", + "0447: 0 = ((4-4)*7) 1479: 1 = (√49/7) 3368: 3 = (√3^(8-6)) 7789: 7 = (7*(9-8)) \n", + "0448: 0 = (4+(4-8)) 1488: 1 = (4^(8-8)) 3369: 3 = (9-√36) 7799: 7 = (7-(9-9)) \n", + "0449: 0 = ((4-4)*9) 1489: 1 = (8-√49) 3377: 3 = (3-(7-7)) 7888: 7 = (8-(8/8)) \n", + "0455: 0 = (4*(5-5)) 1499: 1 = (4^(9-9)) 3378: 3 = √√(3+78) 7889: 7 = (8+(8-9)) \n", + "0456: 0 = (√(4+5)!-6) 1555: 1 = (5^(5-5)) 3379: 3 = (√3^(9-7)) 7899: 7 = (8-(9/9)) \n", + "0457: 0 = (√4+(5-7)) 1556: 1 = ((5/5)^6) 3388: 3 = (3-(8-8)) 7999: 7 = (√9!+(9/9)) \n", + "0458: 0! = (4+(5-8)) 1557: 1 = ((5/5)^7) 3389: 3 = (3*(9-8)) 8888: 8 = (8-(8-8)) \n", + "0459: 0 = (4+(5-9)) 1558: 1 = ((5/5)^8) 3399: 3 = (3-(9-9)) 8889: 8 = (8*(9-8)) \n", + "0466: 0 = (4*(6-6)) 1559: 1 = (5+(5-9)) 3444: 3 = (4-(4/4)) 8899: 8 = (8-(9-9)) \n", + "0467: 0 = (6-(7-4)!) 1566: 1 = (5^(6-6)) 3445: 3 = (4+(4-5)) 8999: 8 = (9-(9/9)) \n", + "0468: 0 = (√64-8) 1567: 1 = ((6-5)^7) 3446: 3 = (4!/√64) 9999: 9 = (9-(9-9)) \n", + "0469: 0 = (√(4*9)-6) 1568: 1 = ((5-6)^8) 3447: 3 = (7-√(4*4)) \n" + ] + } + ], + "source": [ + "def show_plate_equations(digits, ops) -> None:\n", + " \"\"\"Show all equations from license plates.\"\"\"\n", + " plates = list(combinations_with_replacement(range(10), 4))\n", + " def solve(plate): return find_equation(plate, ops=ops)\n", + " table = [f\"{cat(plate)}: {unbracket(solve(plate)) if solve(plate) else None} \" \n", + " for plate in plates]\n", + " S = sum('None' not in entry for entry in table)\n", + " P = len(plates)\n", + " print(f'{S} out of {P} distinct license plates ({S/P:.1%}) can be solved:\\n')\n", + " show_columns(table)\n", + "\n", + "def find_equation(numbers, ops):\n", + " \"\"\"Find an equation involving these numbers and operators.\"\"\"\n", + " for i in range(1, len(numbers)): # Number of digits on the left hand side\n", + " for nums in permutations(numbers):\n", + " Ltable = expressions(nums[:i], ops, permute=True)\n", + " Rtable = expressions(nums[i:], ops, permute=True)\n", + " for n in Ltable:\n", + " if n in Rtable:\n", + " return f'{Ltable[n]} = {Rtable[n]}'\n", + " return None\n", + "\n", + "show_plate_equations(digits=4, ops='+-*/^_√!,')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Wow! We got all the plates except one, 5558. Let's try that one again, allowing a decimal point:" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'5 = (√5^√(5*.8))'" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "find_equation((5, 5, 5, 8), OPS)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It was surprising to me that all the 4-digit plates have an equation, and it was also surprising that we only needed to go up to one digit on the left-hand side (possibly with a unary operator). But maybe it shouldn't have been surprising. I found \"6/3 = 4/2\" for \"2346\", but tht's really the same as \"6 = 3*(4/2)\"." + ] + }, { "cell_type": "markdown", "metadata": { @@ -1653,7 +1955,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 41, "metadata": { "id": "CoKnbYBxKEBB", "outputId": "dd72b838-7b22-4080-9b29-739585881ce7" @@ -1690,14 +1992,14 @@ "source": [ "# Even More Fours: The Power of Floor and Ceiling\n", "\n", - "With the standard set of `OPS`, we got all the integers up to 72 with four 4s. If we add the floor and ceiling operations, we get a big jump: suddenly, all the results of a division or a square root that didn't form an integer can now be coerced into integers. Instead of getting the integers only up to 72, we now get all the way up to **1644**, although it takes a full minute to get there. \n", + "With the standard set of `OPS`, we got all the integers up to 72 with four 4s. If we add the floor and ceiling operations, we get a big jump: suddenly, all the results of a division or a square root that didn't form an integer can now be coerced into integers. Instead of getting the integers only up to 72, we now get all the way up to **1644**.\n", "\n", "I'll just show the first 300, to save space: " ] }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 42, "metadata": { "id": "jbJsFkNZKEBC", "outputId": "fea9ae24-2e75-4a11-8098-162790f91625" @@ -1707,7 +2009,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Can make 0 to 1644 with (4, 4, 4, 4), ops=\"+-*/^_√!.,⌊⌈\", permute=False. [1,205,099 table entries]\n", + "Can make 0 to 1644 with (4, 4, 4, 4), ops=\"+-*/^_√!.,⌊⌈\", permute=False. [1,205,103 table entries]\n", "\n", " 0: 44-44 60: 44+(4*4) 120: ⌈4.444⌉! 180: 4+(4*44) 240: √4*⌈4.44⌉! \n", " 1: 44/44 61: ⌈(.44^-⌈4.4⌉)⌉ 121: (44/4)^√4 181: ⌊(4*(√√4+44))⌋ 241: (.4+(4*4!))/.4 \n", @@ -1716,13 +2018,13 @@ " 4: ⌊4.444⌋ 64: 4!-(4-44) 124: 4+⌈4.44⌉! 184: 4*(√4+44) 244: 4+(4/(.4/4!)) \n", " 5: ⌈4.444⌉ 65: (4+(4^4))/4 125: ⌈(44*√(4+4))⌉ 185: ⌈((44-4)^√√4)⌉ 245: (√4+(4*4!))/.4 \n", " 6: ⌊√44.44⌋ 66: ⌊(44/√.44)⌋ 126: ⌊√44⌋+⌈4.4⌉! 186: ⌈((4+4!)*√44)⌉ 246: (4^4)-(4/.4) \n", - " 7: ⌈√44.44⌉ 67: ⌈(44/√.44)⌉ 127: ⌈√44⌉+⌈4.4⌉! 187: ⌊(4.4^4)⌋/√4 247: ⌊(4^(4-(.4^4)))⌋ \n", + " 7: ⌈√44.44⌉ 67: ⌈(44/√.44)⌉ 127: ⌈4.4⌉!+⌈√44⌉ 187: ⌊(4.4^4)⌋/√4 247: ⌊(4^(4-(.4^4)))⌋ \n", " 8: 4+⌊4.44⌋ 68: 4!+⌊44.4⌋ 128: √4^⌈√44.4⌉ 188: (4!*(4+4))-4 248: (4^4)-(4+4) \n", " 9: 4+⌈4.44⌉ 69: 4!+⌈44.4⌉ 129: 4!+⌊(4!*4.4)⌋ 189: ⌊(⌈4.44⌉!/√.4)⌋ 249: (4^4)-⌈√44⌉ \n", - " 10: 44/4.4 70: 4!+(√4+44) 130: (4+(4^4))/√4 190: (4!*(4+4))-√4 250: (4^4)-⌊√44⌋ \n", - " 11: 44/⌊4.4⌋ 71: ⌈(44.4/√.4)⌉ 131: ⌈(4!*(4!/4.4))⌉ 191: ⌊(√4!*44)⌋-4! 251: (4^4)-⌈4.4⌉ \n", + " 10: 44/4.4 70: √4+(4!+44) 130: (4+(4^4))/√4 190: (4!*(4+4))-√4 250: (4^4)-⌊√44⌋ \n", + " 11: 44/⌊4.4⌋ 71: ⌈(44.4/√.4)⌉ 131: ⌈(√4^(.4+√44))⌉ 191: ⌊(√4!*44)⌋-4! 251: (4^4)-⌈4.4⌉ \n", " 12: (4+44)/4 72: 4+(4!+44) 132: 44*(4-⌈.4⌉) 192: 4*(4+44) 252: (4^4)-⌊4.4⌋ \n", - " 13: 4!-(44/4) 73: 4+⌊(44/√.4)⌋ 133: ⌈((4!-4)*√44)⌉ 193: ⌊(44*4.4)⌋ 253: ⌊(4!*(4!*.44))⌋ \n", + " 13: √4+(44/4) 73: 4+⌊(44/√.4)⌋ 133: ⌈((4!-4)*√44)⌉ 193: ⌊(44*4.4)⌋ 253: ⌊(4!*(4!*.44))⌋ \n", " 14: ⌈(√44+√44)⌉ 74: 4+⌈(44/√.4)⌉ 134: 4!+(44/.4) 194: ⌈(44*4.4)⌉ 254: √4-(4-(4^4)) \n", " 15: 4+(44/4) 75: ⌊((4+44)/√.4)⌋ 135: ⌊(4!/.44)⌋/.4 195: ⌊(√4!*(44-4))⌋ 255: (4^4)-(4/4) \n", " 16: 4*⌊4.44⌋ 76: ⌈4.4⌉!-44 136: √4*(4!+44) 196: 4+(4!*(4+4)) 256: 4^⌊4.44⌋ \n", @@ -1732,9 +2034,9 @@ " 20: 4*⌈4.44⌉ 80: 4*(44-4!) 140: 44+(4*4!) 200: 4!+(4*44) 260: 4+(4^⌊4.4⌋) \n", " 21: ⌈44.4⌉-4! 81: (4-(4/4))^4 141: ⌈((.4^-4.4)/.4)⌉ 201: ⌊(4!*(4+4.4))⌋ 261: (4^4)+⌈4.4⌉ \n", " 22: √4/(4/44) 82: ⌊((4/.44)^√4)⌋ 142: (4!*⌊√44⌋)-√4 202: ⌈(4!*(4+4.4))⌉ 262: (4^4)+⌊√44⌋ \n", - " 23: 4!-⌈.444⌉ 83: 44+⌊(.4^-4)⌋ 143: ((4!*4!)-4)/4 203: ⌊(44*(4+√.4))⌋ 263: (4^4)+⌈√44⌉ \n", + " 23: 4!-⌈.444⌉ 83: 44+⌊(.4^-4)⌋ 143: ((4!^√4)-4)/4 203: ⌊(44*(4+√.4))⌋ 263: (4^4)+⌈√44⌉ \n", " 24: ⌊4.444⌋! 84: (√4*44)-4 144: 4!*⌊√44.4⌋ 204: ⌈(44*(4+√.4))⌉ 264: 44*⌊√44⌋ \n", - " 25: 4!+⌈.444⌉ 85: ⌈(4*(√4^4.4))⌉ 145: (4+(4!*4!))/4 205: ⌊(√4!*(44-√4))⌋ 265: ⌈(4!*4.4)⌉/.4 \n", + " 25: 4!+⌈.444⌉ 85: ⌈(4*(√4^4.4))⌉ 145: (4+(4!^√4))/4 205: ⌊(√4!*(44-√4))⌋ 265: ⌈(4!*4.4)⌉/.4 \n", " 26: 4+(44/√4) 86: (√4*44)-√4 146: √4+(4!*⌊√44⌋) 206: ⌊(44^√√4)⌋-4 266: (4^4)+(4/.4) \n", " 27: ⌈(4*√44.4)⌉ 87: (√4*44)-⌈.4⌉ 147: ⌊(44^(√4^.4))⌋ 207: ⌈(44^√√4)⌉-4 267: ⌊(4!*(√4!/.44))⌋ \n", " 28: 44-(4*4) 88: 44+44 148: 4+(4!*⌊√44⌋) 208: ⌈(4.4^(4-.4))⌉ 268: ⌊(4!^(4*.44))⌋ \n", @@ -1751,7 +2053,7 @@ " 39: 44-⌈4.4⌉ 99: ⌊(4^√(44/4))⌋ 159: ⌊(4!*√44.4)⌋ 219: 4+⌊(√4!*44)⌋ 279: ⌈(4/(√.4/44))⌉ \n", " 40: 44-⌊4.4⌋ 100: 44/.44 160: 4*(44-4) 220: 44*⌈4.4⌉ 280: ⌊(√.4*444)⌋ \n", " 41: ⌈44.4⌉-4 101: ⌊(√4^√44.4)⌋ 161: ⌈((4-.44)^4)⌉ 221: ⌈(√4!*⌈44.4⌉)⌉ 281: ⌈(√.4*444)⌉ \n", - " 42: √4-(4-44) 102: ⌈(√4^√44.4)⌉ 162: √4+⌈(4!*√44)⌉ 222: 444/√4 282: 4!+(√4+(4^4)) \n", + " 42: √4-(4-44) 102: ⌈(√4^√44.4)⌉ 162: √4+⌈(4!*√44)⌉ 222: 444/√4 282: √4+(4!+(4^4)) \n", " 43: 44-(4/4) 103: 4+⌊(√4^√44)⌋ 163: 4+⌊(4!*√44)⌋ 223: ⌈(4^4.4)⌉/√4 283: ⌈((4+(.4/4))^4)⌉ \n", " 44: ⌊44.44⌋ 104: 44+(4!/.4) 164: 44+⌈4.4⌉! 224: (4+4)*(4+4!) 284: 4+(4!+(4^4)) \n", " 45: ⌈44.44⌉ 105: (44-√4)/.4 165: ⌈(√4!+(4!*√44))⌉ 225: ⌊(4/(.4^4.4))⌋ 285: ⌊(⌈√44⌉!^√.44)⌋ \n", @@ -1759,23 +2061,21 @@ " 47: √4+⌈44.4⌉ 107: ⌈(4!*4.44)⌉ 167: ⌈(4!*√(4+44))⌉ 227: 4+⌈((4^√4!)/4)⌉ 287: ⌈(√4!^(4-.44))⌉ \n", " 48: 4+⌊44.4⌋ 108: (44/.4)-√4 168: 4*(44-√4) 228: (4^4)-(4+4!) 288: 4!*(4+(4+4)) \n", " 49: 4+⌈44.4⌉ 109: (44-.4)/.4 169: ⌊√(4*44)⌋^√4 229: ⌈(4^(4-(√4/4!)))⌉ 289: ⌊(4*4.4)⌋^√4 \n", - " 50: 44+⌊√44⌋ 110: ⌊44.4⌋/.4 170: (4!+44)/.4 230: (4^4)-(4!+√4) 290: (⌈4.4⌉!-4)/.4 \n", + " 50: 44+⌊√44⌋ 110: ⌊44.4⌋/.4 170: (4!+44)/.4 230: (4^4)-(√4+4!) 290: (⌈4.4⌉!-4)/.4 \n", " 51: 44+⌈√44⌉ 111: 444/4 171: ⌈(4*(44-√√4))⌉ 231: ⌊(.44^-√44)⌋ 291: ⌊(44*√44)⌋ \n", - " 52: 4+(4+44) 112: 4!+(√4*44) 172: (4*44)-4 232: ⌈(.44^-√44)⌉ 292: ⌈(44*√44)⌉ \n", + " 52: 4+(4+44) 112: √4+(44/.4) 172: (4*44)-4 232: ⌈(.44^-√44)⌉ 292: ⌈(44*√44)⌉ \n", " 53: ⌊(4*√(4*44))⌋ 113: ⌈(.44*(4^4))⌉ 173: ⌊(4*(44-√.4))⌋ 233: ⌈(44*√(4+4!))⌉ 293: (4^4)+⌊(4!/√.4)⌋ \n", - " 54: 44+(4/.4) 114: 4+(44/.4) 174: (4*44)-√4 234: 4!+⌊(44^√√4)⌋ 294: ⌊(4^(4+(.4/4)))⌋ \n", + " 54: 44+(4/.4) 114: 4+(44/.4) 174: (4*44)-√4 234: √4-(4!-(4^4)) 294: ⌊(4^(4+(.4/4)))⌋ \n", " 55: ⌈(4!/.444)⌉ 115: (√4+44)/.4 175: (4*44)-⌈.4⌉ 235: ⌊(√4!*(4+44))⌋ 295: (⌈4.4⌉!-√4)/.4 \n", " 56: 44+(4!/√4) 116: ⌈4.44⌉!-4 176: 4*⌊44.4⌋ 236: 4-(4!-(4^4)) 296: (⌈4.4⌉!/.4)-4 \n", " 57: ⌈(√√4*(44-4))⌉ 117: ⌈(44*√⌈√44⌉)⌉ 177: ⌊(4*44.4)⌋ 237: ⌊(√.4*(4.4^4))⌋ 297: ⌈(√√4*⌊(44^√√4)⌋)⌉\n", " 58: ⌊(.4^-4.44)⌋ 118: ⌈4.44⌉!-√4 178: ⌈(4*44.4)⌉ 238: ⌊((4+44)^√√4)⌋ 298: (⌈4.4⌉!/.4)-√4 \n", - " 59: ⌈(.4^-4.44)⌉ 119: ⌈4.4⌉!-(4/4) 179: ⌈(4*(√.4+44))⌉ 239: ⌈((4+44)^√√4)⌉ 299: (⌈4.4⌉!-.4)/.4 \n", - "CPU times: user 14.6 s, sys: 70.4 ms, total: 14.7 s\n", - "Wall time: 14.7 s\n" + " 59: ⌈(.4^-4.44)⌉ 119: ⌈4.4⌉!-(4/4) 179: ⌈(4*(√.4+44))⌉ 239: ⌈((4+44)^√√4)⌉ 299: (⌈4.4⌉!-.4)/.4 \n" ] } ], "source": [ - "%time show((4, 4, 4, 4), limit=300, ops=OPS + \"⌊⌈\")" + "show((4, 4, 4, 4), limit=300, ops=OPS + \"⌊⌈\")" ] }, { @@ -1794,7 +2094,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 43, "metadata": { "id": "4MHPG5L8KEBC", "outputId": "63bffec7-8b22-4bb2-cd44-6fd03f124ccf" @@ -1804,7 +2104,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Can make 0 to 171 with (5, 5, 5, 5, 5), ops=\"+-*/^_√!.,\", permute=False. [14,827,355 table entries]\n", + "Can make 0 to 171 with (5, 5, 5, 5, 5), ops=\"+-*/^_√!.,\", permute=False. [14,827,335 table entries]\n", "\n", " 0: 5*(55-55) 43: 55-(5!/(5+5)) 86: (55/.5)-(5!/5) 129: (5!-55.5)/.5 \n", " 1: 5^(55-55) 44: 55-(55/5) 87: (555-5!)/5 130: 5!+(55/5.5) \n", @@ -1849,8 +2149,8 @@ " 40: 55-(5+(5+5)) 83: (.5*5!)-((5-5!)/5) 126: 5!+((55/5)-5) 169: 5!+((5*5)+(5!/5)) \n", " 41: 5!-(55+(5!/5)) 84: 5+(55+(5!/5)) 127: (5!/(5/5.5))-5 170: 5!-(√(5*5)-55) \n", " 42: (5+5.5)/(.5*.5) 85: 5+(55+(5*5)) 128: 5!+(5.5+(5*.5)) 171: (5.5/(.5^5))-5 \n", - "CPU times: user 2min 13s, sys: 1.09 s, total: 2min 14s\n", - "Wall time: 2min 14s\n" + "CPU times: user 1min 14s, sys: 683 ms, total: 1min 15s\n", + "Wall time: 1min 15s\n" ] } ], @@ -1864,13 +2164,12 @@ "source": [ "# Integer Complexity\n", "\n", - "In number theory, the **complexity of an integer** is the number of \"1\"s needed to make the integer. Different versions of the concept use different sets of operators, but in the [Wikipedia article on Integer complexity](https://en.wikipedia.org/wiki/Integer_complexity), they allow only addition and multiplication. For example with one \"1\" we can only make 1, but with two \"1\"s we can make 1 and 2, and with seven \"1\"s we can make all the integers from 1 to 12 except 11:\n", - "\n" + "In number theory, the **complexity of an integer** is the number of \"1\"s needed to make the integer. Different versions of the concept use different sets of operators, but in the [Wikipedia article on Integer complexity](https://en.wikipedia.org/wiki/Integer_complexity), they allow only addition and multiplication. For example with one \"1\" we can only make 1, but with two \"1\"s we can make 1 and 2:" ] }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -1879,7 +2178,7 @@ "{1: '(1*1)', 2: '(1+1)'}" ] }, - "execution_count": 40, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1888,9 +2187,16 @@ "expressions((1, 1), '+*')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and with seven \"1\"s we can make all the integers from 1 to 12 except 11:" + ] + }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 45, "metadata": {}, "outputs": [ { @@ -1909,7 +2215,7 @@ " 12: '((1+1)*((1+1)*(1+(1+1))))'}" ] }, - "execution_count": 41, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1920,7 +2226,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -1937,38 +2243,69 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - " 1: 1 | 21: 9 | 41: 12 | 61: 13 | 81: 12 | 101: 15 | 121: 15 | 141: 16 | 161: 16 | 186: 16 | 225: 16 |\n", - " 2: 2 | 22: 10 | 42: 11 | 62: 13 | 82: 13 | 102: 14 | 122: 15 | 142: 16 | 162: 14 | 189: 15 | 228: 16 |\n", - " 3: 3 | 23: 11 | 43: 12 | 63: 12 | 83: 14 | 103: 15 | 123: 15 | 143: 16 | 163: 15 | 190: 16 | 234: 16 |\n", - " 4: 4 | 24: 9 | 44: 12 | 64: 12 | 84: 13 | 104: 14 | 124: 15 | 144: 14 | 164: 15 | 192: 15 | 240: 16 |\n", - " 5: 5 | 25: 10 | 45: 11 | 65: 13 | 85: 14 | 105: 14 | 125: 15 | 145: 15 | 165: 15 | 193: 16 | 243: 15 |\n", - " 6: 5 | 26: 10 | 46: 12 | 66: 13 | 86: 14 | 106: 15 | 126: 14 | 146: 15 | 166: 16 | 194: 16 | 244: 16 |\n", - " 7: 6 | 27: 9 | 47: 13 | 67: 14 | 87: 14 | 107: 16 | 127: 15 | 147: 15 | 168: 15 | 195: 16 | 246: 16 |\n", - " 8: 6 | 28: 10 | 48: 11 | 68: 13 | 88: 14 | 108: 13 | 128: 14 | 148: 15 | 169: 16 | 196: 16 | 252: 16 |\n", - " 9: 6 | 29: 11 | 49: 12 | 69: 14 | 89: 15 | 109: 14 | 129: 15 | 149: 16 | 170: 16 | 198: 16 | 256: 16 |\n", - " 10: 7 | 30: 10 | 50: 12 | 70: 13 | 90: 13 | 110: 14 | 130: 15 | 150: 15 | 171: 15 | 200: 16 | 270: 16 |\n", - " 11: 8 | 31: 11 | 51: 12 | 71: 14 | 91: 14 | 111: 14 | 131: 16 | 151: 16 | 172: 16 | 204: 16 | 288: 16 |\n", - " 12: 7 | 32: 10 | 52: 12 | 72: 12 | 92: 14 | 112: 14 | 132: 15 | 152: 15 | 174: 16 | 208: 16 | 324: 16 |\n", - " 13: 8 | 33: 11 | 53: 13 | 73: 13 | 93: 14 | 113: 15 | 133: 15 | 153: 15 | 175: 16 | 210: 16 |\n", - " 14: 8 | 34: 11 | 54: 11 | 74: 13 | 94: 15 | 114: 14 | 134: 16 | 154: 16 | 176: 16 | 216: 15 |\n", - " 15: 8 | 35: 11 | 55: 12 | 75: 13 | 95: 14 | 115: 15 | 135: 14 | 155: 16 | 180: 15 | 217: 16 |\n", - " 16: 8 | 36: 10 | 56: 12 | 76: 13 | 96: 13 | 116: 15 | 136: 15 | 156: 15 | 181: 16 | 218: 16 |\n", - " 17: 9 | 37: 11 | 57: 12 | 77: 14 | 97: 14 | 117: 14 | 137: 16 | 157: 16 | 182: 16 | 219: 16 |\n", - " 18: 8 | 38: 11 | 58: 13 | 78: 13 | 98: 14 | 118: 15 | 138: 15 | 158: 16 | 183: 16 | 220: 16 |\n", - " 19: 9 | 39: 11 | 59: 14 | 79: 14 | 99: 14 | 119: 15 | 139: 16 | 159: 16 | 184: 16 | 222: 16 |\n", - " 20: 9 | 40: 11 | 60: 12 | 80: 13 | 100: 14 | 120: 14 | 140: 15 | 160: 15 | 185: 16 | 224: 16 |\n" + " 1: 1 | 52: 12 | 103: 15 | 154: 16 | 205: 17 | 256: 16 | 307: 18 | 360: 17 | 412: 19 | 474: 19 | 560: 19 |\n", + " 2: 2 | 53: 13 | 104: 14 | 155: 16 | 206: 17 | 257: 17 | 308: 18 | 361: 18 | 414: 18 | 475: 19 | 567: 18 |\n", + " 3: 3 | 54: 11 | 105: 14 | 156: 15 | 207: 17 | 258: 17 | 309: 18 | 362: 18 | 415: 19 | 476: 19 | 568: 19 |\n", + " 4: 4 | 55: 12 | 106: 15 | 157: 16 | 208: 16 | 259: 17 | 310: 18 | 363: 18 | 416: 18 | 477: 19 | 570: 19 |\n", + " 5: 5 | 56: 12 | 107: 16 | 158: 16 | 209: 17 | 260: 17 | 311: 19 | 364: 18 | 417: 19 | 480: 18 | 574: 19 |\n", + " 6: 5 | 57: 12 | 108: 13 | 159: 16 | 210: 16 | 261: 17 | 312: 17 | 365: 18 | 418: 19 | 481: 19 | 576: 18 |\n", + " 7: 6 | 58: 13 | 109: 14 | 160: 15 | 211: 17 | 262: 18 | 313: 18 | 366: 18 | 420: 18 | 482: 19 | 577: 19 |\n", + " 8: 6 | 59: 14 | 110: 14 | 161: 16 | 212: 17 | 263: 19 | 314: 18 | 367: 19 | 421: 19 | 483: 19 | 578: 19 |\n", + " 9: 6 | 60: 12 | 111: 14 | 162: 14 | 213: 17 | 264: 17 | 315: 17 | 368: 18 | 422: 19 | 484: 19 | 579: 19 |\n", + " 10: 7 | 61: 13 | 112: 14 | 163: 15 | 214: 18 | 265: 18 | 316: 18 | 369: 18 | 423: 19 | 485: 19 | 580: 19 |\n", + " 11: 8 | 62: 13 | 113: 15 | 164: 15 | 215: 17 | 266: 17 | 317: 19 | 370: 18 | 424: 19 | 486: 17 | 582: 19 |\n", + " 12: 7 | 63: 12 | 114: 14 | 165: 15 | 216: 15 | 267: 18 | 318: 18 | 371: 19 | 425: 19 | 487: 18 | 584: 19 |\n", + " 13: 8 | 64: 12 | 115: 15 | 166: 16 | 217: 16 | 268: 18 | 319: 19 | 372: 18 | 426: 19 | 488: 18 | 585: 19 |\n", + " 14: 8 | 65: 13 | 116: 15 | 167: 17 | 218: 16 | 269: 19 | 320: 17 | 373: 19 | 427: 19 | 489: 18 | 588: 19 |\n", + " 15: 8 | 66: 13 | 117: 14 | 168: 15 | 219: 16 | 270: 16 | 321: 18 | 374: 19 | 429: 19 | 490: 19 | 592: 19 |\n", + " 16: 8 | 67: 14 | 118: 15 | 169: 16 | 220: 16 | 271: 17 | 322: 18 | 375: 18 | 430: 19 | 492: 18 | 594: 19 |\n", + " 17: 9 | 68: 13 | 119: 15 | 170: 16 | 221: 17 | 272: 17 | 323: 18 | 376: 19 | 432: 17 | 493: 19 | 600: 19 |\n", + " 18: 8 | 69: 14 | 120: 14 | 171: 15 | 222: 16 | 273: 17 | 324: 16 | 377: 19 | 433: 18 | 494: 19 | 608: 19 |\n", + " 19: 9 | 70: 13 | 121: 15 | 172: 16 | 223: 17 | 274: 18 | 325: 17 | 378: 17 | 434: 18 | 495: 18 | 612: 19 |\n", + " 20: 9 | 71: 14 | 122: 15 | 173: 17 | 224: 16 | 275: 17 | 326: 17 | 379: 18 | 435: 18 | 496: 19 | 624: 19 |\n", + " 21: 9 | 72: 12 | 123: 15 | 174: 16 | 225: 16 | 276: 17 | 327: 17 | 380: 18 | 436: 18 | 498: 19 | 630: 19 |\n", + " 22: 10 | 73: 13 | 124: 15 | 175: 16 | 226: 17 | 277: 18 | 328: 17 | 381: 18 | 437: 19 | 500: 19 | 640: 19 |\n", + " 23: 11 | 74: 13 | 125: 15 | 176: 16 | 227: 18 | 278: 18 | 329: 18 | 382: 19 | 438: 18 | 504: 18 | 648: 18 |\n", + " 24: 9 | 75: 13 | 126: 14 | 177: 17 | 228: 16 | 279: 17 | 330: 17 | 384: 17 | 439: 19 | 505: 19 | 649: 19 |\n", + " 25: 10 | 76: 13 | 127: 15 | 178: 17 | 229: 17 | 280: 17 | 331: 18 | 385: 18 | 440: 18 | 506: 19 | 650: 19 |\n", + " 26: 10 | 77: 14 | 128: 14 | 179: 18 | 230: 17 | 281: 18 | 332: 18 | 386: 18 | 441: 18 | 507: 19 | 651: 19 |\n", + " 27: 9 | 78: 13 | 129: 15 | 180: 15 | 231: 17 | 282: 18 | 333: 17 | 387: 18 | 442: 19 | 508: 19 | 652: 19 |\n", + " 28: 10 | 79: 14 | 130: 15 | 181: 16 | 232: 17 | 283: 19 | 334: 18 | 388: 18 | 444: 18 | 510: 19 | 654: 19 |\n", + " 29: 11 | 80: 13 | 131: 16 | 182: 16 | 233: 18 | 284: 18 | 335: 19 | 389: 19 | 445: 19 | 511: 19 | 656: 19 |\n", + " 30: 10 | 81: 12 | 132: 15 | 183: 16 | 234: 16 | 285: 17 | 336: 17 | 390: 18 | 446: 19 | 512: 18 | 657: 19 |\n", + " 31: 11 | 82: 13 | 133: 15 | 184: 16 | 235: 17 | 286: 18 | 337: 18 | 391: 19 | 447: 19 | 513: 18 | 660: 19 |\n", + " 32: 10 | 83: 14 | 134: 16 | 185: 16 | 236: 17 | 287: 18 | 338: 18 | 392: 18 | 448: 18 | 514: 19 | 666: 19 |\n", + " 33: 11 | 84: 13 | 135: 14 | 186: 16 | 237: 17 | 288: 16 | 339: 18 | 393: 19 | 449: 19 | 516: 19 | 672: 19 |\n", + " 34: 11 | 85: 14 | 136: 15 | 187: 17 | 238: 17 | 289: 17 | 340: 18 | 394: 19 | 450: 18 | 518: 19 | 675: 19 |\n", + " 35: 11 | 86: 14 | 137: 16 | 188: 17 | 239: 18 | 290: 17 | 341: 19 | 395: 19 | 451: 19 | 520: 19 | 684: 19 |\n", + " 36: 10 | 87: 14 | 138: 15 | 189: 15 | 240: 16 | 291: 17 | 342: 17 | 396: 18 | 452: 19 | 522: 19 | 702: 19 |\n", + " 37: 11 | 88: 14 | 139: 16 | 190: 16 | 241: 17 | 292: 17 | 343: 18 | 397: 19 | 453: 19 | 525: 19 | 720: 19 |\n", + " 38: 11 | 89: 15 | 140: 15 | 191: 17 | 242: 17 | 293: 18 | 344: 18 | 398: 19 | 455: 19 | 528: 19 | 729: 18 |\n", + " 39: 11 | 90: 13 | 141: 16 | 192: 15 | 243: 15 | 294: 17 | 345: 18 | 399: 18 | 456: 18 | 532: 19 | 730: 19 |\n", + " 40: 11 | 91: 14 | 142: 16 | 193: 16 | 244: 16 | 295: 18 | 346: 19 | 400: 18 | 457: 19 | 540: 18 | 732: 19 |\n", + " 41: 12 | 92: 14 | 143: 16 | 194: 16 | 245: 17 | 296: 17 | 348: 18 | 401: 19 | 458: 19 | 541: 19 | 738: 19 |\n", + " 42: 11 | 93: 14 | 144: 14 | 195: 16 | 246: 16 | 297: 17 | 349: 19 | 402: 19 | 459: 18 | 542: 19 | 756: 19 |\n", + " 43: 12 | 94: 15 | 145: 15 | 196: 16 | 247: 17 | 298: 18 | 350: 18 | 403: 19 | 460: 19 | 543: 19 | 768: 19 |\n", + " 44: 12 | 95: 14 | 146: 15 | 197: 17 | 248: 17 | 299: 19 | 351: 17 | 404: 19 | 462: 19 | 544: 19 | 810: 19 |\n", + " 45: 11 | 96: 13 | 147: 15 | 198: 16 | 249: 17 | 300: 17 | 352: 18 | 405: 17 | 464: 19 | 545: 19 | 864: 19 |\n", + " 46: 12 | 97: 14 | 148: 15 | 199: 17 | 250: 17 | 301: 18 | 353: 19 | 406: 18 | 465: 19 | 546: 19 | 972: 19 |\n", + " 47: 13 | 98: 14 | 149: 16 | 200: 16 | 251: 18 | 302: 18 | 354: 18 | 407: 19 | 468: 18 | 549: 19 |\n", + " 48: 11 | 99: 14 | 150: 15 | 201: 17 | 252: 16 | 303: 18 | 355: 19 | 408: 18 | 469: 19 | 550: 19 |\n", + " 49: 12 | 100: 14 | 151: 16 | 202: 17 | 253: 17 | 304: 17 | 356: 19 | 409: 19 | 470: 19 | 552: 19 |\n", + " 50: 12 | 101: 15 | 152: 15 | 203: 17 | 254: 17 | 305: 18 | 357: 18 | 410: 18 | 471: 19 | 555: 19 |\n", + " 51: 12 | 102: 14 | 153: 15 | 204: 16 | 255: 17 | 306: 17 | 358: 19 | 411: 19 | 472: 19 | 558: 19 |\n" ] } ], "source": [ - "def show_complexity(end=17) -> None:\n", + "def show_complexity(end=20) -> None:\n", " \"\"\"Show a table of integer: complexity_number.\"\"\"\n", " table = complexity(end)\n", " show_columns([f'{x:3}: {table[x]:3} |' for x in sorted(table)])\n", @@ -1989,7 +2326,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -2001,7 +2338,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 49, "metadata": {}, "outputs": [ { @@ -2069,7 +2406,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.15" + "version": "3.13.3" } }, "nbformat": 4,