# Alphabet Rain

The basic premise is to print out the input string and then repeat each character vertically, based on it's (0-indexed) position in the (case-insensitive) alphabet A-Z. A is at location 0 so is not repeated, e is at position 4 so is repeated 4 times, P is at position 15 so is repeated 15 times, ! is not in A-Z so is repeated 0 times, etc.

For clarity, anything that falls outside of the range B-Zb-z, for example digits or special characters, will not be repeated, and thus will only appear on the first line.

This is , so shortest solution in each language is the winner.

## Input:

• Input will be in the standard printable ASCII character set, from 32   up to 126 ~.
• The input string will be 1 character long or longer.
• There will not be any leading or trailing whitespace.
• You can take take input as a string ("hello") or list of characters ( ["h", "e", "l", "l", "o"])

## Examples:

Input of aaaa gives:

aaaa


Input of abcda gives:

abcda
bcd
cd
d


Input of Programming Puzzles & Code Golf!, gives:

Programming Puzzles & Code Golf!
Progr mming Puzzles   Code Golf
Progr mming Puzzles   Code Golf
Progr mming Puzzles    ode Golf
Progr mming Puzzles    o e Golf
Progr mming Puzzl s    o   Golf
Progr mming Puzzl s    o   Gol
Pro r mmin  Puzzl s    o    ol
Pro r mmin  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzz  s    o    o
Pro r    n  Puzz  s    o    o
Pro r       Puzz  s    o    o
Pr  r       Puzz  s
r  r        uzz  s
r  r        uzz  s
uzz  s
uzz
uzz
zz
zz
zz
zz
zz


Input of ~|[abc<0>cba]|~, gives:

~|[abc<0>cba]|~
bc   cb
c   c


## Notes:

• standard loopholes apply
• output can be a list of strings, but:
• extraneous trailing newlines are not allowed (single \n on final line is acceptable)
• output can be a list of lists of characters, so long as it looks like it's raining characters
• to our Nordic users who have a few extra letters in their "A-Z" alphabet, feel free to support them, but it's not part of the challenge
• Is a single leading \n acceptable? – Lynn Oct 10 '17 at 12:01
• @Lynn, no leading newlines, the first line should be the input string/character list - I'll update the post! – streetster Oct 10 '17 at 14:25
• FWIW, I think they look more like icicles than rain – caird coinheringaahing Oct 10 '17 at 18:39
• @cairdcoinheringaahing sounds almost festive – Pureferret Oct 11 '17 at 17:02
• :( Just Nordic? – ASCII-only Oct 12 '17 at 3:10

# QBIC, 141 bytes

_L;|dim g(a)┘dim H(a)[a|_SA,b,1|┘H(b)=B┘o=asc(ucase$(B))-65~o<1or o>25|o=0]g(b)=o~g(b)>p|p=g(b)}?A[p|[a|~g(d)|g(d)=g(d)-1\H(d)=@ ]?H(d)';]?  Wow, this has to be the longest entry I've made using QBIC... ## Explanation _L | Assign to num var 'a' the length of ; A$, which is read off the CMD line
dim g(a)                    Define 'g' as an array of 'a' slots. The lower-
case letter denotes it will store numbers.
g() will store if we still need to rain down the char at pos ()
of the input string.
┘                           Inject a linebreak in the compiled QBasic
dim H(a)                    Define H$to be an array, also of length 'a', for strings H$(x) will store what to rain down if g(x) > 0
[a|                         Run along the length of the input string
(QBasic: FOR b = 1 TO a STEP 1)
_SA,b,1|┘                 Take a substring at index b on string A$, length 1 and store as B$; lift out each character one at a time
H(b)=B┘                   Save the character in H$(x) o=asc(ucase$(B))-65       Take the ASCII codepoint of that substring, as uppercase
minus 65. [A-Z] maps to 0-25. Save that number as 'o'
~o<1or o>25               IF o is not in range
|o=0]                     THEN set o to zero (the same value as 'A/a')
g(b)=o                    SET the number of rain-down copies to 'o'
~g(b)>p                   IF the number of raindowns exceeds the prvious max,
|p=g(b)                   THEN store the new max into 'p'. This defines the rain-down depth
}                           END IF, NEXT
?A                          PRINT the original, \n
[p|                         FOR c = 1 TO max-depth
.
; gsub("[\($x)]";" ") # apply each pattern to input ; . ) | select(.!=length*" ") # eliminate blank lines  Try it online! # SNOBOL4 (CSNOBOL4), 181 bytes  S =OUTPUT =INPUT U =&UCASE L =&LCASE Z S NOTANY(U L ' ') =' ' :S(Z) N U LEN(1) . X REM . U L LEN(1) . Y REM . L R S (X | Y) =' ' :S(R) S NOTANY(' ') :F(END) OUTPUT =S :(N) END  Try it online!  S =OUTPUT =INPUT ;* read input and print it U =&UCASE ;* alias for uppercase letters L =&LCASE ;* alias for lowercase letters Z S NOTANY(U L ' ') =' ' :S(Z) ;* replace non-alphabet, non-space characters with space N U LEN(1) . X REM . U ;* get the Next uppercase letter L LEN(1) . Y REM . L ;* get the Next lowercase letter R S (X | Y) =' ' :S(R) ;* replace all those with spaces S NOTANY(' ') :F(END) ;* if S is all spaces, terminate the program OUTPUT =S :(N) ;* else print S and goto N END  # Stax, 12 bytes î┌→♠─l∙╨"«Pò  Run and debug it # Julia 1.0, 97 bytes f(s,h=c->isletter(c)&&(c-'A')%32)=println.([s;[map(c->h(c)>i ? c : ' ',s) for i=0:maximum(h,s)]])  Try it online! • This only prints one b, 2 c etc, think you need a +1 or something somewhere :) – streetster Aug 7 '19 at 5:52 • Change the A to an @ tio.run/… – streetster Aug 7 '19 at 5:57 • Should be fixed now – Simeon Schaub Aug 7 '19 at 10:06 # Assembly (MIPS, SPIM), 319 bytes .text .globl main main: lw$4 4($5) li$2 4
syscall
li $9 65 li$11 91
li $14 122 move$12 $4 li$2 11
syscall
g:
li $4 10 syscall addi$9 1
bge $9$11 n
addi $8$12 -1
l:
addi $8 1 lb$4 ($8) beqz$4 g
blt $4$9 e
blt $4$11 f
addi $13$9 32
blt $4$13 e
bgt $4$14 e
f:
syscall
j l
e:
li $4 32 j f n: li$2 10
syscall


Try it online!

almost positive this can be golfed further, (might be able to use mod instead of a bunch of branches, idk) but i'm not complaining. Takes the string as a command line argument. most of the registers are used for magic ascii numbers, though $9 and$8 update - $9 is the current iteration, starting at 65 (a).$8 starts at the beginning of the string, then iterates over the string until reaching a null terminator. characters that are no longer valid are replaced with '32' or space. Prints a single trailing newline, on the last line.

The output is padded - that is, if the input string is 5 characters long, each printed row will also be 5 characters long, even if this means the last few bytes in a row are space characters. or more practically: "Faa"=>
"Faa" "F " "F " "F " "F " "F "
The instructions did not specify if we had to trim each row to the shortest possible or if this behavior was allowed. If the trimmed variant is desired I can mark this non-competing.

• one cool aside: flipping the contents of e and f in the code will result in [stalagmites](tio.run/… " - the code will print the line at the top, then grow from the bottom up, as if the text dripped down to the ground and built up over time. Did that by accident first and wondered what I did wrong. – Andrew Baumher Sep 5 '19 at 15:08
• Nice! No requirement to trim the strings so all good on that front :) – streetster Sep 5 '19 at 17:27

# PHP 7, 110 Bytes

$t.=" ";for($i=66;$i<90&&trim($t);){echo$t;$t=preg_replace('~[^\n'.chr($i).'-Z'.chr(32+$i++).'-z]~', ' ',$t);}  Try it online ## Ungolfed Input given in$t

$t.=" "; for($i=66;$i<90&&trim($t);){
echo$t;$t=preg_replace('~[^\n'.chr($i).'-Z'.chr(32+$i++).'-z]~', ' ',\$t);
}

• nice answer. Do host it on tio.run so people can verify your answer. – Razetime Oct 18 at 12:16
• @Razetime; Thanks foir the feedback. Done. @Titus: Thanks for showing a simpler alternative to tio.run. :) – Zsolt Szilagy Oct 18 at 12:19

# Pip, 23 bytes

PaFi,26P{z@?LCa>i?as}Ma


Try it online!

## Explanation

PaFi,26P{z@?LCa>i?as}Ma
Pa                      Print the original string
Fi,26                 loop with variable i across range 0-26
Ma Map the input to the following function
{z@?LCa>i?as}   Replace any symbols with index lesser than i with a space
P                Print the mapped string


# Husk, 15 bytes

T' m?SRȯ-64ca;√
`

Try it online!