Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
{+/2!0N 2#0,x^"_"}
Try it online!
{ } function with argument x
{
}
x
x^"_" remove all _s
x^"_"
_
0, prepend a 0
0,
0
0N 2# split in pairs
0N 2#
2! mod 2 (asas ascii codes): P→80→0, o→111→1, ~→126→0
2!
P
o
~
+/ sum
+/
2! mod 2 (as ascii codes)
2! mod 2 as ascii codes: P→80→0, o→111→1, ~→126→0
{$[~2=#x:"P"\x^"_";`error;|//^x:2#',+/2!0N 2#/:"o~"?x;`error;+/x]2#0,x^"_"}
Try it online!Try it online!
{$[~2=#x:"P"\x^"_";`error;|//^x:2#',/0N 2#/:"o~"?x;`error;+/x]}
{$[|$[~2=#x:"P"\x^"_";`error;|//^r^x:2#',/0N 2#/:2^"o~""o~"?"P"\x^"_";`error;+x;`error;+/r]x]}
{$[|//^r:2#',/0N 2#/:2^"o~"?"P"\x^"_";`error;+/r]}