26
2
Take a flag, like this one:
-----------------------------
| | |
| | |
|=============+=============|
| | |
| | |
-----------------------------
And a number input: the "wave length"
Say the wave length was 5. Then, every 5 characters along the line from the beginning, replace the next character a -
with \
and shift all the characters after it one row down. Repeat this until the end. You end up with:
-----\
| -----\
| -----\
|===== | -----\
| ====== | -----
| ==+=== |
-----\ | ====== |
-----\ | ====|
-----\ |
-----\ |
-----
If you end up not being able to make a full wave length along at the end, the flag is finished. Just remain flat until the end.
You can assume that all the lines are of the same length and that the top and bottom lines are composed entirely of -
(0x2D) and the rest of the characters are in !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
, or is a space (). (So it's ascii value is
x
, where 31 < x < 127
)
The flag will be at least 3 tall and 3 wide.
Wave length will be a non-negative integer (>= 0).
(You can also have wave length 1 be the smallest wavelength, so the above example would have wave length 6. This is OK.)
Your i/o of flag can be as arrays of lines or a string with multiple lines.
The output flag may have trailing spaces, but can only have leading spaces so long as it is the same on every flag. Trailing space on an input flag may be deleted.
Scoring
This is code-golf, so the shortest solution, in bytes, wins.
Test cases
---
abc
---
2
--\
abc
--\
-----
| + |
-----
10
-----
| + |
-----
---------------------------------------
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& .\^/. &&&&&&|
|&&&&&& . | | . &&&&&&|
|&&&&&& |\| |/| &&&&&&|
|&&&&&& .--' '--. &&&&&&|
|&&&&&& \ / &&&&&&|
|&&&&&& > < &&&&&&|
|&&&&&& '~|/~~|~~\|~' &&&&&&|
|&&&&&& | &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
---------------------------------------
12
------------\
|&&&&&& ------------\
|&&&&&& ------------\
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& .\^/. &&&&&&|
|&&&&&& . | | . &&&&&&|
|&&&&&& . |\| |/| &&&&&&|
|&&&&&& --' '-- &&&&&&|
|&&&&&& \ /. &&&&&&|
|&&&&&& > < &&&&&&|
|&&&&&& '~|/~~|~~\|~' &&&&&&|
|&&&&&& | &&&&&&|
|&&&&&& &&&&&&|
------------\ &&&&&&|
------------\ &&&&&&|
------------\
-----------------------
|-._`-._ :| |: _.-'_.-|
| `-._`:| |:`_.-' |
|-------`-' '-'-------|
|------_.-. .-._------|
| _.-'_.:| |:._`-._ |
|-'_.-' :| |: `-._`-|
-----------------------
4
----\
|-._`----\
| `-._ :----\
|-----._`:| |: ----\
|-------`-| |:`_.-'_---
| _.--_.-' '-'_.-' .-|
|-'_.-'_.:. .-.----- |
----\-' :| |:._------|
----\| |: _`-._--|
----\ `-._ |
----\`-|
---
---------------
---------------
---------------
---------------
---------------
5
-----\
-----------\
---------------
---------------
-----\---------
-----\---
---
-------------------------------------------
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
|--------------- |
|#########################################|
| |
|#########################################|
| |
|#########################################|
-------------------------------------------
0
\
|\
|*\
| \
|** \
| *\
|** \
| ** \
|** *\
|- ** \
|#- ** \
| #-** *\
|# #- ** \
| # #- ** \
\# # #-** *\
\# # #- ** \
\# # #- **|\
\# # #-** |#\
\# # #- **| #\
\# # #- |# #\
\# # #-**| # #\
\# # #- |# # #\
\# # #-| # # #\
\# # #-# # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # |
\# # # # # #|
\# # # # # |
\# # # # #|
\# # # # |
\# # # #|
\# # # |
\# # #|
\# # |
\# #|
\# |
\#|
\|
\
4Expecting @LuisMendo to come here and blow this away within the next day or so. – Magic Octopus Urn – 2017-05-11T19:44:37.437
Crap... Forgot @ doesn't link those who haven't responded... Someone kick my butt using MATL please so I can delete the comments. – Magic Octopus Urn – 2017-05-11T20:37:22.397
2Anyone animate this – Matthew Roh – 2017-05-12T05:07:35.307
The first testcase seems to contradict this statement of yours: If you end up not being able to make a full wave length along at the end, the flag is finished. Just remain flat until the end. – user41805 – 2017-05-12T05:07:38.530
1
@SIGSEGV Done, though maybe not what you had in mind.
– Brian McCutchon – 2017-05-12T06:12:25.197@KritixiLithos So the rest of the flag (Nothing) goes down, and that nothingness stays flat. – Artyer – 2017-05-12T08:09:49.523
1@carusocomputing Did someone call me? 31 bytes, though – Luis Mendo – 2017-05-12T10:24:24.313
Is the Canadian flag example wrong? The second shifted column contains a
.
that doesnt shift with the row. – Marie – 2017-05-12T20:28:10.610@Marie It's in the column that has a \. Only the columns after the \ shift down. – Artyer – 2017-05-12T20:58:25.703
Line 9 column 27, it is directly in line with the first
-
of the last turn-downed section. – Marie – 2017-05-12T21:41:12.877@Marie Oh yeah, that's a mistake. I was looking at the wrong dot. Thanks! – Artyer – 2017-05-13T09:16:10.120
No problem. I only noticed it because my solution didnt match and diffchecker highlighted that dot – Marie – 2017-05-13T18:34:04.293