42
4
Print a continuous sinusoidal wave scrolling vertically on a terminal. The program should not terminate and should continuously scroll down the wave (except until it is somehow interrupted). You may assume overflow is not a problem (i.e. you may use infinite loops with incrementing counters, or infinite recursion).
The wave should satisfy the following properties:
- Amplitude = 20 chars (peak amplitude)
- Period = 60 to 65 lines (inclusive)
- The output should only consist of spaces, newline and
|
- After each line of output, pause for 50ms
Sample output:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The above output should go on forever unless otherwise interrupted, e.g. SIGINT or SIGKILL, or closing terminal window, or you power off your machine, or the Sun swallows the Earth, etc.
Shortest code wins.
Note. I am aware of a similar problem on Display Scrolling Waves but this isn't exactly the same. In my problem, the wave is not to be scrolled "in place" - just output it on a terminal. Also, this is an ascii-art problem, so don't use Mathematica to plot it.
...or the Sun swallows the Earth, or the galaxy suffers from heat death, or highly intelligent beings tamper with the space time continuum – None – 2016-03-30T14:22:28.870
1Peak amplitude, peak-to-peak amplitude, or root-square amplitude? – DavidC – 2014-01-16T20:31:47.710
Peak amplitude. – user12205 – 2014-01-16T20:38:04.440
@David The Ecuador makes it pretty obvious. :-P – Doorknob – 2014-01-16T20:38:18.690
1Is it ok to draw a wave with just |s and no spaces? – Gelatin – 2014-01-17T01:23:30.087
@Gelatin Yes it is ok. – user12205 – 2014-01-17T08:19:44.173
Can a specific standard terminal width be assumed (e.g. 80)? – maxwellb – 2014-01-17T23:06:46.723
@maxwellb Terminal width is unspecified, i.e. do whatever you want :) – user12205 – 2014-01-17T23:17:13.650
@ace Wait, if I were to replace every space character in your sample output with
|
, it would be a valid program? You shouldn't say this because it changes the question. – Justin – 2014-01-19T09:49:10.347@Quincunx it's not a wave then, is it? – user12205 – 2014-01-19T10:14:48.590
@ace Then why your response to this?
– Justin – 2014-01-19T23:36:22.877@Quincunx Oh... I thought using no spaces mean something like
printf("%*c")
... sorry for the misunderstanding... – user12205 – 2014-01-19T23:46:21.0531All answers yet are invalid. They also stop for SIGKILL not just for SIGINT. – Max Ried – 2014-04-04T09:02:59.547
1@Max Ried fine, I will change it to "should go on forever unless otherwise interrupted". – user12205 – 2014-04-04T10:28:54.967