15
1
Scenario
I often cook lasagne, but I also have a few mistakes. Since I repeat these faults so often, I thought I maybe could do a program that checks if I did everything right.
Valid lasagne
A valid lasagne is
- At least 5 columns wide
- At least 4 layers high
- Excluding extra cheese
- The top layer is cheese (represented by
,
) - The second layer is sauce (represented by either
@
or#
) - After that the layers alternate (1 layer sauce, 1 layer noodles (represented by either
~
or-
)) - Each column can have either one or two layers of cheese
The program
Should
- take a lasagne string as input
- multiline string
- string array
- the string only contains the chars
,@#~-
- Rectangular
- Padded with spaces if necessary
- Output whether it's a valid lasagne
- Any thing that's thruthy in your language if valid
- Nothing or anything that's falsy in your language
- be either
- a full program
- a function
- that only uses functionality that was implemented before the 14.12.2016
Test cases
,, ,
,,,,,,
@@@###
~~~~~-
@##@@#
--> truthy
@@@#
----
@@##
----
@###
--> falsy (cause of cheese and width (You don't have to print the stuff in the brackets))
,,,,,
-----
@####
-----
@@@@@
--> falsy (have the sauce as last layer)
Winning criteria
The
- shortest
- in bytes
- code-golf
- functional
submission wins.
13Please close that parenthesis. – Quentin – 2016-12-14T16:40:34.123
Question: Does it need to be horizontally rectangular? i.e. what if it is 10 rows high and 9 columns wide? – Ruslan – 2016-12-14T17:31:08.933
The spec says it can only
,@#~-
with the exception of spaces as padding, but the first test case contains spaces in the middle of a line. – feersum – 2016-12-14T19:06:46.763@feersum "Padded with spaces if necessary" – UKMonkey – 2016-12-15T11:42:04.293