|
|
|
|
|
by elcaro
1673 days ago
|
|
Just for fun, I tried it in Raku. say qx< cal -hy > # Command output as string
.lines.skip.join("\n").split(/\n\n+/) # Skip year & split groups
.map({ |([Z] .lines.join.comb(22).batch(3)) }) # Single column structure
.map({ |(.[2] ~ .[0].trim, |.[3 .. *]) }) # Month name on first row
.grep(*.trim.chars).join("\n") # Join non-blank lines
.subst(/\s+ ^^ \s\s+ 1»/, ' 1', :g) # Collapse weeks together
I was never going to beat APL... Though I imagine some clever Rakoons could probably find a few places where this can be golfed down. |
|