Inquiry answererTips for golfing in 05AB1EFlippin' SquaresProgram your favorite phraseReverse sentencesPrint some JSONFind the original string, without the repetition without the repetition in the middleRemove Spaces, Maintaining CapitalizationRest of the path
What was the earliest microcomputer Logo language implementation?
Is it possible that the shadow of The Moon is a single dot during solar eclipse?
What are A and A* conference ranks?
What is the maximum viable speed for a projectile within earth's atmosphere?
Delete empty subfolders, keep parent folder
Why are two-stroke engines nearly unheard of in aviation?
Where did Otto von Bismarck say "lying awake all night, hating"?
In Bb5 systems against the Sicilian, why does White exchange their b5 bishop without playing a6?
Why has the UK has not yet signed a continuity trade agreement with Turkey?
Who are the people reviewing far more papers than they're submitting for review?
Microservices and Stored Procedures
Floating Point XOR
How do you determine which representation of a function to use for Newton's method?
MySQL - How to check for a value in all columns
Plausibility and performance of a composite longbow
What is Cousin Itt in The Addams Family?
Python web-scraper to download table of transistor counts from Wikipedia
Exam design: give maximum score per question or not?
What is this WWII four-engine plane on skis?
Resampling 1000m resolution Aqua MODIS images to 30m resolution
Why do IXPs need ASN?
How to convert String to DateTime without time zone conversion?
How do we know that black holes are spinning?
How to make classical firearms effective on space habitats despite the coriolis effect?
Inquiry answerer
Tips for golfing in 05AB1EFlippin' SquaresProgram your favorite phraseReverse sentencesPrint some JSONFind the original string, without the repetition without the repetition in the middleRemove Spaces, Maintaining CapitalizationRest of the path
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
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.) - 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.
code-golf string
$endgroup$
|
show 3 more comments
$begingroup$
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.) - 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.
code-golf string
$endgroup$
5
$begingroup$
Are we guaranteed that if the input includes a?
, there will only be one and it will always be the last character?
$endgroup$
– Shaggy
7 hours ago
2
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
4
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
2
$begingroup$
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$
– A _
3 hours ago
1
$begingroup$
Isends with ,?
a valid input?
$endgroup$
– GammaFunction
1 hour ago
|
show 3 more comments
$begingroup$
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.) - 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.
code-golf string
$endgroup$
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.) - 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.
code-golf string
code-golf string
edited 3 hours ago
Veskah
2,2475 silver badges24 bronze badges
2,2475 silver badges24 bronze badges
asked 8 hours ago
A _A _
1,9375 silver badges26 bronze badges
1,9375 silver badges26 bronze badges
5
$begingroup$
Are we guaranteed that if the input includes a?
, there will only be one and it will always be the last character?
$endgroup$
– Shaggy
7 hours ago
2
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
4
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
2
$begingroup$
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$
– A _
3 hours ago
1
$begingroup$
Isends with ,?
a valid input?
$endgroup$
– GammaFunction
1 hour ago
|
show 3 more comments
5
$begingroup$
Are we guaranteed that if the input includes a?
, there will only be one and it will always be the last character?
$endgroup$
– Shaggy
7 hours ago
2
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
4
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
2
$begingroup$
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$
– A _
3 hours ago
1
$begingroup$
Isends with ,?
a valid input?
$endgroup$
– GammaFunction
1 hour ago
5
5
$begingroup$
Are we guaranteed that if the input includes a
?
, there will only be one and it will always be the last character?$endgroup$
– Shaggy
7 hours ago
$begingroup$
Are we guaranteed that if the input includes a
?
, there will only be one and it will always be the last character?$endgroup$
– Shaggy
7 hours ago
2
2
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
4
4
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
2
2
$begingroup$
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$
– A _
3 hours ago
$begingroup$
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$
– A _
3 hours ago
1
1
$begingroup$
Is
ends with ,?
a valid input?$endgroup$
– GammaFunction
1 hour ago
$begingroup$
Is
ends with ,?
a valid input?$endgroup$
– GammaFunction
1 hour ago
|
show 3 more comments
17 Answers
17
active
oldest
votes
$begingroup$
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
$endgroup$
add a comment
|
$begingroup$
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
$endgroup$
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
add a comment
|
$begingroup$
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'
$endgroup$
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
add a comment
|
$begingroup$
Charcoal, 23 22 bytes
¿№θ?¿№θ,⁻⊟⪪θ,¦?¦No¦Yes
Try it online! Link is to verbose version of code. Edit: Saved 1 byte thanks to @KevinCruijssen. Explanation:
¿№θ?
Does the string contain any ?
s?
¿№θ,
Does it contain any ,
s?
⊟⪪θ,
Split the string on ,
s and take the last.
⁻...?
Delete the ?
and output the result.
No
If there are no ,
s then output No
.
Yes
If there are no ?
s then output Yes
.
$endgroup$
$begingroup$
-1 changingPrint(Join(Split(Pop(Split(q, ",")), "?"), w)
toPrint(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten thatMinus
did that. Besides, I was feeling pleased with myself for saving two separators.
$endgroup$
– Neil
1 hour ago
add a comment
|
$begingroup$
Perl 5 + -plF/,|?/
, 27 bytes
$_=/?$/?/,/?$F[$#F]:No:Yes
Try it online!
$endgroup$
add a comment
|
$begingroup$
Retina, 32 bytes
.+[^?]$
Yes
.+,(.*)?
$1
.+?
No
Try it online.
Explanation:
Replace any input not ending with "?" with Yes
:
.+[^?]$
Yes
Replace any input containing a comma and ending with a "?" with the part between the comma and the "?" (captured in capture group 1):
.+,(.*)?
$1
Replace any other input ending with a "?" with No
:
.+?
No
32 bytes alternative:
^/?/K`Yes
.+,(.*)?
$1
/?/K`No
K
tip thanks to @Neil.
Try it online.
Explanation:
The three steps are the same as above, but the K
only looks at a partial match (?
in this case). The ^
in the first line means a reverse, so if the input doesn't contain a ?
it replaced it with Yes
. And if the string does (still) contain a ?
at the last line, it replaces it with No
.
$endgroup$
$begingroup$
Did you know that Retina 1'sK
stage has a built-in conditional? I didn't. It could probably save you a few bytes.
$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain theK
and conditional&
to be completely honest. I know how to useK
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for theYes
/No
?
$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any?
must be at the end.
$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
add a comment
|
$begingroup$
PHP, 58 bytes
<?=$argn[-1]=='?'?substr(strrchr($argn,','),1,-1)?:No:Yes;
Try it online!
$endgroup$
$begingroup$
PrintsNo
instead of the empty string in cases ending with,?
.
$endgroup$
– GammaFunction
1 hour ago
add a comment
|
$begingroup$
Red, 78 bytes
func[s][r:"Yes"parse s[to","copy t to"?"(r: last split t",")| to"?"(r:"No")]r]
Try it online!
$endgroup$
add a comment
|
$begingroup$
Perl 6, 40 bytes
Try it online!
$endgroup$
add a comment
|
$begingroup$
IBM/Lotus Notes Formula, 79 bytes
@If(@Ends(i;"?");@If(@Contains(i;",");@Left(@RightBack(i;",");"?");"No");"Yes")
No TIO for Formula so...
$endgroup$
add a comment
|
$begingroup$
Pyth, 25 bytes
?qeQ??},QPecQ,"No""Yes
Try it online!
?q # if ==
eQ? # Q[-1] "?":
?} # if in
,Q # "," Q:
cQ, # return split(Q, ",")
e # [-1] (last element)
P # [:-1] (remove the trailing ?)
"No" # else: return "No"
"Yes" # else: return "Yes" (last " implicit)
$endgroup$
add a comment
|
$begingroup$
Gema, 34 characters
*,*?=@subst*,=;$2
*?=No
*=Yes
Sample run:
bash-5.0$ echo -n 'Hey,does this program work?' | gema '*,*?=@subst*,=;$2;*?=No;*=Yes'
does this program work
Try it online! / Try all test cases online!
$endgroup$
add a comment
|
$begingroup$
Python 2, 66 63 bytes
lambda i:("Yes",("No",i.split(",")[-1][:-1])[","in i])["?"in i]
Try it online!
-3 after spotting the updated clarification "the input will only have one ? and it will always be the last character."
Basically a port of my Lotus Notes answer. Curiously, the clarification noted above does not help the Notes answer because @Ends
is 4 bytes cheaper than @Contains
. Now if only there was an @In
function...
$endgroup$
add a comment
|
$begingroup$
Zsh, 51 bytes
<<<$$$1#*?:+Yes:-$$$$1##*,%$1:-No%?
Try it online!
A byte can be saved if ends with,?
and similar are invalid.
$endgroup$
add a comment
|
$begingroup$
Japt, 23 bytes
ø'? ?Uq, hoinu¹Ìk'?:`Y
Try it
$endgroup$
add a comment
|
$begingroup$
C++ (gcc), 120 bytes
Function-like macro:
#include<string>
#define f(s)(int i,j;for(;s[i];)j=s[++i]-44?j:i;s[--i]-63?"Yes":j?std::string(s+j+1,i-j-1):"No";)
Try it online!
$endgroup$
add a comment
|
$begingroup$
Stax, 16 bytes
ëw‼◘╔╤▬n→ª▒¡Γ╟ï¿
Run and debug it
$endgroup$
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f192900%2finquiry-answerer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
17 Answers
17
active
oldest
votes
17 Answers
17
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
$endgroup$
add a comment
|
$begingroup$
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
$endgroup$
add a comment
|
$begingroup$
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
$endgroup$
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
edited 5 hours ago
answered 8 hours ago
JitseJitse
1,7967 silver badges24 bronze badges
1,7967 silver badges24 bronze badges
add a comment
|
add a comment
|
$begingroup$
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
$endgroup$
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
add a comment
|
$begingroup$
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
$endgroup$
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
add a comment
|
$begingroup$
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
$endgroup$
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
edited 4 hours ago
answered 8 hours ago
Kevin CruijssenKevin Cruijssen
51k7 gold badges85 silver badges247 bronze badges
51k7 gold badges85 silver badges247 bronze badges
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
add a comment
|
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
1
1
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
20
$endgroup$
– Grimy
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
$begingroup$
@Grimy Oh, smart thinking. Thanks! :)
$endgroup$
– Kevin Cruijssen
6 hours ago
add a comment
|
$begingroup$
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'
$endgroup$
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
add a comment
|
$begingroup$
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'
$endgroup$
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
add a comment
|
$begingroup$
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'
$endgroup$
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'
edited 2 hours ago
answered 8 hours ago
ArnauldArnauld
92.7k7 gold badges108 silver badges377 bronze badges
92.7k7 gold badges108 silver badges377 bronze badges
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
add a comment
|
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
$begingroup$
Welp, was looking for a JS solution, ended up with something double this size.
$endgroup$
– The random guy
8 hours ago
add a comment
|
$begingroup$
Charcoal, 23 22 bytes
¿№θ?¿№θ,⁻⊟⪪θ,¦?¦No¦Yes
Try it online! Link is to verbose version of code. Edit: Saved 1 byte thanks to @KevinCruijssen. Explanation:
¿№θ?
Does the string contain any ?
s?
¿№θ,
Does it contain any ,
s?
⊟⪪θ,
Split the string on ,
s and take the last.
⁻...?
Delete the ?
and output the result.
No
If there are no ,
s then output No
.
Yes
If there are no ?
s then output Yes
.
$endgroup$
$begingroup$
-1 changingPrint(Join(Split(Pop(Split(q, ",")), "?"), w)
toPrint(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten thatMinus
did that. Besides, I was feeling pleased with myself for saving two separators.
$endgroup$
– Neil
1 hour ago
add a comment
|
$begingroup$
Charcoal, 23 22 bytes
¿№θ?¿№θ,⁻⊟⪪θ,¦?¦No¦Yes
Try it online! Link is to verbose version of code. Edit: Saved 1 byte thanks to @KevinCruijssen. Explanation:
¿№θ?
Does the string contain any ?
s?
¿№θ,
Does it contain any ,
s?
⊟⪪θ,
Split the string on ,
s and take the last.
⁻...?
Delete the ?
and output the result.
No
If there are no ,
s then output No
.
Yes
If there are no ?
s then output Yes
.
$endgroup$
$begingroup$
-1 changingPrint(Join(Split(Pop(Split(q, ",")), "?"), w)
toPrint(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten thatMinus
did that. Besides, I was feeling pleased with myself for saving two separators.
$endgroup$
– Neil
1 hour ago
add a comment
|
$begingroup$
Charcoal, 23 22 bytes
¿№θ?¿№θ,⁻⊟⪪θ,¦?¦No¦Yes
Try it online! Link is to verbose version of code. Edit: Saved 1 byte thanks to @KevinCruijssen. Explanation:
¿№θ?
Does the string contain any ?
s?
¿№θ,
Does it contain any ,
s?
⊟⪪θ,
Split the string on ,
s and take the last.
⁻...?
Delete the ?
and output the result.
No
If there are no ,
s then output No
.
Yes
If there are no ?
s then output Yes
.
$endgroup$
Charcoal, 23 22 bytes
¿№θ?¿№θ,⁻⊟⪪θ,¦?¦No¦Yes
Try it online! Link is to verbose version of code. Edit: Saved 1 byte thanks to @KevinCruijssen. Explanation:
¿№θ?
Does the string contain any ?
s?
¿№θ,
Does it contain any ,
s?
⊟⪪θ,
Split the string on ,
s and take the last.
⁻...?
Delete the ?
and output the result.
No
If there are no ,
s then output No
.
Yes
If there are no ?
s then output Yes
.
edited 1 hour ago
answered 5 hours ago
NeilNeil
88.9k8 gold badges46 silver badges188 bronze badges
88.9k8 gold badges46 silver badges188 bronze badges
$begingroup$
-1 changingPrint(Join(Split(Pop(Split(q, ",")), "?"), w)
toPrint(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten thatMinus
did that. Besides, I was feeling pleased with myself for saving two separators.
$endgroup$
– Neil
1 hour ago
add a comment
|
$begingroup$
-1 changingPrint(Join(Split(Pop(Split(q, ",")), "?"), w)
toPrint(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten thatMinus
did that. Besides, I was feeling pleased with myself for saving two separators.
$endgroup$
– Neil
1 hour ago
$begingroup$
-1 changing
Print(Join(Split(Pop(Split(q, ",")), "?"), w)
to Print(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
-1 changing
Print(Join(Split(Pop(Split(q, ",")), "?"), w)
to Print(Minus(Pop(Split(q, ",")), "?");
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten that
Minus
did that. Besides, I was feeling pleased with myself for saving two separators.$endgroup$
– Neil
1 hour ago
$begingroup$
@KevinCruijssen Thanks, I'd forgotten that
Minus
did that. Besides, I was feeling pleased with myself for saving two separators.$endgroup$
– Neil
1 hour ago
add a comment
|
$begingroup$
Perl 5 + -plF/,|?/
, 27 bytes
$_=/?$/?/,/?$F[$#F]:No:Yes
Try it online!
$endgroup$
add a comment
|
$begingroup$
Perl 5 + -plF/,|?/
, 27 bytes
$_=/?$/?/,/?$F[$#F]:No:Yes
Try it online!
$endgroup$
add a comment
|
$begingroup$
Perl 5 + -plF/,|?/
, 27 bytes
$_=/?$/?/,/?$F[$#F]:No:Yes
Try it online!
$endgroup$
Perl 5 + -plF/,|?/
, 27 bytes
$_=/?$/?/,/?$F[$#F]:No:Yes
Try it online!
answered 4 hours ago
Dom HastingsDom Hastings
15.1k3 gold badges34 silver badges71 bronze badges
15.1k3 gold badges34 silver badges71 bronze badges
add a comment
|
add a comment
|
$begingroup$
Retina, 32 bytes
.+[^?]$
Yes
.+,(.*)?
$1
.+?
No
Try it online.
Explanation:
Replace any input not ending with "?" with Yes
:
.+[^?]$
Yes
Replace any input containing a comma and ending with a "?" with the part between the comma and the "?" (captured in capture group 1):
.+,(.*)?
$1
Replace any other input ending with a "?" with No
:
.+?
No
32 bytes alternative:
^/?/K`Yes
.+,(.*)?
$1
/?/K`No
K
tip thanks to @Neil.
Try it online.
Explanation:
The three steps are the same as above, but the K
only looks at a partial match (?
in this case). The ^
in the first line means a reverse, so if the input doesn't contain a ?
it replaced it with Yes
. And if the string does (still) contain a ?
at the last line, it replaces it with No
.
$endgroup$
$begingroup$
Did you know that Retina 1'sK
stage has a built-in conditional? I didn't. It could probably save you a few bytes.
$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain theK
and conditional&
to be completely honest. I know how to useK
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for theYes
/No
?
$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any?
must be at the end.
$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
add a comment
|
$begingroup$
Retina, 32 bytes
.+[^?]$
Yes
.+,(.*)?
$1
.+?
No
Try it online.
Explanation:
Replace any input not ending with "?" with Yes
:
.+[^?]$
Yes
Replace any input containing a comma and ending with a "?" with the part between the comma and the "?" (captured in capture group 1):
.+,(.*)?
$1
Replace any other input ending with a "?" with No
:
.+?
No
32 bytes alternative:
^/?/K`Yes
.+,(.*)?
$1
/?/K`No
K
tip thanks to @Neil.
Try it online.
Explanation:
The three steps are the same as above, but the K
only looks at a partial match (?
in this case). The ^
in the first line means a reverse, so if the input doesn't contain a ?
it replaced it with Yes
. And if the string does (still) contain a ?
at the last line, it replaces it with No
.
$endgroup$
$begingroup$
Did you know that Retina 1'sK
stage has a built-in conditional? I didn't. It could probably save you a few bytes.
$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain theK
and conditional&
to be completely honest. I know how to useK
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for theYes
/No
?
$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any?
must be at the end.
$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
add a comment
|
$begingroup$
Retina, 32 bytes
.+[^?]$
Yes
.+,(.*)?
$1
.+?
No
Try it online.
Explanation:
Replace any input not ending with "?" with Yes
:
.+[^?]$
Yes
Replace any input containing a comma and ending with a "?" with the part between the comma and the "?" (captured in capture group 1):
.+,(.*)?
$1
Replace any other input ending with a "?" with No
:
.+?
No
32 bytes alternative:
^/?/K`Yes
.+,(.*)?
$1
/?/K`No
K
tip thanks to @Neil.
Try it online.
Explanation:
The three steps are the same as above, but the K
only looks at a partial match (?
in this case). The ^
in the first line means a reverse, so if the input doesn't contain a ?
it replaced it with Yes
. And if the string does (still) contain a ?
at the last line, it replaces it with No
.
$endgroup$
Retina, 32 bytes
.+[^?]$
Yes
.+,(.*)?
$1
.+?
No
Try it online.
Explanation:
Replace any input not ending with "?" with Yes
:
.+[^?]$
Yes
Replace any input containing a comma and ending with a "?" with the part between the comma and the "?" (captured in capture group 1):
.+,(.*)?
$1
Replace any other input ending with a "?" with No
:
.+?
No
32 bytes alternative:
^/?/K`Yes
.+,(.*)?
$1
/?/K`No
K
tip thanks to @Neil.
Try it online.
Explanation:
The three steps are the same as above, but the K
only looks at a partial match (?
in this case). The ^
in the first line means a reverse, so if the input doesn't contain a ?
it replaced it with Yes
. And if the string does (still) contain a ?
at the last line, it replaces it with No
.
edited 56 mins ago
answered 5 hours ago
Kevin CruijssenKevin Cruijssen
51k7 gold badges85 silver badges247 bronze badges
51k7 gold badges85 silver badges247 bronze badges
$begingroup$
Did you know that Retina 1'sK
stage has a built-in conditional? I didn't. It could probably save you a few bytes.
$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain theK
and conditional&
to be completely honest. I know how to useK
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for theYes
/No
?
$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any?
must be at the end.
$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
add a comment
|
$begingroup$
Did you know that Retina 1'sK
stage has a built-in conditional? I didn't. It could probably save you a few bytes.
$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain theK
and conditional&
to be completely honest. I know how to useK
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for theYes
/No
?
$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any?
must be at the end.
$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
$begingroup$
Did you know that Retina 1's
K
stage has a built-in conditional? I didn't. It could probably save you a few bytes.$endgroup$
– Neil
4 hours ago
$begingroup$
Did you know that Retina 1's
K
stage has a built-in conditional? I didn't. It could probably save you a few bytes.$endgroup$
– Neil
4 hours ago
$begingroup$
@Neil I'm not sure how to chain the
K
and conditional &
to be completely honest. I know how to use K
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for the Yes
/No
?$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
@Neil I'm not sure how to chain the
K
and conditional &
to be completely honest. I know how to use K
with a regex to match like this, but how do I combine it with the conditional to mimic a ternary if-else for the Yes
/No
?$endgroup$
– Kevin Cruijssen
3 hours ago
$begingroup$
You don't need
&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any ?
must be at the end.$endgroup$
– Neil
1 hour ago
$begingroup$
You don't need
&
, which is what surprised me, and you can just match on a string, or better still, a character, since you know that any ?
must be at the end.$endgroup$
– Neil
1 hour ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
$begingroup$
@Neil So, like this? Which is also 32 bytes apparently.
$endgroup$
– Kevin Cruijssen
59 mins ago
add a comment
|
$begingroup$
PHP, 58 bytes
<?=$argn[-1]=='?'?substr(strrchr($argn,','),1,-1)?:No:Yes;
Try it online!
$endgroup$
$begingroup$
PrintsNo
instead of the empty string in cases ending with,?
.
$endgroup$
– GammaFunction
1 hour ago
add a comment
|
$begingroup$
PHP, 58 bytes
<?=$argn[-1]=='?'?substr(strrchr($argn,','),1,-1)?:No:Yes;
Try it online!
$endgroup$
$begingroup$
PrintsNo
instead of the empty string in cases ending with,?
.
$endgroup$
– GammaFunction
1 hour ago
add a comment
|
$begingroup$
PHP, 58 bytes
<?=$argn[-1]=='?'?substr(strrchr($argn,','),1,-1)?:No:Yes;
Try it online!
$endgroup$
PHP, 58 bytes
<?=$argn[-1]=='?'?substr(strrchr($argn,','),1,-1)?:No:Yes;
Try it online!
edited 6 hours ago
answered 7 hours ago
Night2Night2
2,7313 silver badges17 bronze badges
2,7313 silver badges17 bronze badges
$begingroup$
PrintsNo
instead of the empty string in cases ending with,?
.
$endgroup$
– GammaFunction
1 hour ago
add a comment
|
$begingroup$
PrintsNo
instead of the empty string in cases ending with,?
.
$endgroup$
– GammaFunction
1 hour ago
$begingroup$
Prints
No
instead of the empty string in cases ending with ,?
.$endgroup$
– GammaFunction
1 hour ago
$begingroup$
Prints
No
instead of the empty string in cases ending with ,?
.$endgroup$
– GammaFunction
1 hour ago
add a comment
|
$begingroup$
Red, 78 bytes
func[s][r:"Yes"parse s[to","copy t to"?"(r: last split t",")| to"?"(r:"No")]r]
Try it online!
$endgroup$
add a comment
|
$begingroup$
Red, 78 bytes
func[s][r:"Yes"parse s[to","copy t to"?"(r: last split t",")| to"?"(r:"No")]r]
Try it online!
$endgroup$
add a comment
|
$begingroup$
Red, 78 bytes
func[s][r:"Yes"parse s[to","copy t to"?"(r: last split t",")| to"?"(r:"No")]r]
Try it online!
$endgroup$
Red, 78 bytes
func[s][r:"Yes"parse s[to","copy t to"?"(r: last split t",")| to"?"(r:"No")]r]
Try it online!
answered 6 hours ago
Galen IvanovGalen Ivanov
9,4471 gold badge14 silver badges39 bronze badges
9,4471 gold badge14 silver badges39 bronze badges
add a comment
|
add a comment
|
$begingroup$
Perl 6, 40 bytes
Try it online!
$endgroup$
add a comment
|
$begingroup$
Perl 6, 40 bytes
Try it online!
$endgroup$
add a comment
|
$begingroup$
Perl 6, 40 bytes
Try it online!
$endgroup$
Perl 6, 40 bytes
Try it online!
answered 6 hours ago
Jo KingJo King
31.2k4 gold badges72 silver badges139 bronze badges
31.2k4 gold badges72 silver badges139 bronze badges
add a comment
|
add a comment
|
$begingroup$
IBM/Lotus Notes Formula, 79 bytes
@If(@Ends(i;"?");@If(@Contains(i;",");@Left(@RightBack(i;",");"?");"No");"Yes")
No TIO for Formula so...
$endgroup$
add a comment
|
$begingroup$
IBM/Lotus Notes Formula, 79 bytes
@If(@Ends(i;"?");@If(@Contains(i;",");@Left(@RightBack(i;",");"?");"No");"Yes")
No TIO for Formula so...
$endgroup$
add a comment
|
$begingroup$
IBM/Lotus Notes Formula, 79 bytes
@If(@Ends(i;"?");@If(@Contains(i;",");@Left(@RightBack(i;",");"?");"No");"Yes")
No TIO for Formula so...
$endgroup$
IBM/Lotus Notes Formula, 79 bytes
@If(@Ends(i;"?");@If(@Contains(i;",");@Left(@RightBack(i;",");"?");"No");"Yes")
No TIO for Formula so...
answered 5 hours ago
ElPedroElPedro
4,05813 silver badges28 bronze badges
4,05813 silver badges28 bronze badges
add a comment
|
add a comment
|
$begingroup$
Pyth, 25 bytes
?qeQ??},QPecQ,"No""Yes
Try it online!
?q # if ==
eQ? # Q[-1] "?":
?} # if in
,Q # "," Q:
cQ, # return split(Q, ",")
e # [-1] (last element)
P # [:-1] (remove the trailing ?)
"No" # else: return "No"
"Yes" # else: return "Yes" (last " implicit)
$endgroup$
add a comment
|
$begingroup$
Pyth, 25 bytes
?qeQ??},QPecQ,"No""Yes
Try it online!
?q # if ==
eQ? # Q[-1] "?":
?} # if in
,Q # "," Q:
cQ, # return split(Q, ",")
e # [-1] (last element)
P # [:-1] (remove the trailing ?)
"No" # else: return "No"
"Yes" # else: return "Yes" (last " implicit)
$endgroup$
add a comment
|
$begingroup$
Pyth, 25 bytes
?qeQ??},QPecQ,"No""Yes
Try it online!
?q # if ==
eQ? # Q[-1] "?":
?} # if in
,Q # "," Q:
cQ, # return split(Q, ",")
e # [-1] (last element)
P # [:-1] (remove the trailing ?)
"No" # else: return "No"
"Yes" # else: return "Yes" (last " implicit)
$endgroup$
Pyth, 25 bytes
?qeQ??},QPecQ,"No""Yes
Try it online!
?q # if ==
eQ? # Q[-1] "?":
?} # if in
,Q # "," Q:
cQ, # return split(Q, ",")
e # [-1] (last element)
P # [:-1] (remove the trailing ?)
"No" # else: return "No"
"Yes" # else: return "Yes" (last " implicit)
edited 5 hours ago
answered 6 hours ago
ar4093ar4093
3816 bronze badges
3816 bronze badges
add a comment
|
add a comment
|
$begingroup$
Gema, 34 characters
*,*?=@subst*,=;$2
*?=No
*=Yes
Sample run:
bash-5.0$ echo -n 'Hey,does this program work?' | gema '*,*?=@subst*,=;$2;*?=No;*=Yes'
does this program work
Try it online! / Try all test cases online!
$endgroup$
add a comment
|
$begingroup$
Gema, 34 characters
*,*?=@subst*,=;$2
*?=No
*=Yes
Sample run:
bash-5.0$ echo -n 'Hey,does this program work?' | gema '*,*?=@subst*,=;$2;*?=No;*=Yes'
does this program work
Try it online! / Try all test cases online!
$endgroup$
add a comment
|
$begingroup$
Gema, 34 characters
*,*?=@subst*,=;$2
*?=No
*=Yes
Sample run:
bash-5.0$ echo -n 'Hey,does this program work?' | gema '*,*?=@subst*,=;$2;*?=No;*=Yes'
does this program work
Try it online! / Try all test cases online!
$endgroup$
Gema, 34 characters
*,*?=@subst*,=;$2
*?=No
*=Yes
Sample run:
bash-5.0$ echo -n 'Hey,does this program work?' | gema '*,*?=@subst*,=;$2;*?=No;*=Yes'
does this program work
Try it online! / Try all test cases online!
edited 4 hours ago
answered 7 hours ago
manatworkmanatwork
16.8k4 gold badges39 silver badges73 bronze badges
16.8k4 gold badges39 silver badges73 bronze badges
add a comment
|
add a comment
|
$begingroup$
Python 2, 66 63 bytes
lambda i:("Yes",("No",i.split(",")[-1][:-1])[","in i])["?"in i]
Try it online!
-3 after spotting the updated clarification "the input will only have one ? and it will always be the last character."
Basically a port of my Lotus Notes answer. Curiously, the clarification noted above does not help the Notes answer because @Ends
is 4 bytes cheaper than @Contains
. Now if only there was an @In
function...
$endgroup$
add a comment
|
$begingroup$
Python 2, 66 63 bytes
lambda i:("Yes",("No",i.split(",")[-1][:-1])[","in i])["?"in i]
Try it online!
-3 after spotting the updated clarification "the input will only have one ? and it will always be the last character."
Basically a port of my Lotus Notes answer. Curiously, the clarification noted above does not help the Notes answer because @Ends
is 4 bytes cheaper than @Contains
. Now if only there was an @In
function...
$endgroup$
add a comment
|
$begingroup$
Python 2, 66 63 bytes
lambda i:("Yes",("No",i.split(",")[-1][:-1])[","in i])["?"in i]
Try it online!
-3 after spotting the updated clarification "the input will only have one ? and it will always be the last character."
Basically a port of my Lotus Notes answer. Curiously, the clarification noted above does not help the Notes answer because @Ends
is 4 bytes cheaper than @Contains
. Now if only there was an @In
function...
$endgroup$
Python 2, 66 63 bytes
lambda i:("Yes",("No",i.split(",")[-1][:-1])[","in i])["?"in i]
Try it online!
-3 after spotting the updated clarification "the input will only have one ? and it will always be the last character."
Basically a port of my Lotus Notes answer. Curiously, the clarification noted above does not help the Notes answer because @Ends
is 4 bytes cheaper than @Contains
. Now if only there was an @In
function...
edited 2 hours ago
answered 4 hours ago
ElPedroElPedro
4,05813 silver badges28 bronze badges
4,05813 silver badges28 bronze badges
add a comment
|
add a comment
|
$begingroup$
Zsh, 51 bytes
<<<$$$1#*?:+Yes:-$$$$1##*,%$1:-No%?
Try it online!
A byte can be saved if ends with,?
and similar are invalid.
$endgroup$
add a comment
|
$begingroup$
Zsh, 51 bytes
<<<$$$1#*?:+Yes:-$$$$1##*,%$1:-No%?
Try it online!
A byte can be saved if ends with,?
and similar are invalid.
$endgroup$
add a comment
|
$begingroup$
Zsh, 51 bytes
<<<$$$1#*?:+Yes:-$$$$1##*,%$1:-No%?
Try it online!
A byte can be saved if ends with,?
and similar are invalid.
$endgroup$
Zsh, 51 bytes
<<<$$$1#*?:+Yes:-$$$$1##*,%$1:-No%?
Try it online!
A byte can be saved if ends with,?
and similar are invalid.
answered 1 hour ago
GammaFunctionGammaFunction
1,4953 silver badges15 bronze badges
1,4953 silver badges15 bronze badges
add a comment
|
add a comment
|
$begingroup$
Japt, 23 bytes
ø'? ?Uq, hoinu¹Ìk'?:`Y
Try it
$endgroup$
add a comment
|
$begingroup$
Japt, 23 bytes
ø'? ?Uq, hoinu¹Ìk'?:`Y
Try it
$endgroup$
add a comment
|
$begingroup$
Japt, 23 bytes
ø'? ?Uq, hoinu¹Ìk'?:`Y
Try it
$endgroup$
Japt, 23 bytes
ø'? ?Uq, hoinu¹Ìk'?:`Y
Try it
answered 54 mins ago
ShaggyShaggy
21.5k3 gold badges21 silver badges72 bronze badges
21.5k3 gold badges21 silver badges72 bronze badges
add a comment
|
add a comment
|
$begingroup$
C++ (gcc), 120 bytes
Function-like macro:
#include<string>
#define f(s)(int i,j;for(;s[i];)j=s[++i]-44?j:i;s[--i]-63?"Yes":j?std::string(s+j+1,i-j-1):"No";)
Try it online!
$endgroup$
add a comment
|
$begingroup$
C++ (gcc), 120 bytes
Function-like macro:
#include<string>
#define f(s)(int i,j;for(;s[i];)j=s[++i]-44?j:i;s[--i]-63?"Yes":j?std::string(s+j+1,i-j-1):"No";)
Try it online!
$endgroup$
add a comment
|
$begingroup$
C++ (gcc), 120 bytes
Function-like macro:
#include<string>
#define f(s)(int i,j;for(;s[i];)j=s[++i]-44?j:i;s[--i]-63?"Yes":j?std::string(s+j+1,i-j-1):"No";)
Try it online!
$endgroup$
C++ (gcc), 120 bytes
Function-like macro:
#include<string>
#define f(s)(int i,j;for(;s[i];)j=s[++i]-44?j:i;s[--i]-63?"Yes":j?std::string(s+j+1,i-j-1):"No";)
Try it online!
answered 50 mins ago
NishiokaNishioka
1514 bronze badges
1514 bronze badges
add a comment
|
add a comment
|
$begingroup$
Stax, 16 bytes
ëw‼◘╔╤▬n→ª▒¡Γ╟ï¿
Run and debug it
$endgroup$
add a comment
|
$begingroup$
Stax, 16 bytes
ëw‼◘╔╤▬n→ª▒¡Γ╟ï¿
Run and debug it
$endgroup$
add a comment
|
$begingroup$
Stax, 16 bytes
ëw‼◘╔╤▬n→ª▒¡Γ╟ï¿
Run and debug it
$endgroup$
Stax, 16 bytes
ëw‼◘╔╤▬n→ª▒¡Γ╟ï¿
Run and debug it
answered 19 mins ago
recursiverecursive
8,28615 silver badges32 bronze badges
8,28615 silver badges32 bronze badges
add a comment
|
add a comment
|
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f192900%2finquiry-answerer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
$begingroup$
Are we guaranteed that if the input includes a
?
, there will only be one and it will always be the last character?$endgroup$
– Shaggy
7 hours ago
2
$begingroup$
Please add a test case containing multiple commas.
$endgroup$
– manatwork
7 hours ago
4
$begingroup$
Accepting an answer early may discourage other users from posting new answers, because it kind of looks like the challenge is done.
$endgroup$
– Arnauld
5 hours ago
2
$begingroup$
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$
– A _
3 hours ago
1
$begingroup$
Is
ends with ,?
a valid input?$endgroup$
– GammaFunction
1 hour ago