a
a
And one final time – precedence allows us to do away with the `(
`/`)
`s – which comes down to just ***14*** bytes of “perl”y goodness.
- `
pop;
` – put the last (only) (first) parameter into `$_
` - `
/./
` – matches the first character of `$_
` and stores the result in `$&
` and more importantly stores the match to the right of this in `$'
`. The regex operator `//
` operates on `$_
` by default if no other variable specified - `
$'
` – which is the numeric part of the square - `
ord
` – get character code of first character of `$_
` – like the regex operator this works on `$_
` by default. - `
+
` – add `$'
` {the number part} to `ord
` {the numeric code of the letter} as `+
` has precedence over `&
` to get a number for each square which is ODD when light and EVEN when dark, this is done first so we DON’T need braces `(
` & `)
`. - `
&
` – bitwise and with `/\d/
` which will always be `1
` with the result of `$'+ord
` which results in getting the last (unit) bit of `$'+ord
` which is what we want.
Which gives us….
- `
pop;/./&$'+ord
`