22
2
Write a program or function that, when given n
, will print a spiral n
characters long made up of the Latin alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ
repeated as needed. This spiral should run through the alphabet only forwards.
Related to Alphabet Spiral, though the spiral runs through the alphabet forwards and backwards, and the spiral is constant.
Test cases
4 AB
DC
40 UVWXYZ
TGHIJA
NSFABKB
MREDCLC
LQPONMD
KJIHGFE
0
10 GHIJ
FAB
EDC
1000 UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
TGHIJKLMNOPQRSTUVWXYZABCDEFGHIJA
SFABCDEFGHIJKLMNOPQRSTUVWXYZABKB
REZCDEFGHIJKLMNOPQRSTUVWXYZABCLC
QDYBMNOPQRSTUVWXYZABCDEFGHIJCDMD
PCXALEFGHIJKLMNOPQRSTUVWXYZKDENE
OBWZKDEFGHIJKLMNOPQRSTUVWXALEFOF
NAVYJCDMNOPQRSTUVWXYZABCDYBMFGPG
MZUXIBCLCDEFGHIJKLMNOPQREZCNGHQH
LYTWHABKBABCDEFGHIJKLMNSFADOHIRI
KXSVGZAJAZGHIJKLMNOPQROTGBEPIJSJ
JWRUFYZIZYFUVWXYZABCDSPUHCFQJKTK
IVQTEXYHYXETQRSTUVWXETQVIDGRKLUL
HUPSDWXGXWDSPUVWXYZYFURWJEHSLMVM
GTORCVWFWVCROTGHIJAZGVSXKFITMNWN
FSNQBUVEVUBQNSFABKBAHWTYLGJUNOXO
ERMPATUDUTAPMREDCLCBIXUZMHKVOPYP
DQLOZSTCTSZOLQPONMDCJYVANILWPQZQ
CPKNYRSBSRYNKJIHGFEDKZWBOJMXQRAR
BOJMXQRARQXMLKJIHGFELAXCPKNYRSBS
ANILWPQZQPWVUTSRQPONMBYDQLOZSTCT
ZMHKVOPYPONMLKJIHGFEDCZERMPATUDU
YLGJUNOXONMLKJIHGFEDCBAFSNQBUVEV
XKFITMNWVUTSRQPONMLKJIHGTORCVWFW
WJEHSLMLKJIHGFEDCBAZYXWVUPSDWXGX
VIDGRKJIHGFEDCBAZYXWVUTSRQTEXYHY
UHCFQPONMLKJIHGFEDCBAZYXWVUFYZIZ
TGBEDCBAZYXWVUTSRQPONMLKJIHGZAJA
SFAZYXWVUTSRQPONMLKJIHGFEDCBABKB
REDCBAZYXWVUTSRQPONMLKJIHGFEDCLC
QPONMLKJIHGFEDCBAZYXWVUTSRQPONMD
LKJIHGFE
Rules
- Your input will be a non-negative integer
0 <= n <= 1000
, but your code should theoretically handle any non-negative integer. - Your output format may be in any sane format, with delimiters if necessary.
- Rotations and reflections are equivalent.
- Your alphabet may be uppercase or lowercase.
- The empty spaces in your spiral may be filled in with whatever non-alphabetic nulls you see fit.
- The spiral itself may be in any shape you see fit. Rectangular spirals work best with ASCII solutions, but graphical solutions may be shorter with circular spirals.
- Leading and trailing spaces and newlines are allowed.
- This is code golf. The shortest answer in bytes (or equivalent) wins.
As always, if anything is unclear or incorrect, please let me know in the comments. Good luck and good golfing!
most editors will not allow printing out a string that long – t-clausen.dk – 2016-08-31T08:05:07.747
@t-clausen.dk I went with the standard signed 32-bit integer maximum. If you have a better suggestion for an upper bound, I'd be happy to edit it in. – Sherlock9 – 2016-08-31T08:21:34.210
Nice and tricky :-) – Joffan – 2016-08-31T21:27:14.140