A day at the beach
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!