Back
Close

Alphabetic precedence

Statement

 Goal

Given a string s, for every word, output a number for each letter, representing its precedence in the alphabet (i.e. "foo" will be "122" because in the alphabet the letter "f" is found 1st, then "o" will be found 2nd), while keeping non-alphabetic characters as is.
Input
Line 1: The string s of words separated by a single space, made of different alphabetic and non-alphabetic characters.
Output
Line 1: The result string where the alphabetic characters are replaced by their corresponding numbers for every word.
Constraints
1 <= size of s <= 1000
Example
Input
foo
Output
122

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
foo
Output
122

Validator 1 Validator
Input
rar
Output
212

Test 2 Test
Input
bar
Output
213

Validator 2 Validator
Input
zip
Output
312

Test 3 Test
Input
f0o BAr
Output
102 213

Validator 3 Validator
Input
r4r ZIp
Output
141 312

Test 4 Test
Input
abcde fghij klmno pqrst uvwxyz zyxwvu tsrqp onmlk jihgf edcba abcdefghijklmnopqrstuvwxyz
Output
12345 12345 12345 12345 123456 654321 54321 54321 54321 54321 1234567891011121314151617181920212223242526

Validator 4 Validator
Input
uvwxyz pqrst klmno fghij abcde edcba jihgf onmlk tsrqp zyxwvu zyxwvutsrqponmlkjihgfedcba
Output
123456 12345 12345 12345 12345 54321 54321 54321 54321 654321 2625242322212019181716151413121110987654321

Test 5 Test
Input
Hippopotomonstrosesquippedaliophobia
Output
561111101110151081091415131014414121661111431761011510261

Validator 5 Validator
Input
Pneumonoultramicroscopicsilicovolcanoconiosis
Output
9731368781351210164210811289421145428148521782874811411

Test 6 Test
Input
I did not hit her, it’s not true! It’s bullshit! I did not hit her! I did not! Oh hi Mark.
Output
1 121 123 123 213, 13’2 123 3241! 13’2 17445236! 1 121 123 123 213! 1 121 123! 21 12 3142.

Validator 6 Validator
Input
I got the results of the test back, and I definitely have breast cancer! Look, don't worry about it. Everything will be fine.
Output
1 123 321 3146254 21 321 3123 2134, 132 1 1234647258 3142 243156 214235! 2331, 132'4 31224 12354 12. 1816973452 3122 12 2341.

Test 7 Test
Input
Cecilia Chapman, 711-2880 Nulla St., Mankato Mississippi 96522, (257) 563-7401
Output
2324541 2316415, 711-2880 34221 12., 3142165 21441441331 96522, (257) 563-7401

Validator 7 Validator
Input
Iris Watson, P.O. Box 283 8562 Fusce Rd., Frederick Nebraska 20620, (372) 587-2335
Output
1213 615432, 2.1. 123 283 8562 35412 21., 473237516 53261741 20620, (372) 587-2335

Solution language

Solution

Stub generator input