# 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 !
• What is the winning criterion? – Luke Jan 26 '17 at 16:47
• Should the robot reproduce the use of backspace, cursor moves, text overwriting, etc.? – Arnauld Jan 26 '17 at 16:52
• @Luke Winner is the most creative solution I guess ? – Sygmei Jan 26 '17 at 16:54
• @Arnauld Nope, it does not have to. But that would be a nice solution ! – Sygmei Jan 26 '17 at 16:54
• All challenges on PPCG must have an objective winning criterion, such as shortest code or fastest to run. I'd suggest shortest code (that is, code-golf) for this particular challenge. – ETHproductions Jan 26 '17 at 16:55

# Bash + linux utilities, 37

This will measure the time taken to enter each character (including backspaces) and play back verbatim. Use ^C or ^D to end user input.

script -qta -csed\ d
scriptreplay -ta


Creates a temporary files typescript and a in the current directory.

• I'll try that when I'll be on Linux :) – Sygmei Jan 26 '17 at 17:20
• Wow ! Neat one :) Nice use of Linux utilities – Sygmei Jan 26 '17 at 18:46
• You can actually get bash for windows if you like what you see. That is what Git for Windows uses. – nurchi Jan 26 '17 at 20:18
• That's cheating BTW, script and scriptreplay are not a bash utility or of any other shell I know. They are binaries. If this is considered a legitimate answer then I can put these two commands inside an executable called a and give ./a as an answer ;-D – saga Jan 28 '17 at 15:17
• @Saga. The point is the language here is "Bash + linux utilities" and not "Pure Bash" (in which case the answer would only contain bash builtins). On my vanilla Ubuntu machine, this includes old favourites such sed and script. From the point of view of PPCG, these utilities effectively form a "standard library" to bash. That they are implemented as binaries is an irrelevant implementation detail. Look around - you'll see this seems to be well accepted by the PPCG community. – Digital Trauma Jan 28 '17 at 17:28

# MATLAB / Octave, 38 bytes

tic;x=input('','s');pause(toc);disp(x)


Starts a timer (tic) and prompts the user for input. Then the program pauses for however long it took for the user to input the text (toc) and prints out the input text.

• Commands named tic and toc? That's genius :-) – ETHproductions Jan 26 '17 at 17:03

# MATL, 7 5 bytes

2 bytes saved thanks to @Luis

jZY.


This solution will determine how long the user takes to enter the input and then wait that same amount before printing the user's input back to them all at once.

Unfortunately doesn't work online since the online interpreters don't support interactive input.

Explanation

        % Implicitly start the timer
j       % Grab user input as a string (will prompt the user)
Z      % Stop the timer and return the elapsed time in seconds
Y.      % Pause for this many seconds
% Implicitly display the user-input string

• GIF in the post always makes it better ! – Sygmei Jan 26 '17 at 17:19

# Python 3.5, 61 bytes

from time import*
s,i=time(),input()
sleep(time()-s)
print(i)