Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output Keystrokes #113

Open
tkellehe opened this issue Feb 19, 2017 · 3 comments
Open

Output Keystrokes #113

tkellehe opened this issue Feb 19, 2017 · 3 comments

Comments

@tkellehe
Copy link
Owner

tkellehe commented Feb 19, 2017

http://codegolf.stackexchange.com/q/110467/52270

18 bytes

ʋ115ṡḶƙÞṡạḌ100.ṡ€ß

My answer

Try it:)

                   # Input is automatically pushed to the stack.
ʋ                  # Vectorize the string into an array of characters.
 115               # Push on the string literal "115" to be used to create the delays.
    ṡ              # Swap the two items on the stack.

     ḶƙÞṡạḌ100.ṡ€  # The main loop for the animation.
     Ḷ             # Loops the following code based off of the length of the string.
      ƙ            # Push on the current iteration's element of the character array (essentially a foreach).
       Þ           # Pop off of the stack and push to the screen.
        ṡ          # Swap the string "115" and he array of characters (this is done because need array of characters on the top for the loop to know how many times to loop)
         ạ         # Grab the next character in the string "115" (essentially a natural animation cmd that every time called on the same object will access the next item looping)
                   # Also, turns the string into an array of characters.
          Ḍ100.    # Pop the character off and convert to a number then multiply by 100 to get the correct delay. Then delay for that many ms.
               ṡ   # Swap the items again to compensate for the one earlier.
                €  # The end of the loop.

                 ß # Clears the screen such that when implicit popping of the stack occurs it will display the correct output.
@tkellehe
Copy link
Owner Author

tkellehe commented Feb 20, 2017

Possible future 11 byte solution.

¥115ṡṬƙÞạḌO

@tkellehe
Copy link
Owner Author

tkellehe commented Apr 6, 2017

15 bytes

ʋ115ṡḶƙÞṡạḌOṡ€ß

Try it:)

                # Input is automatically pushed to the stack.
ʋ               # Vectorize the string into an array of characters.
 115            # Push on the string literal "115" to be used to create the delays.
    ṡ           # Swap the two items on the stack.

     ḶƙÞṡạḌOṡ€  # The main loop for the animation.
     Ḷ          # Loops the following code based off of the length of the string.
      ƙ         # Push on the current iteration's element of the character array (essentially a foreach).
       Þ        # Pop off of the stack and push to the screen.
        ṡ       # Swap the string "115" and he array of characters (this is done because need array of characters on the top for the loop to know how many times to loop)
         ạ      # Grab the next character in the string "115" (essentially a natural animation cmd that every time called on the same object will access the next item looping)
                # Also, turns the string into an array of characters.
          ḌO    # Pop the character off and convert to a number then multiply by 100 to get the correct delay. Then delay for that many ms.
            ṡ   # Swap the items again to compensate for the one earlier.
             €  # The end of the loop.

              ß # Clears the screen such that when implicit popping of the stack occurs it will display the correct output.

@tkellehe
Copy link
Owner Author

tkellehe commented Apr 9, 2017

11 bytes

¥115ṡḞƙÞạḌO

Try it:)

            # Input is automatically pushed to the stack.
¥           # Turns off auto popping.
 115        # Push on the string literal "115" to be used to create the delays.
    ṡ       # Swap the two items on the stack.

     ḞƙÞạḌO # The main loop for the animation.
     Ḟ      # Loops the following code over each character of the string consuming off of the stack.
      ƙ     # Push on the current iteration's element of the character array (essentially a foreach).
       Þ    # Pop off of the stack and push to the screen.
        ạ   # Grab the next character in the string "115" (essentially a natural animation cmd that every time called on the same object will access the next item looping)
         ḌO # Pop the character off and convert to a number then multiply by 100 to get the correct delay. Then delay for that many ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant