##PowerShell, 162 bytes
PowerShell, 162 bytes
function f{param($f)-join([char[]](65..90)+(0..5))[[convert]::ToInt32(-join($f|%{+($_-cmatch'[A-Z]')}),2)]}
($a=$args[0])+(f $a[4..0])+(f $a[9..5])+(f $a[14..10])
OK, a lot of neat stuff happening in this one. I'll start with the second line.
We take input as a string via $args[0]
and set it to $a
for use later. This is encapsulated in ()
so it's executed and the result returned (i.e., $a
) so we can immediately string-concatenate it with the results of three function calls (f ...)
. Each function call passes as an argument the input string indexed in reverse order chunks as a char-array -- meaning, for the example input, $a[4..0]
will equal @('0','E','R','0','a')
with each entry as a char, not a string.
Now to the function, where the real meat of the program is. We take input as $f
, but it's only used way toward the end, so let's focus there, first. Since it's passed as a char-array (thanks to our previous indexing), we can immediately pipe it into a loop with $f|%{...}
. Inside the loop, we take each character and perform a case-sensitive regex match with -cmatch
which will result in true/false if it's uppercase/otherwise. We cast that as an integer with the encapsulating +()
, then that array of 1's and 0's is -join
ed to form a string. That is then passed as the first parameter in the .NET [convert]::ToInt32()
call to change the binary (base 2
) into decimal. We use that resultant decimal number to index into a string (-join(...)[...]
). The string is first formulated as a range (65..90)
that's cast as a char-array, then concatenated with the range (0..5)
(i.e., the string is "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
). All of that is to return the appropriate character from the string.