,['0.]v*1['1.]v*']<[:,>!]v*' <:' >,<:,>!
Try It Online!
This program accepts strings similar to this one:
"[2 8 1 6 4]"
and prints either '1' or '0' to stdout, with no newline.
Explanation
,['0.]v*1['1.]v*']<[:,>!]v*' <:' >,<:,>!
,['0.]v*1 First we take and ignore the first input
character '[', and create an interpreter
for which the default operation is to print
['1.]v*']< '0'. Next we bind the operation "print '1'"
to the symbol ']' under this interpreter.
[:,>!]v* Now we push an operation that takes a symbol
from stdin, extracts the operation associated
with that symbol from the interpreter on the
stack, and executes it.
' < We now bind this operation to the space
:' > character. Immediately, we extract the
operation back out of the interpreter, and
,< bind it to the next symbol from stdin, which
is the first number in the list. Finally, we
:,>! manually execute the function once, to begin
the cycle. Now, the interpreter will continue
to take input until it receives a symbol that
is neither space nor the first number. The
program will print '1' if that symbol is ']',
otherwise it will print '0'.
I wrote a solution in 36 characters, however the input/output format is inconvenient enough that I don't think it qualifies:
,[$.]v*1['1.]v*']<[:,$,>!]v*,<:,$,>!
It takes strings similar to this:
"[2 8 1 6 4 ]"
and prints '1' if the items are all equal, and '[' otherwise.
As Mascarpone is character-set-agnostic (provided the set contains the 17 symbols used by the initial interpreter) and only 26 unique characters are needed for this program to succeed (the 17 original instructions, the space character, and the characters 2-9), we require only 5 bits per character. By this logic, the solutions would be 25 bytes and 22.5 bytes in size, respectively.
Input and output can be taken/given in any reasonable and convenient format
, that's pretty standard for more trivial challenges \$\endgroup\$'3'
instead of number3
; or producing the output via program exit code. What I mean is what options for output are allowed: two consistent values? Non-consistent truthy/falsy? One consistent value for truthy and any inconsistent values for falsy? \$\endgroup\$