Original: https://james-iry.blogspot.co.at/2009/05/brief-incomplete-and-mostly-wrong.html
Alain Colmerauer designed the logic programming language Prolog. His goal was to create a programming language that is as intelligent as a two-year-old child. In order to prove that he had succeeded in his goal, he presented a Prolog program that answers "No" resourcefully for all inquiries.
Ask me anything!
?-(Of course he didn't.) Your task is to create a program that is more intelligent than Alain Colmerauer's program. This does not have to be in Prolog.
Specifics
If input ends with
?
and has at least one,
, return text from the last,
until before the last?
.Else, if input ends with
?
returnNo
.Else, return
Yes
.
Rules
- No standard loopholes.
- Input/output will be taken via our standard input/output methods.
- Your program has to take at least 1 inquiry.
- You should output the processed inquiry.
- The
Yes
andNo
's are case-sensitive in the examples. - You are guaranteed that if the input includes a
?
, the input will only have one?
and it will always be the last character. - The input will always be a phrase/sentence. This phrase/sentence will never only contain the characters
,
and?
, e.g.,
,?
, and,?
are not valid inputs. (Although submissions might implement it anyway, since the phrase/sentence is an empty string in these cases.) - In addition, the input will never end with
,?
. - If there is whitespace immediately after the last
,
or immediately before the?
, they should be included in the output.
Examples
Hmm. -> Yes
Alright, -> Yes
Ask me anything! -> Yes
Ask me a question, please! -> Yes
Are you okay? -> No
No? -> No
Hey,does this program work? -> does this program work
Quotes in the following test cases should not be outputted.
They are used as a delimiter here.
Okay, so this does work ? -> " so this does work "
Please, add, a, test, case, containing, multiple, commas? -> " commas"
Scoring
This is code-golf, so shortest answer in bytes wins.
?
, there will only be one and it will always be the last character? \$\endgroup\$You are guaranteed that if the input includes a ?, the input will only have one ? and it will always be the last character.
Therefore these test cases are unneccecary. \$\endgroup\$ends with ,?
a valid input? \$\endgroup\$