Validate a stem-and-leaf plot
Perl, 47 bytes
Includes +2 for -0p
Give input on STDIN
stem.pl
:
#!/usr/bin/perl -0p
$"="*";$_=/^((??{$_+$n++})\|@{[0..9,"
"]})+$/
Pip, 60 58 + 1 = 59 bytes
First stab at the problem, probably could use more golfing. Uses the -r
flag to read lines of input from stdin. Truthy output is 1
, falsy output is 0
or empty string.
g=a+,#g&a@vNE'|NEg@v@v&$&{Y(a^'|1)a@`^\d+\|\d*$`&SNy=^y}Mg
Explanation and test suite pending, but in the meantime: Try it online!