13
Challenge
¡We're going to give exclamation and question marks inverted buddies!
Given a body of text containing sentences ending in .
, ?
, or !
, prepend inverted question marks, ¿
, to interrogative sentences (sentences ending in ?
) and inverted exclamation marks, ¡
, to exclamatory (sentences ending in !
). Sentences ending in .
are to be ignored.
Sentences will be separated by whitespace (spaces, tabs, and/or newlines) and will only contain alphanumerics, commas, apostrophes, and spaces. Every sentence will have at least one word. The first word of every sentence is guaranteed to be capitalized. Input can start and end with any whitespace.
Example
Input:
Hello there! What is your name?
My name is Ron. What's your name?
My name is Alex. Nice to meet you!
Nice to meet you to! How was your break?
It was great, I spent all my time code golfing!
What's that?
Wow, you're such a n00b! Here, let me show you.
Output:
¡Hello there! ¿What is your name?
My name is Ron. ¿What's your name?
My name is Alex. ¡Nice to meet you!
¡Nice to meet you to! ¿How was your break?
¡It was great, I spent all my time code golfing!
¿What's that?
¡Wow, you're such a n00b! Here, let me show you.
Rules
- All default Code Golf rules apply.
- The program with the shortest amount of bytes wins.
Bonus (17% off) - Parse multiple marks
A sentence can also end in multiple exclamation/question marks. Give each of these marks a paired inverse exclamation/question mark for an extra 17% off your byte count.
Example
Input:
I am a man in a can doing a dance?? Maybe...
Doing it for the views??!???!
Output:
¿¿I am a man in a can doing a dance?? Maybe...
¡¿¿¿¡¿¿Doing it for the views??!???!
Incorrect output:
¿¿I am a man in a can doing a dance?? Maybe...
¿¿¡¿¿¿¡Doing it for the views??!???!
Do we get to choose what sort of whitespace separates the sentences, or do we have to support all 3 types? – Mego – 2015-12-04T09:00:56.043
@Mego All three types should be supported. – usandfriends – 2015-12-04T09:01:24.227
No, a sentence will always have at least one word in it and will end with one of the three allowed punctuation characters. I'll add that to the challenge. – usandfriends – 2015-12-04T09:04:11.243