27
1
Your input will be an English sentence, phrase, or word. It will only contain a-zA-Z' -,.!?
. Your task is to take the input, remove spaces, and then redistribute capitalization such that letters at indexes that were capitalized before (and only letters at indexes that were capitalized before) are capitalized.
For example, if the input is A Quick Brown Fox Jumped Over The Lazy Dog
, the (0-based) indexes of the capital letters are 0, 2, 8, 14, 18, 25, 30, 34, 39
. Next, remove spaces from the input: AQuickBrownFoxJumpedOverTheLazyDog
. Next, lowercase all letters, but uppercase those at 0, 2, 8, 14, 18, 25, 30, 34, 39
: AqUickbrOwnfoxJumpEdovertHelazYdog
, which is your output.
Input
Your input will be an English sentence, phrase, or word. It can only contain lowercase letters, uppercase letters, hyphens, apostrophes, commas, periods, question marks, exclamation marks, and spaces.
Output
The input with spaces removed, lowercase-d, with letters at the index of capital letters in the input uppercase-d.
NOTE: Your program cannot crash (error such execution terminates) with an IndexOutOfRange or similar error.
Test Cases
Hi! Test!
Hi!tEst!
A Quick Brown Fox Jumped Over The Lazy Dog
AqUickbrOwnfoxJumpEdovertHelazYdog
testing TESTing TeStING testing testing TESTING
testingtESTIngteStInGTEstingtestingtestiNG
TESTING... ... ... success! EUREKA???!!! maybe, don't, NOOOOO
TESTING.........success!eureKA???!!!maybe,don't,nooooo
Enter PASSWORD ---------
Enterpassword---------
A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Z z
AabbCcddEeffGghhIijjKkllMmnnOoppQqrrSsttUuvvWwxxZz
TEST
teST
Sandbox – Stephen – 2017-06-28T21:06:18.613
'For example, if the input is "A Quick Brown Fox Jumped Over The Lazy Dog", the (0-based) indexes of the capital letters are
0, 2, 8, 14, 18, 23, 27, 32
' They are0, 2, 8, 14, 18, 25, 30, 34, 39
– Luke Sawczak – 2017-06-28T21:18:40.413@LukeSawczak thank you, my bad – Stephen – 2017-06-28T21:23:39.383
Traling spaces not allowed, I assume? – Luis Mendo – 2017-06-28T21:38:12.237
@LuisMendo your assumption is correct. This is code-golf, right? :P – Stephen – 2017-06-28T21:40:12.493
Can we assume the first character won't be a space? – xnor – 2017-06-29T04:47:28.213
@xnor No, I'll add a test case. Sorry. – Stephen – 2017-06-29T12:38:55.253