PowerShell v3+, 60 78 67 bytes
-join(65..90|%{[char]$_+'.,'[$_-le89]+" "+"`n"*($_-in71,80,83,86)})
OK. I've actually read, understood, and followed the spec this time. Promise. :D
Takes the array 65..90
and loops over each element |%{...}
. Each iteration, we're constructing a new string using concatenation, indexing, and multiplication.
First, we take the current number and char
cast it to make it an ASCII letter. That's concatenated with another char, based on indexing into the string '.,'
whether we're at 90
or not (i.e., to account for Z.
while having all the rest be commas). That's string concatenated with " "
to space-separate the letters, and string multiplication of "`n"
based on Boolean value for whether the current element is -in
the specified array (i.e., whether we need to concatenate on a newline character). The resulting string is left on the pipeline.
Those strings are encapsulated in parens, and -join
ed together into a new string, which is then also left on the pipeline and implicit Write-Output
at the end prints the result. Since we have `n
in the string, it's automatically converted to newlines upon printing.
Requires v3+ for the -in
operator. Has a trailing space on each line, which is OK per the challenge specs.
Example
PS C:\Tools\Scripts\golfing> .\now-i-know-my-abc.ps1
A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.
/(?=[HQTW])/
\$\endgroup\$H, I, J, K, LMNO, P
? \$\endgroup\$