Given an input number
25), output the alphabet reading left-to-right up to and including that corresponding letter, with
a=1, b=2, c=3, .... The twist is the letters must also be repeated vertically corresponding to their position in the alphabet. Odd numbers (when
1-indexed) should be balanced across the horizontal line, while even numbers should alternate between favoring the top or bottom (you can choose which direction to go first). If you're 0-indexing, then swap odd/even in the previous sentence.
Worded another way -- if the alphabetical value of a letter
#, then there should be
# copies of that letter in the output, all of them in the
#th column. These letters should be evenly balanced above and below the horizontal line that has the
a. If the letters cannot be balanced evenly, then alternate having the "extra" letter above and below that line.
Here are the first six outputs (
n = 1,2,3,4,5,6, 1-indexed, choosing to alternate to the bottom first), separated by newlines, so you can see the pattern. Comments explaining the pattern start with
a # On a line by itself ab b # The "extra" letter is below the horizontal c abc # The 'c' splits evenly bc d # Because the 'b' was below, the extra 'd' must be above cd abcd bcd de cde abcde # The 'e' balances bcde e def cdef abcdef bcdef ef f # Since the 'd' was above, the extra 'f' must be below
(skip a few to
xyz wxyz tuvwxyz stuvwxyz pqrstuvwxyz opqrstuvwxyz lmnopqrstuvwxyz klmnopqrstuvwxyz hijklmnopqrstuvwxyz ghijklmnopqrstuvwxyz defghijklmnopqrstuvwxyz cdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz bcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz fghijklmnopqrstuvwxyz ijklmnopqrstuvwxyz jklmnopqrstuvwxyz mnopqrstuvwxyz nopqrstuvwxyz qrstuvwxyz rstuvwxyz uvwxyz vwxyz yz z
- You can choose to output in uppercase or lowercase, but it must be consistent.
- The output cannot have extraneous whitespace, except for an optional trailing newline.
- Either a full program or a function are acceptable.
- The input number can be taken via any suitable format.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.