A boring version of yourself
Have you ever dreamed of a boring version of you which types the text you just typed ?
No ? Because that's exactly what I'm challenging you to do !
The program needs to check how many time it took for the user to input a text at program launch and then retype the text again using the same period of time (approximatively).
Here's my Python3 implementation with additional information :
import time start = time.time() userInput = input("Cool human input :") endHuman = time.time() - start duration = endHuman / len(userInput) start = time.time() print("Boring robot input : ", end="") for i in userInput: print(i, end="") time.sleep(duration) end = time.time() - start print() print(endHuman, "vs", end)
This is a code-challenge so be creative !
Here are the rules :
- User must input the initial text, no program args
- Text input length is > 0 (No need to check)
- The sleep duration between each letter is not imposed, it can be (timeTookByUser / numberOfLetters) like in my implementation, it can be random (as long as the total time is approximatively equal), it can sleep for the total time at first and then print all (but it's not fun).
- The "robot timer" must stop when the last letter is typed by the robot, you can't print everything and then sleep and end the program.
- As long as the robot prints the text passed in input, you can print other stuff (additional informations etc..)
- You don't have to use the console, you can input the text using a graphical text input and render it letter by letter using DELs but you will have to specify it in your answer
- Be creative !