18
\$\begingroup\$

Content

You count numbers every day (I think), and most of you know how to count properly, the one next to 1 is 2, and the next is 3, so go on, no matter what number you receive, you can easily know what next number is.

Anyway, the program doesn't know, they are incredibly stupid, if I make a program shaped like 1, it doesn't count to 2 for me. We need to solve that asap.

Task

Write a program shaped 1 that produces a program shaped 2, which chains and produces the next number, until the program failed and produces a number other than it should be.

Shapes

your number should shaped like:

  #      ###   ###    # #  ###  ###  ###  ###  ###  ###
  #        #     #    # #  #    #      #  # #  # #  # #
  #      ###   ###    ###  ###  ###    #  ###  ###  # #
  #      #       #      #    #  # #    #  # #    #  # #
  #      ###   ###      #  ###  ###    #  ###    #  ###

It can be enlarged, twisted, be longer or shorter, as long as it Resembles the shape:

Acceptable:
 #####  ######  ### resembles 9
 ##  #  #    #  # #
 ##  #  ######  ###
 #####       #  ###
     #       #    #
     #       #    #
             #

Not acceptable:

  ###   #####   ###  ####
  ###   # #     # #  # ##
    #   ###     ###  ###
    #     #      #     #
          #      #     #
Those does NOT resembles 9

Acceptable reshape:

Original shape:

   ###               ####
   # #      widen    #  #
   ###     ------->  ####
     #                  #
     #                  #

           extend   ###       shorten   ###
           -------> # #   or            # #
                    ###                 ###
                      #                   #
                      #
                      #



          lengthen  ###
           -------> # #
                    # #
                    ###
                      #
                      #

     enlarge line   ###      ####      ####      ###           ###
           -------> ###  or  # ##  or  ## #  or  # #  but not  # # (this is
                    # #      ####      ####      ###           ###  not 9
                    ###        ##         #      ###           ###  but a 0)
                      #        ##         #        #           ###
                      #        


You can do 1 or more of those actions on the same digit for any amount of units, for example:

   #####
   #  ##
   #  ##
   #####
      ##
      ##
      ##
      ##

Is Widened, extended, enlarged, and lengthened.

The original number should be obtained if you repeatedly removing one out of two consecutive identical rows or columns.

For digits that contain a hole in it (6, 8, 9, 0), the hole should exist (length, wide does not matter).

For U-shaped holes (2, 3, 4, 5, 6), those should have at least one empty byte that resembles a hole:

  ###  is done by shortening, and then enlarge line.
   ##  
  ###  Acceptable.
   ##
  ###

For numbers that have more than one digit, digits should have at least one spacing between them, and they should not be connected in any way:

  #  ###
  #    #
  #  ###
  #  #
     ###

In case someone built a super large program, I am limiting first number's (1) byte count to be under 10k.

Rules

  • No standard loopholes
  • Takes no input and outputs a program.
  • You should output in the very same language you used on the previous number.

Scoring

Your score is the highest number you chained until break.

For example, your code failed to generate 21, your score will be 20. In this case, the 20 program could be anything as long as it fits number rules, may also be non-program.

If there is infinity score exist, it counts as an infinity score.

for tie breaker, It would be the lowest total bytes count until the number 1000.

Whoever gets the largest number is the overall winner. (Grand prize)

And also individual winners for each language too. (individual prize)

\$\endgroup\$
4
  • 4
    \$\begingroup\$ For those who like formal definitions, I'd add that the "resembles" transformation is zero or more steps of "enlarge" (choose a row or column and insert its copy right after the original) or "shrink" (choose two adjacent identical rows or columns and remove one of the two). \$\endgroup\$
    – Bubbler
    Sep 2 at 3:40
  • 7
    \$\begingroup\$ If I'm understanding this correctly, the minimal correct shape for each digit would look like this, and all valid digits can be formed by "enlarge" operations only from these shapes. Is this correct @okie? \$\endgroup\$
    – Bubbler
    Sep 2 at 3:45
  • 1
    \$\begingroup\$ @Bubbler correct! \$\endgroup\$
    – okie
    Sep 2 at 5:14
  • 5
    \$\begingroup\$ Bubbler's explanation is simple and clear to me. The current explanation is long and confusing. I would just use that one, instead. \$\endgroup\$
    – Wheat Witch
    Sep 2 at 8:04
31
\$\begingroup\$

Python 3, infinity points

exec('exec("N=2%F=@@@%Q=chr'                            
'(39)*3%def?magic(s,N,W,H=N'                            
'one):%?if?H?is?None:%??H?='                            
'?W//2%?L=[%?@###,#,###,###'                            
',#?#,###,###,###,###,###@.'                            
'split(@,@),%?@#?#,#,??#,??'                            
'#,#?#,#??,#??,??#,#?#,#?#@'                            
'.split(@,@),%?@#?#,#,###,#'                            
'##,###,###,###,??#,###,###'                            
'@.split(@,@),%?@#?#,#,#??,'                            
'??#,??#,??#,#?#,??#,#?#,??'                            
'#@.split(@,@),%?@###,#,###'                            
',###,??#,###,###,??#,###,?'                            
'?#@.split(@,@)]%?Z=@@%?s=s'                            
'.replace(chr(32),chr(63)).'                            
'replace(chr(34),chr(33)).r'                            
'eplace(chr(39),chr(64)).re'                            
'place(chr(10),chr(37))%?s='                            
'f@exec({chr(39)}exec(!{s}!'                            
'.replace(chr(63),chr(32)).'                            
'replace(chr(33),chr(34)).r'                            
'eplace(chr(64),chr(39)).re'                            
'place(chr(37),chr(10))){ch'                            
'r(39)})@%?I=0%?done=False%'                            
'?for?i?in?range(5):%??for?'                            
'_?in?range(H):%???z=@?@.jo'                            
'in(L[i][int(j)]for?j?in?st'                            
'r(N))+@?@%???k=0%???for?j?'                            
'in?z:%????if?j==@#@:%?????'                            
'k+=1%????else:%?????if?k:%'                            
'??????k*=W%??????if?I==0:%'                            
'???????Z+=s[:k-1]+!@!%????'                            
'???I=k-1%??????else:%?????'                            
'??z=s[I:I+k-2]%???????if?l'                            
'en(z)?==?0:%????????Z+=@#@'                            
'*k%???????elif?len(z)?<?k-'                            
'2:%????????Z+=(!@!+z).ljus'                            
't(k,@#@)%????????I+=k%????'                            
'????done=True%???????else:'                            
'%????????if?z[-1]==!@!:%??'                            
'???????Z+=!@!+z+@)@%??????'                            
'???I+=k%?????????done=True'                            
'%????????elif?z[-2]==!@!:%'                            
'?????????Z+=!@!+z+@#@%????'                            
'?????I+=k%?????????done=Tr'                            
'ue%????????else:%?????????'                            
'Z+=!@!+z+!@!%?????????I+=k'                            
'-2%?????Z+=@?@*W%?????k=0%'                            
'???Z+=chr(10)%?if?done:?re'                            
'turn?Z[:-1]%def?f(s):%?fro'                            
'm?itertools?import?count%?'                            
'print(next(filter(None,(ma'                            
'gic(s,N,w)?for?w?in?count('                            
'7)))))%@@@%exec(F)%templat'                            
'e=@@@N={}%F={}{}{}%exec(F)'                            
'%template={}{}{}%S=templat'                            
'e.format(N+1,Q,F,Q,Q,templ'                            
'ate,Q)%f(S)@@@%S=template.'                            
'format(N+1,Q,F,Q,Q,templat'                            
'e,Q)%f(S)".replace(chr(63)'                            
',chr(32)).replace(chr(33),'                            
'chr(34)).replace(chr(64),c'                            
'hr(39)).replace(chr(37),ch'                            
'r(10)))')##################                            
############################                            
############################                            
############################                            
############################                            
############################                            
############################                        

Try it online!

Here's the code that generates the 1

The total length of the first 1000 programs (including 1) is 3961370 bytes

The main function of interest takes any string without !, ?, @, or % and uses those to escape (space), \n, ', ". That makes it easy to split up the big exec string, since it has nothing annoying anymore.

Here's the number 1234567890 as generated by the program. (At the TIO link, you can see how it has to increase the size of 1234567891 because it couldn't fit)

exec(''       'exec("N=1234567891%'       'F=@@@%Q=chr(39)*3%d'       'ef?ma'       'gic(s'       ',N,W,H=None):%?if?H'       '?is?None:%??H?=?W//'       '2%?L=[%?@###,#,###,'       '###,#?#,###,###,###'       ',###,###@.split(@,@'       '),%?@#?#,#,??#,??#,'       
'#?#,#'       '??,#??,??#,#?#,#?#@'       '.split(@,@),%?@#?#,'       '#,###'       ',###,'       '###,###,###,??#,###'       ',###@.split(@,@),%?'       '@#?#,#,#??,??#,??#,'       '??#,#?#,??#,#?#,??#'       '@.split(@,@),%?@###'       ',#,###,###,??#,###,'       
'###,?'       '?#,###,??#@.split(@'       ',@)]%?Z=@@%?s=s.rep'       'lace('       'chr(3'       '2),chr(63)).replace'       '(chr(34),chr(33)).r'       'eplace(chr(39),chr('       '64)).replace(chr(10'       '),chr(37))%?s=f@exe'       'c({chr(39)}exec(!{s'       
'}!.re'                     'place'                     '(chr('       '63),c'       'hr(32'       ')).re'                     'place'                                   '(chr('       '33),c'       'hr(34'       ')).re'       'place'       '(chr('       '64),c'       
'hr(39'                     ')).re'                     'place'       '(chr('       '37),c'       'hr(10'                     '))){c'                                   'hr(39'       ')})@%'       '?I=0%'       '?done'       '=Fals'       'e%?fo'       'r?i?i'       
'n?ran'                     'ge(5)'                     ':%??f'       'or?_?'       'in?ra'       'nge(H'                     '):%??'                                   '?z=@?'       '@.joi'       'n(L[i'       '][int'       '(j)]f'       'or?j?'       'in?st'       
'r(N))'       '+@?@%???k=0%???for?'       'j?in?z:%????if?j==@'       '#@:%?????k+=1%????e'       'lse:%?????if?k:%???'       '???k*=W%??????if?I='                     '=0:%?'       '??????Z+=s[:k-1]+!@'       '!%???????I=k-1%????'       '??els'       'e:%??'       
'?????'       'z=s[I:I+k-2]%??????'       '?if?len(z)?==?0:%??'       '??????Z+=@#@*k%????'       '???elif?len(z)?<?k-'       '2:%????????Z+=(!@!+'                     'z).lj'       'ust(k,@#@)%????????'       'I+=k%????????done=T'       'rue%?'       '?????'       
'?else'       ':%????????if?z[-1]='       '=!@!:%?????????Z+=!'       '@!+z+@)@%?????????I'       '+=k%?????????done=T'       'rue%????????elif?z['                     '-2]=='       '!@!:%?????????Z+=!@'       '!+z+@#@%?????????I+'       '=k%??'       '?????'       
'??don'       'e=Tru'                                   'e%???'                     '?????'                     'else:'       '%????'       '?????'                     'Z+=!@'       '!+z+!'       '@!%??'                     '?????'       '??I+='       'k-2%?'       
'????Z'       '+=@?@'                                   '*W%??'                     '???k='                     '0%???'       'Z+=ch'       'r(10)'                     '%?if?'       'done:'       '?retu'                     'rn?Z['       ':-1]%'       'def?f'       
'(s):%'       '?from'                                   '?iter'                     'tools'                     '?impo'       'rt?co'       'unt%?'                     'print'       '(next'       '(filt'                     'er(No'       'ne,(m'       'agic('       
's,N,w'       ')?for?w?in?count(7)'       '))))%@@@%exec(F)%te'                     'mplat'       'e=@@@N={}%F={}{}{}%'       'exec(F)%template={}'                     '{}{}%'       'S=template.format(N'                     '+1,Q,'       'F,Q,Q,template,Q)%f'       
'(S)@@'       '@%S=template.format'       '(N+1,Q,F,Q,Q,templa'                     'te,Q)'       '%f(S)".replace(chr('       '63),chr(32)).replac'                     'e(chr'       '(33),chr(34)).repla'                     'ce(ch'       'r(64),chr(39)).repl'       
'ace(c'       'hr(37),chr(10)))')##       #####################                     #######       #####################       #####################                     #######       #####################                     #######       #####################       

Try it online!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ congrets on achieving infinity! I didn't expect the answer came out this fast. but in case someone also achieved infinity too, can you provide you total byte count for first 1000 number? Thx! \$\endgroup\$
    – okie
    Sep 3 at 1:11
  • 2
    \$\begingroup\$ This is really amazing! Worth checking if you're eligible for any of these bounties with no deadline. I'd give you a bounty now if I had enough rep! \$\endgroup\$
    – AviFS
    Sep 3 at 1:42
7
\$\begingroup\$

Jelly, score infinity, 134 111 bytes for 1, 597940 bytes for 1..1000

“ØJṫ-3ØėṖ¤,“DịI¢I¤ȷṢI£⁽⁽IȥbI£ḤYI¤<⁻ID-I¤<⁽I¡~øIŀḊEḃ65ḃ2EaOṛj0z0x€0¦F¥€;ṪA$ṾƊ;I©Vy¥vƭ/OUƊɼL¤Ua1¦®ṚUo⁶Y”;©2Vy¥vƭ/

Try it online!

A full program that takes no arguments and prints the next program. Should work for any integer - to try a different output just change the number 2 after the ©︎ to something else. This uses something similar to the minimum possible shapes for each number as suggested by @Bubbler but I’ve added a zero. The left-hand most digit has its right-hand column widened to accommodate the program, which is then placed in the bottom row. All other non-spaces are replaced by the right link, .

Example program for 9876543210

    ṛṛṛ     ṛṛṛ ṛṛṛ     ṛṛṛ ṛṛṛ                                                                                                                               
ṛṛṛ ṛ ṛ     ṛ   ṛ         ṛ   ṛ                                                                                                                               
ṛ ṛ ṛṛṛ     ṛṛṛ ṛṛṛ ṛ ṛ ṛṛṛ ṛṛṛ   ṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛ
ṛṛṛ ṛ ṛ ṛṛṛ ṛ ṛ   ṛ ṛṛṛ   ṛ ṛ     ṛ ṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛṛ
  ṛ ṛṛṛ  ṛṛ ṛṛṛ ṛṛṛ   ṛ ṛṛṛ ṛṛṛ ṛ ṛṛ“ØJṫ-3ØėṖ¤,”,“DịI¢I¤ȷṢI£⁽⁽IȥbI£ḤYI¤<⁻ID-I¤<⁽I¡~øIŀḊEḃ65ḃ2EaOṛj0z0x€0¦F¥€;ṪA$ṾƊ;I©Vy¥vƭ/OUƊɼL¤Ua1¦®ṚUo⁶Y”,9876543211©Vy¥vƭ/

Try it online!

Explanation (outdated)

[“&<-”,[”“,”’,””]],“D…Y”,2      | Literal list of [["&<-","“’”"],"D…Y",2]
                          ©     | Copy this list to the register
                             ƭ/ | Reduce using:
                           y    | 1. translate (so the D…Y item has "&" replaced by "“", "<" by "’" and "-" by "”")
                            v   | 2. Eval (so the translated string is evaluated as a program using 2 as its argument

Explanation of the program that’s built by the main program (also outdated(

This is split into parts to make easier to read; these are all a single link though. It takes an integer argument and also expects the original list of three items in the main program to be in the register.

   “œ…’       ¤     | Starting with [7814, 233918, 203174, 39260, 210860, 241612, 15754, 241614, 86334, 54574]
            Ɗ       | - Do the following as a monad:
       ḃ62          | - Convert to bijective base 62
          ḃ2        | - Convert to bijective base 2
             ’      | - Subtract 1
 Dị                 | Now, index into this list of binary digits using the digits of the link’s argument
               j0   | Join with zeroes
                 z0 | Transpose, filling with zeros
 
                 Ʋ | Starting with the link’s argument:
      +1           | - Add 1
        D          | - Convert to decimal digits
         L         | - Length
                Ʋ  | - Following as a monad:
          132+     | - Add 132
              1;   | - Prepend 1 (call this y)
    ¥€             | For each row of the output from the first part:
 x"                | - Repeat the number of times indicated by y, with arguments zipped
   F               | - Flatten
 
 ḷ              ɗɼ$ | Do the following to the register, but preserve the existing working value of the link (output from previous part):
       Ʋ            | - Following as a monad:
  Ṫ                 |   - Tail
   +1               |   - Add 1
     ;@             |   - Append to the end of the list
        Ṿ           | - Uneval
         Ż   Ɗ}¡    | - Prepend a zero if the following is true when applied to the output from previous part:
          ¬         |   - Not
           Ḣ        |   - Head
            Ḣ       |   - Head
 
 aⱮ”¹                  | And with "¹"
     a1¦®;“©yvƭ/”¤     | And the first row with the register after appending "©︎yvƭ/" to it
                  Ṛ    | Reverse
                   o⁶  | Or with space
                     Y | Join with newlines
\$\endgroup\$
6
  • 1
    \$\begingroup\$ Your 4 is not fitting the rule here, you should extend or shorten the entire line, not just bottom of the line.#s##/n####/nss## should work instead of #s#/n###/ns##.(s = space) And also, your bytes count should be the sum byte count of first 1000 number, not the first program only. \$\endgroup\$
    – okie
    Sep 6 at 0:14
  • 1
    \$\begingroup\$ @okie thanks. How about now? \$\endgroup\$ Sep 6 at 0:37
  • \$\begingroup\$ your example 9876543210’s 8 is somehow broken along with top row being shifted a bit. \$\endgroup\$
    – okie
    Sep 6 at 1:18
  • 1
    \$\begingroup\$ @okie sorry copy-paste error \$\endgroup\$ Sep 6 at 6:48
  • \$\begingroup\$ your answer are valid now! well done! \$\endgroup\$
    – okie
    Sep 6 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.