Skip to main content
2 of 2
explaining the code

Common Lisp, 170 bytes

(let ((r "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))(loop for i from 1 to 51 do(let ((l (subseq r 0 (- i (* 2 (- i 26) (floor i 26))))))(format t "~a~a~%" l (subseq (reverse l) 1)))))

Run it: TIO here.

Formatted:

(let ((r "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
  (loop for i from 1 to 51
    do(let ((l (subseq r 0 (- i (* 2 (- i 26) (floor i 26))))))
      (format t "~a~a~%" l (subseq (reverse l) 1)))))

Breakdown:

  • (let ((r "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) - variable r holds string range of all characters
  • variable l holds a substring from the r of length based on the line number, where l = r[0:i - (2 * (i - 26) * i % 26)] ... (2 * (i - 26) * i % 26) this part ensures the i to be this sequence 0...26...0
  • format prints the l string and its reversed counter part with skipped first letter (to avoid ABBA, ABCCBA , etc.)