40
3
Background
The echo
program is so neat. You can say anything to it, and it repeats your words perfectly, every time! How cool is that! Disappointingly, it repeats the input all at once, regardless of your typing speed, which is not very realistic. We'll have to fix that.
The Task
Your program shall take its input from STDIN or closest equivalent. It shall read lines from the user one by one, possibly displaying some prompt, until they enter an empty line. After that, it shall print the lines to STDOUT or closest equivalent, in the same order as they were given. The last (empty) line is not printed, and the last printed line doesn't need to have a trailing newline.
Additionally, the program shall preserve the time intervals between each line: if it took the user x
seconds to enter a line, it shall take x
seconds for the program to print it.
This applies to the first and last lines too; the empty line is not printed, but the program waits anyway before terminating.
Example
Here's an example session with the program.
All actions that don't produce text are described in brackets, and the (optional) prompt is displayed as >
.
[begin program]
> fhtagn[enter; 1.48s passed since starting program]
> yum yum[enter; 3.33s passed since previous enter]
> so cool![enter; 2.24s passed since previous enter]
> [enter; 0.23s passed since previous enter]
[wait 1.48s]fhtagn
[wait 3.33s]yum yum
[wait 2.24s]so cool!
[wait 0.23s, then end program]
Without the actions, the session looks like this:
> fhtagn
> yum yum
> so cool!
>
fhtagn
yum yum
so cool!
Rules and Scoring
The waiting times should be accurate to within 0.01 seconds (in practice, if the average human can't tell the difference, you're fine). The lowest byte count wins, and standard loopholes are disallowed. If your language has a built-in function for precisely this task, you may not use it.
10Next step up: Golf a program that plays a basic rhythm game :P – Sp3000 – 2015-10-09T14:49:41.750
Can we disregard the time the program takes to output characters? I mean, If I can measure that my language takes 0.1 sec to output a char, should I take it into account? Full disclosure, I'm planning to use ><> interpreters' tick time to implement the delay ; in this case, can I have a loop elapsing the input time then disregard the time elapsed by my display loop? – Aaron – 2015-10-09T14:56:51.293
1@AaronGOUZIT I'll allow that, as long as you're consistent: either the time intervals between the moments your program begins to print a line are all taken from the user, OR the waiting times between finishing printing a line and beginning to print the next are all taken from the user. – Zgarb – 2015-10-09T15:00:58.400
if it took the user x seconds to enter a line, it shall take x seconds for the program to print it. - does this mean character by character with pauses in between, or print line / pause / print line / pause ? – TessellatingHeckler – 2015-10-09T15:21:39.217
1@TessellatingHeckler The latter; see the example session. – Zgarb – 2015-10-09T15:24:15.057
How is typing
so cool!
shorter than typingyum yum
? :) – user41805 – 2015-10-09T19:06:10.8731@KritixiLithos I only used my right hand for
yum yum
, which was rather cumbersome. – Zgarb – 2015-10-09T19:07:57.510