11
2
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!
@Shaggy no, not unless for some reason the language you use considers
true
falsey andfalse
truthy – Skidsdev – 2017-05-25T18:13:40.7301@StephenS Will do – Skidsdev – 2017-05-25T18:13:49.003
@Mayube thanks, sorry, I forgot to add "could you" in front of that xD – Stephen – 2017-05-25T18:21:23.103
I suggest you add a test case:
puzzle
. 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. – Comrade SparklePony – 2017-05-25T19:41:42.613@ComradeSparklePony will do – Skidsdev – 2017-05-25T21:10:46.210
Do you require the 2 output values to be consistent? – Shaggy – 2017-05-26T07:25:39.510
Just curious, is there a way to define new functions in 2Col? – clismique – 2017-05-26T09:57:45.317
@Qwerp-Derp not yet, I'm planning to add a feature that will allow you to jump to another line, and then another that will allow you to jump back, meaning you could define functions that way – Skidsdev – 2017-05-26T10:00:15.317
Isn't
from functools import reduce;
unnecessary? And also... semicolons? – Esolanging Fruit – 2017-05-30T07:25:00.637