11
Challenge
Hi, given a string as input, remove any salutations found at the start of the string.
The program which performs the most correct substitutions in under 50 bytes wins.
Salutations
Hey, a salutation is defined as one of the following words:
- hi
- hey
- hello
- dear
- greetings
- hai
- guys
- hii
- howdy
- hiya
- hay
- heya
- hola
- hihi
- salutations
The first letter may be capitalised.
There will always be a comma and/or a single space following the salutation which must also be removed. The comma and the space may be in any order (,<space>
or <space>,
) and both should be removed.
The greeting and the following word will only ever be separated by a comma and/or single space.
You must then capitalise the first letter of the word which would have followed the salutation. Even if no replacement has taken place, you should still capitalise the first word of the output.
Capitalisation only applies to lowercase alphabetical characters (abcdefghijklmnopqrstuvwxyz
). You should leave any other character as it was.
The salutation will always be at the start of the string. You should not replace a salutation which is not at the start.
There may not always be a salutation.
Your code must be under 50 bytes.
Examples
Input > Output
Salutations, what's going on? > What's going on?
hello i have quetions how does juice an avocado > I have quetions how does juice an avocado
How d'you do > How d'you do
Hey,You! > You!
hola cows eat hay > Cows eat hay
hey Hi there! > Hi there!
hihi ,guys > Guys
Test battery
Hola, there are 1000 different inputs in total:
The test battery can be found here where each input is separated by a newline: https://github.com/beta-decay/Remove-Substitutions-Battery/blob/master/inputs.txt
The corresponding correct outputs are here: https://github.com/beta-decay/Remove-Substitutions-Battery/blob/master/replaced.txt
A Bash command to retrieve both the above is
wget https://raw.githubusercontent.com/beta-decay/Remove-Substitutions-Battery/master/{inputs,replaced}.txt
Winning
Howdy, the program with the most correct substitutions from the 1000 inputs above wins.
You must put the percentage of the inputs your program handles correctly in your header like so:
# Language Name, percentage%
I'm not completely sure why Jeff made this a thing, but it makes a nice challenge nevertheless.
3
s=>System.Text.RegularExpressions.Regex.Replace();
50 bytes before even a pattern is specified, that's C# out then. (With a regex approach of course) – TheLethalCoder – 2017-05-30T12:01:18.5001Python is also out (with regex) :( – Gábor Fekete – 2017-05-30T12:50:15.643
You can always return the given input for a score of 31.3%. – Ian Miller – 2017-05-30T15:57:18.443
Urge to edit out the salutation at the beginning of the challenge rising. ;) – Draco18s no longer trusts SE – 2017-05-30T17:02:38.547
2
Fun anecdote: I originally started my first post on PPCG with "Hello, world! :)" but noticed as soon as I posted it that SE removed the entirety of that line except the ":)". I was of course mortified that I had done something wrong and immediately removed the smiley as well. Not a trace was left in the revision history, and to this day you and I are the only ones who know about it...
– ETHproductions – 2017-05-30T17:03:12.907@ETHproductions That was your first post? Wow, I congratulate you :D – Beta Decay – 2017-05-30T17:04:57.217