Just an exploration of parsing this days input without regex.
Given the following code
c =. Parse;._2 fread 'input'
echo +/ (* #\) 12 13 14 *./@:>:"1 c
echo +/ */"1 c
... any of these Parse
subs can be used and the result should be the same
Parse =: {{
a =. (\: {:@|:) _2 ]\ 2 }. ;: ',;' -.~ y
(>./@:(".@>@{."1)/.~ ('red';'green';'blue')&i.@{:@|:) a
}}
Parse =: {{
'red green blue' =. 0 1 2
a =. ".@> 2 }. ;: ',;' -.~ y
({."1 >.//. {:"1) /:~ _2 |.\ a
}}
Parse =: {{
a =. _2 |.\ 0:`1:`2:`".@.('rgb' i. {.)@> 2 }. ;: ',;' -.~ y
({."1 >.//. {:"1) /:~ a
}}
Parse =: {{
a =. _2 |.\ 2 }. ;: ',;' -.~ y
>./ (#@>@{. "./. >@{:)&.|: \:~ a
}}
Smashed down to a 2-liner