[seqfan] Re: Balanced / Unbalanced numbers

D. S. McNeil dsm054 at gmail.com
Sun Dec 9 17:58:29 CET 2018


I think the path for 2 diverges a little from that because of a value being
off by one in step 13:

step #1: 2 + 112 = 114 false
step #2: 114 + 112 = 226 false
step #3: 226 + 211 = 437 false
step #4: 437 + 431 = 868 false
step #5: 868 + 871 = 1739 false
step #6: 1739 + 1744 = 3483 false
step #7: 3483 + 3489 = 6972 false
step #8: 6972 + 6963 = 13935 false
step #9: 13935 + 14003 = 27938 false
step #10: 27938 + 27968 = 55906 false
step #11: 55906 + 55820 = 111726 false
step #12: 111726 + 111728 = 223454 false
step #13: 223454 + 223450 = 446904 false
step #14: 446904 + 446905 = 893809 false
step #15: 893809 + 893813 = 1787622 false
step #16: 1787622 + 1787621 = 3575243 false
step #17: 3575243 + 3575488 = 7150731 false
step #18: 7150731 + 7150681 = 14301412 false
step #19: 14301412 + 14301403 = 28602815 false
step #20: 28602815 + 28602909 = 57205724 false
step #21: 57205724 + 57205818 = 114411542 false
step #22: 114411542 + 114411543 = 228823085 false
step #23: 228823085 + 228823199 = 457646284 false
step #24: 457646284 + 457646291 = 915292575 false
step #25: 915292575 + 915292488 = 1830585063 false
step #26: 1830585063 + 1830585101 = 3661170164 false
step #27: 3661170164 + 3661170165 = 7322340329 false
step #28: 7322340329 + 7322340326 = 14644680655 false
step #29: 14644680655 + 14644679920 = 29289360575 false
step #30: 29289360575 + 29289360580 = 58578721155 false
step #31: 58578721155 + 58578721162 = 117157442317 false
step #32: 117157442317 + 117157442282 = 234314884599 true

but we find a balanced number in the end.

I'm going to have to teach my find_nearest_balanced function to be smarter,
though.  Brute force searching on each side doesn't cut it for 12, where we
hit 1037708753757778746280242 on the road and the buildup of odd numbers on
the left finally causes a problem.  Probably makes more sense to figure out
the digit difference we need to make up and build candidates directly.

E.g. just by looking at the distance we need to cover I know
that 1037708753757778811488888 is balanced and (relatively) nearby,
although I didn't check to see if it had the minimal distance, and since I
was just keyboard mashing it probably doesn't. :-)


Doug



More information about the SeqFan mailing list