As a couple of people may have noticed lately, I've largely abandoned development of Braingolf because it's boring and uninspired, and moved on to 2Col which is a little more interesting, and not designed to be a golfing language.
The defining feature of 2Col is that every line of code must be exactly 2 characters long, excluding the newline. This means that the length of a 2Col program can always be calculated as 3n-1
where n
is the number of lines in the program.
So here's my challenge: Given 2Col code as a string, output truthy if it is valid 2Col code (Every line is exactly 2 characters and it conforms with the 3n-1
formula), and falsey otherwise.
Input
Input should be taken as a single string, or an array of characters.
Output
A truthy value if the input string is valid layout, and a falsey value otherwise.
Your code should be consistent in which truthy/falsey values it uses
Testcases
======
F!
$^
----
truthy
======
======
*8
+1
Sq
----
truthy
======
======
nop
xt
----
falsey
======
======
+1
+1
#^
----
falsey
======
======
<empty string>
----
falsey
======
======
ye
----
truthy
======
======
no<space>
----
falsey
======
======
test
----
falsey
======
======
puzzle
----
falsey
======
Scoring
This is code-golf so fewest bytes wins!
true
falsey andfalse
truthy \$\endgroup\$ – Skidsdev May 25 '17 at 18:13puzzle
. This will make solutions that do the whole length of the string modulo 3, then negated (which works for all the current test cases) invalid. \$\endgroup\$ – Comrade SparklePony May 25 '17 at 19:41