tkellehe / noodel

A programming language designed around supporting ASCII animation based code golfing challenges.
10 stars 0 forks source link

Time taken to print numbers #82

Open tkellehe opened 7 years ago

tkellehe commented 7 years ago

http://codegolf.stackexchange.com/questions/106856/time-taken-to-print-numbers

17 bytes

ƇGQȥḋɲṡ×2Ḷñ⁺1€ÑƇ⁻

My answer

Try it:)

tkellehe commented 7 years ago

13 bytes

Tried a slightly different approach and saved 4 bytes.

ƇQjȥḶGQɱ⁻Ñ€Ƈ⁻

Try it:)

tkellehe commented 7 years ago

11 bytes

With the new get the time since execution start can save two bytes. Should have added this when I added the get current time...

QjȥḶGQɱ⁻Ñ€Ƭ

Try it:)

            # Program execution start time is implicitly recorded.

Qjȥ         # Creates the value 2001.
Qj          # Pushes the string literal "Qj" onto the stack.
  ȥ         # Treats the string as a base 98 number corresponding to the Noodel code page.

   ḶGQɱ⁻Ñ€  # Prints -1000 ... 1000.
   Ḷ        # Consumes the 2001 and loops the following code that many times.
    GQ      # Pushes the string literal "GQ" onto the stack.
      ɱ     # Pushes on the loop counter (zero based).
       ⁻    # Attempts to subtract (ɱ - "GQ") and since ɱ is a number the string will be converted into a number (which will fail therein default to base 98 conversion).
        Ñ   # Consumes the difference and prints it to the screen followed by a new line.
         €  # End of the loop.

          Ƭ # Pushes on the amount of time passed since the start in milliseconds.
tkellehe commented 7 years ago

An update to the looping function now numerical eval strings.

10 bytes

QjḶGQɱ⁻Ñ€Ƭ

Try it:)

           # Program execution start time is implicitly recorded.

Qj         # Pushes the string literal "Qj" onto the stack.

  ḶGQɱ⁻Ñ€  # Prints -1000 ... 1000.
  Ḷ        # Consumes the "Qj" and evaluates as base 98 to get 2001 and loops the following code that many times.
   GQ      # Pushes the string literal "GQ" onto the stack.
     ɱ     # Pushes on the loop counter (zero based).
      ⁻    # Attempts to subtract (ɱ - "GQ") and since ɱ is a number the string will be converted into a number (which will fail therein default to base 98 conversion).
       Ñ   # Consumes the difference and prints it to the screen followed by a new line.
        €  # End of the loop.

         Ƭ # Pushes on the amount of time passed since the start in milliseconds.