# A day at the beach

Inspired by this challenge

## Goal:

The goal is to draw waves crashing onto a beach.

## Input:

You will be given 3 integers (in whatever format you want) as input.
The first integer will be the length of the drawing The second integer will be the index of the sandbar, where the waves start to crest (at least 3 spaces from beach)
The third integer will be the spacing between waves (at least 3, can be greater than length of drawing, in which case you only draw one wave)

## Output:

The output will be a box of characters which shows the waves crashing into the beach. The drawing should end when the first wave has completed crashing into the beach.

At first, the wave is shown as a swell (_-_).
As the wave passes the sandbar, it starts to crest (/c_).
Finally, the wave crashes into the beach (/c. => _-_ => ___ => __. ).

## Examples:

Input: 14 4 6

Output:

-___________..
_-__________..
__-_________..
___-________..
___/c_______..
____/c______..
-____/c_____..
_-____/c____..
__-____/c___..
___-____/c__..
___/c____/c_..
____/c____/c..
-____/c____-_.
_-____/c_____.
__-____/c___..


Input: 10, 2, 11

Output:

-_______..
_-______..
_/c_____..
__/c____..
___/c___..
____/c__..
_____/c_..
______/c..
_______-_.
_________.
________..


Input: 6 0 3

c___..
/c__..
_/c_..
c_/c..
/c_-_.
_/c__.
c_/c..


## Rules:

Standard Loopholes apply

This is so shortest code wins

• · is not ASCII, which may exclude some languages. Can it be replaced by .? – Luis Mendo Feb 14 '17 at 15:23
• @LuisMendo The beach is supposed to be the ASCII period. The example of wave crashing into the beach is due to the period being practically invisible otherwise. – fəˈnɛtɪk Feb 14 '17 at 17:00
• Which leads me to the opposite question: can we use · instead of the ASCII period? (It's actually a rather big win in my code.) – Arnauld Feb 14 '17 at 17:12
• Using either or should be fine. The idea is that the code output appears consistent with the example outputs. – fəˈnɛtɪk Feb 14 '17 at 17:14

## JavaScript (ES6), 250 243 bytes

This code is assuming code page #1252 and is using the · character (0xB7). Takes input as 3 distinct parameters (a,b,c).

(a,b,c,R=n=>'_'.repeat(n-2),s=(x=b?'-':'c')+R(a-1)+'··')=>(g=j=>s+
+((F=__·$,_-_·,/c··,-__,^${C=R(b>2?b:2)}__-,/c_,^c_,^_${S=R(c)},_··,___·,_-_·,_-_,${C}/c_,_/c,/c,${x+S}.split,).map((r,i)=>s=i&8?s:s.replace(RegExp(r,'g'),F[i+8])),j--?g(j):''))(a)  ### How it works This code starts with a string such as -______·· and applies successive regular expressions on each iteration to animate the waves. For instance -__ is replaced with _-_. At first, it looked like a reasonable idea. However, the fact that the string may start with a c (like it does in the 3rd test case) makes things significantly more complicated. ### Test cases f = (a,b,c,R=n=>'_'.repeat(n-2),s=(x=b?'-':'c')+R(a-1)+'··')=>(g=j=>s+ +((F=__·$,_-_·,/c··,-__,^${C=R(b>2?b:2)}__-,/c_,^c_,^_${S=R(c)},_··,___·,_-_·,_-_,${C}/c_,_/c,/c,${x+S}.split,).map((r,i)=>s=i&8?s:s.replace(RegExp(r,'g'),F[i+8])),j--?g(j):''))(a)

console.log(f(14, 4, 6))
console.log(f(10, 2, 11))
console.log(f(6, 0, 3))

## Batch, 273 243 bytes

@echo off
set f=for /l %%i in (0,1,%1)do call
set s=set b=
%s%..
%f% %s%_%%b%%
%f%:c %%i %2 %3
exit/b
:c
set/aw=%1%%%3
if %w%==0 %s%__-%b:~3%
if %w%==%2 %s%%b:_-=/c%
%s%_%b:~0,-4%%b:~-3%
%s%%b:__. =_.. %
%s%%b:/.=-_%
echo %b:~3%


Note: Trailing space on line 4. If only the two beach characters were different, I could save 3 bytes and actually beat JavaScript!