No trailing but(t)s please!
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
This challenge was inspired by Yeah But No But Yeah.
maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) =>
for(var i = 0; i < nrOfButs; i++)
if(i % 3 == 0)
console.log("Yeah")
if(i % 2 == 0)
console.log("But")
if(i % 3 == 1)
console.log("No")
Since the code is not only overly long but also incorrect, I´ll suggest to maxb´s boss to fire that guy and hire one of you folks instead.
I can´t guarantee anything; but I reckon there´ll be a decent wage, health insurance and possibly a company car in it. All You have to do is
A) correct the code, so the Number of Buts printed is the same as asked in the parameter
B) correct the grammar. (see below)
C) make it as short as possible.
He might as well block my calls after that because he doesn´t like pennypickers; but who knows.
Input
a non-negative integer, in any convenient way
Output
Yeah
and No
, mostly separated by But
s. The code above and the examples below should clarify the pattern.
Output should never end in a But
.
And a sentence should always end with a stop (.
) or exclamation mark; i.e. put one after every No
that is directly followed by a Yeah
(without a But
) and one at the end of the output.
A single trailing "Yeah." may be printed (if you want to think positive), but that´s not a must.
You may print the output or return a list of strings.
Trailing blanks are acceptable, as well as a single leading or trailing newline.
examples (input => possible output)
input 0:
Yeah.
input 1:
Yeah
But
No.
input 2:
Yeah
But
No
But
Yeah.
input 3:
Yeah
But
No
But
Yeah
But
No.
Yeah! <optional>
...
input 5:
Yeah
But
No
But
Yeah
But
No.
Yeah
But
No
But
Yeah.
code-golf string
 |Â
show 7 more comments
up vote
1
down vote
favorite
This challenge was inspired by Yeah But No But Yeah.
maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) =>
for(var i = 0; i < nrOfButs; i++)
if(i % 3 == 0)
console.log("Yeah")
if(i % 2 == 0)
console.log("But")
if(i % 3 == 1)
console.log("No")
Since the code is not only overly long but also incorrect, I´ll suggest to maxb´s boss to fire that guy and hire one of you folks instead.
I can´t guarantee anything; but I reckon there´ll be a decent wage, health insurance and possibly a company car in it. All You have to do is
A) correct the code, so the Number of Buts printed is the same as asked in the parameter
B) correct the grammar. (see below)
C) make it as short as possible.
He might as well block my calls after that because he doesn´t like pennypickers; but who knows.
Input
a non-negative integer, in any convenient way
Output
Yeah
and No
, mostly separated by But
s. The code above and the examples below should clarify the pattern.
Output should never end in a But
.
And a sentence should always end with a stop (.
) or exclamation mark; i.e. put one after every No
that is directly followed by a Yeah
(without a But
) and one at the end of the output.
A single trailing "Yeah." may be printed (if you want to think positive), but that´s not a must.
You may print the output or return a list of strings.
Trailing blanks are acceptable, as well as a single leading or trailing newline.
examples (input => possible output)
input 0:
Yeah.
input 1:
Yeah
But
No.
input 2:
Yeah
But
No
But
Yeah.
input 3:
Yeah
But
No
But
Yeah
But
No.
Yeah! <optional>
...
input 5:
Yeah
But
No
But
Yeah
But
No.
Yeah
But
No
But
Yeah.
code-golf string
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
So if I understand correctly: 1. A dot should be added between everyNo Yeah
orYeah No
. 2. A dot should be added at the very end. 3. A single line only containingYeah
orNo
should be removed. 4. When a sentence ends with aBut
theBut
should be removed? (not sure about this fourth one)
– Kevin Cruijssen
4 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@maxb Then what is that dot betweenNo
andYeah
doing there in test casen=5
? And the trailingYeah.
is gone forn=3
.
– Kevin Cruijssen
3 hours ago
2
Hmm, shouldn't the output forn=0
be empty?.. It won't go into thefor(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.
– Kevin Cruijssen
3 hours ago
 |Â
show 7 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This challenge was inspired by Yeah But No But Yeah.
maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) =>
for(var i = 0; i < nrOfButs; i++)
if(i % 3 == 0)
console.log("Yeah")
if(i % 2 == 0)
console.log("But")
if(i % 3 == 1)
console.log("No")
Since the code is not only overly long but also incorrect, I´ll suggest to maxb´s boss to fire that guy and hire one of you folks instead.
I can´t guarantee anything; but I reckon there´ll be a decent wage, health insurance and possibly a company car in it. All You have to do is
A) correct the code, so the Number of Buts printed is the same as asked in the parameter
B) correct the grammar. (see below)
C) make it as short as possible.
He might as well block my calls after that because he doesn´t like pennypickers; but who knows.
Input
a non-negative integer, in any convenient way
Output
Yeah
and No
, mostly separated by But
s. The code above and the examples below should clarify the pattern.
Output should never end in a But
.
And a sentence should always end with a stop (.
) or exclamation mark; i.e. put one after every No
that is directly followed by a Yeah
(without a But
) and one at the end of the output.
A single trailing "Yeah." may be printed (if you want to think positive), but that´s not a must.
You may print the output or return a list of strings.
Trailing blanks are acceptable, as well as a single leading or trailing newline.
examples (input => possible output)
input 0:
Yeah.
input 1:
Yeah
But
No.
input 2:
Yeah
But
No
But
Yeah.
input 3:
Yeah
But
No
But
Yeah
But
No.
Yeah! <optional>
...
input 5:
Yeah
But
No
But
Yeah
But
No.
Yeah
But
No
But
Yeah.
code-golf string
This challenge was inspired by Yeah But No But Yeah.
maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) =>
for(var i = 0; i < nrOfButs; i++)
if(i % 3 == 0)
console.log("Yeah")
if(i % 2 == 0)
console.log("But")
if(i % 3 == 1)
console.log("No")
Since the code is not only overly long but also incorrect, I´ll suggest to maxb´s boss to fire that guy and hire one of you folks instead.
I can´t guarantee anything; but I reckon there´ll be a decent wage, health insurance and possibly a company car in it. All You have to do is
A) correct the code, so the Number of Buts printed is the same as asked in the parameter
B) correct the grammar. (see below)
C) make it as short as possible.
He might as well block my calls after that because he doesn´t like pennypickers; but who knows.
Input
a non-negative integer, in any convenient way
Output
Yeah
and No
, mostly separated by But
s. The code above and the examples below should clarify the pattern.
Output should never end in a But
.
And a sentence should always end with a stop (.
) or exclamation mark; i.e. put one after every No
that is directly followed by a Yeah
(without a But
) and one at the end of the output.
A single trailing "Yeah." may be printed (if you want to think positive), but that´s not a must.
You may print the output or return a list of strings.
Trailing blanks are acceptable, as well as a single leading or trailing newline.
examples (input => possible output)
input 0:
Yeah.
input 1:
Yeah
But
No.
input 2:
Yeah
But
No
But
Yeah.
input 3:
Yeah
But
No
But
Yeah
But
No.
Yeah! <optional>
...
input 5:
Yeah
But
No
But
Yeah
But
No.
Yeah
But
No
But
Yeah.
code-golf string
code-golf string
edited 1 hour ago
asked 4 hours ago


Titus
12.4k11236
12.4k11236
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
So if I understand correctly: 1. A dot should be added between everyNo Yeah
orYeah No
. 2. A dot should be added at the very end. 3. A single line only containingYeah
orNo
should be removed. 4. When a sentence ends with aBut
theBut
should be removed? (not sure about this fourth one)
– Kevin Cruijssen
4 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@maxb Then what is that dot betweenNo
andYeah
doing there in test casen=5
? And the trailingYeah.
is gone forn=3
.
– Kevin Cruijssen
3 hours ago
2
Hmm, shouldn't the output forn=0
be empty?.. It won't go into thefor(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.
– Kevin Cruijssen
3 hours ago
 |Â
show 7 more comments
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
So if I understand correctly: 1. A dot should be added between everyNo Yeah
orYeah No
. 2. A dot should be added at the very end. 3. A single line only containingYeah
orNo
should be removed. 4. When a sentence ends with aBut
theBut
should be removed? (not sure about this fourth one)
– Kevin Cruijssen
4 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@maxb Then what is that dot betweenNo
andYeah
doing there in test casen=5
? And the trailingYeah.
is gone forn=3
.
– Kevin Cruijssen
3 hours ago
2
Hmm, shouldn't the output forn=0
be empty?.. It won't go into thefor(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.
– Kevin Cruijssen
3 hours ago
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
So if I understand correctly: 1. A dot should be added between every
No Yeah
or Yeah No
. 2. A dot should be added at the very end. 3. A single line only containing Yeah
or No
should be removed. 4. When a sentence ends with a But
the But
should be removed? (not sure about this fourth one)– Kevin Cruijssen
4 hours ago
So if I understand correctly: 1. A dot should be added between every
No Yeah
or Yeah No
. 2. A dot should be added at the very end. 3. A single line only containing Yeah
or No
should be removed. 4. When a sentence ends with a But
the But
should be removed? (not sure about this fourth one)– Kevin Cruijssen
4 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@maxb Then what is that dot between
No
and Yeah
doing there in test case n=5
? And the trailing Yeah.
is gone for n=3
.– Kevin Cruijssen
3 hours ago
@maxb Then what is that dot between
No
and Yeah
doing there in test case n=5
? And the trailing Yeah.
is gone for n=3
.– Kevin Cruijssen
3 hours ago
2
2
Hmm, shouldn't the output for
n=0
be empty?.. It won't go into the for(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.– Kevin Cruijssen
3 hours ago
Hmm, shouldn't the output for
n=0
be empty?.. It won't go into the for(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.– Kevin Cruijssen
3 hours ago
 |Â
show 7 more comments
4 Answers
4
active
oldest
votes
up vote
2
down vote
Python 2, 105 bytes
def f(n,s=1):
if n>0 or s:print'nButn'.join(['Yeah','No'][i%2]for i in range(min(3,n)+1))+'.';f(n-3,0)
Try it online!
add a comment |Â
up vote
1
down vote
Javascript, 80 bytes
a=>s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'nbutn':'.');return s
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because thei%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And theyeah
,no
,but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
add a comment |Â
up vote
1
down vote
Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No
Try it online! Explanation:
.+
*
Convert to unary.
L$`__?_?|^
Yeah$&.
Match up to three _
s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah
with a trailing .
.
__
_¶But¶Yeah
A match of 2 or 3 _
s results in a But
Yeah
in the second position.
_
¶But¶No
The other _
s turn into But
No
.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No
Try it online! Explanation:
.+
$*
Convert to unary.
M!`11?1?
Match up to three 1
s at a time.
%`^.*
Yeah$&.
Add a leading Yeah
and trailing .
for each match. The ^.*
allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No
Add in the But
Yeah
and/or No
as above.
add a comment |Â
up vote
1
down vote
05AB1E, 44 bytes
>iâ€Â¥æ.â€Âë[D1‹#©3‚ßEâ€Â¥æ€¸â€Â#Nè})â€Â€³â€Â¶.øý'.«,®3-
I have the feeling just know I'm hugely over-complicating things here.. >.>
Try it online.
Explanation:
>i # If the input is 0:
â€Â¥æ.†# Push (and implicitly output) "Yeah."
ë # Else:
[ # Start an infinite loop
# Take the (implicit) input `n`
D1‹# # If `n` is smaller than 1: stop the infinite loop
© # Temporary store `n` (without popping)
3‚ß # Take the max `m` of `n` and 3
Eâ€Â¥æ€¸â€Â#Nè}) # Create an alternating list of "Yeah" and "No" of size `m`
â€Â€³â€Â¶.ø # Push "nButn"
ý # Join the alternating list above with it
'.« # Append a trailing "."
, # Print everything to STDOUT with a trailing newline
®3- # Decrease `n` by 3
Additional explanation why â€Â¥æ.â€Â
is "Yeah.", â€Â¥æ€¸â€Â
is "Yeah No", and â€Â€³â€Â
is "But".
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Python 2, 105 bytes
def f(n,s=1):
if n>0 or s:print'nButn'.join(['Yeah','No'][i%2]for i in range(min(3,n)+1))+'.';f(n-3,0)
Try it online!
add a comment |Â
up vote
2
down vote
Python 2, 105 bytes
def f(n,s=1):
if n>0 or s:print'nButn'.join(['Yeah','No'][i%2]for i in range(min(3,n)+1))+'.';f(n-3,0)
Try it online!
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Python 2, 105 bytes
def f(n,s=1):
if n>0 or s:print'nButn'.join(['Yeah','No'][i%2]for i in range(min(3,n)+1))+'.';f(n-3,0)
Try it online!
Python 2, 105 bytes
def f(n,s=1):
if n>0 or s:print'nButn'.join(['Yeah','No'][i%2]for i in range(min(3,n)+1))+'.';f(n-3,0)
Try it online!
answered 2 hours ago


TFeld
11.7k2833
11.7k2833
add a comment |Â
add a comment |Â
up vote
1
down vote
Javascript, 80 bytes
a=>s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'nbutn':'.');return s
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because thei%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And theyeah
,no
,but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
add a comment |Â
up vote
1
down vote
Javascript, 80 bytes
a=>s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'nbutn':'.');return s
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because thei%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And theyeah
,no
,but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Javascript, 80 bytes
a=>s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'nbutn':'.');return s
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Javascript, 80 bytes
a=>s='';for(i=0;i<a+1;i++)s+=(i%2==0?'yeah':'no')+(i<a?'nbutn':'.');return s
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago


Jonathan Allan
48.4k534159
48.4k534159
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 3 hours ago


Vico
113
113
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Vico is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because thei%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And theyeah
,no
,but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
add a comment |Â
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because thei%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And theyeah
,no
,but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
1
1
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
please give explanation why you downvote my answer so i can improve in another chance
– Vico
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because the
i%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And the yeah
, no
, but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).– Kevin Cruijssen
1 hour ago
Hi, welcome to PPCG! I'm not the one who downvoted, but I completely agree with your comment above that people should leave an explanation of why they downvote!.. Anyway, I think one reason is because the
i%2==0
check isn't really correct in comparison to the code in the challenge description. I admit that the challenge description is a bit vague tbh (as I mentioned in the comments below it). I can only guess here, but the downvote is most likely due to a different than expected output. (PS: And the yeah
, no
, but
should be Titlecase instead of lowercase, but that's an easy fix. ;) ).– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
Some more general tips not related to this challenge: You might want to add a Try-it-online link with test code for your answers. In this case this could be a possible TIO-link. In addition, Tips for golfing in JavaScript and Tips for golfing in <all langauges> might be interesting to read through; I see a few parts you can golf in your current answer. :) Don't let this downvote discourage you, and enjoy your stay!
– Kevin Cruijssen
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
RE: the downvote: The post automatically went onto the low quality post queue due to it's length and content (a post from a new user with only a code-block will trigger this). Then when it is edited to actually fix that a downvote is automatically applied - the community here views this "feature" as a bug (it's not a very friendly welcome!). Please ignore it; check the format of the edited post too (I've also added a language tag for the code-block to add syntax highlighting).
– Jonathan Allan
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
thank you for your reply guys, i learn from my mistake
– Vico
1 hour ago
add a comment |Â
up vote
1
down vote
Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No
Try it online! Explanation:
.+
*
Convert to unary.
L$`__?_?|^
Yeah$&.
Match up to three _
s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah
with a trailing .
.
__
_¶But¶Yeah
A match of 2 or 3 _
s results in a But
Yeah
in the second position.
_
¶But¶No
The other _
s turn into But
No
.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No
Try it online! Explanation:
.+
$*
Convert to unary.
M!`11?1?
Match up to three 1
s at a time.
%`^.*
Yeah$&.
Add a leading Yeah
and trailing .
for each match. The ^.*
allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No
Add in the But
Yeah
and/or No
as above.
add a comment |Â
up vote
1
down vote
Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No
Try it online! Explanation:
.+
*
Convert to unary.
L$`__?_?|^
Yeah$&.
Match up to three _
s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah
with a trailing .
.
__
_¶But¶Yeah
A match of 2 or 3 _
s results in a But
Yeah
in the second position.
_
¶But¶No
The other _
s turn into But
No
.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No
Try it online! Explanation:
.+
$*
Convert to unary.
M!`11?1?
Match up to three 1
s at a time.
%`^.*
Yeah$&.
Add a leading Yeah
and trailing .
for each match. The ^.*
allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No
Add in the But
Yeah
and/or No
as above.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No
Try it online! Explanation:
.+
*
Convert to unary.
L$`__?_?|^
Yeah$&.
Match up to three _
s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah
with a trailing .
.
__
_¶But¶Yeah
A match of 2 or 3 _
s results in a But
Yeah
in the second position.
_
¶But¶No
The other _
s turn into But
No
.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No
Try it online! Explanation:
.+
$*
Convert to unary.
M!`11?1?
Match up to three 1
s at a time.
%`^.*
Yeah$&.
Add a leading Yeah
and trailing .
for each match. The ^.*
allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No
Add in the But
Yeah
and/or No
as above.
Retina, 48 47 bytes
.+
*
L$`__?_?|^
Yeah$&.
__
_¶But¶Yeah
_
¶But¶No
Try it online! Explanation:
.+
*
Convert to unary.
L$`__?_?|^
Yeah$&.
Match up to three _
s at a time. Also handle the zero edge case as a match. Each match results in at least a Yeah
with a trailing .
.
__
_¶But¶Yeah
A match of 2 or 3 _
s results in a But
Yeah
in the second position.
_
¶But¶No
The other _
s turn into But
No
.
52 bytes in Retina 0.8.2:
.+
$*
M!`11?1?
%`^.*
Yeah$&.
11
1¶But¶Yeah
1
¶But¶No
Try it online! Explanation:
.+
$*
Convert to unary.
M!`11?1?
Match up to three 1
s at a time.
%`^.*
Yeah$&.
Add a leading Yeah
and trailing .
for each match. The ^.*
allows it to work for the zero case too.
11
1¶But¶Yeah
1
¶But¶No
Add in the But
Yeah
and/or No
as above.
edited 1 hour ago
answered 1 hour ago
Neil
75.5k744170
75.5k744170
add a comment |Â
add a comment |Â
up vote
1
down vote
05AB1E, 44 bytes
>iâ€Â¥æ.â€Âë[D1‹#©3‚ßEâ€Â¥æ€¸â€Â#Nè})â€Â€³â€Â¶.øý'.«,®3-
I have the feeling just know I'm hugely over-complicating things here.. >.>
Try it online.
Explanation:
>i # If the input is 0:
â€Â¥æ.†# Push (and implicitly output) "Yeah."
ë # Else:
[ # Start an infinite loop
# Take the (implicit) input `n`
D1‹# # If `n` is smaller than 1: stop the infinite loop
© # Temporary store `n` (without popping)
3‚ß # Take the max `m` of `n` and 3
Eâ€Â¥æ€¸â€Â#Nè}) # Create an alternating list of "Yeah" and "No" of size `m`
â€Â€³â€Â¶.ø # Push "nButn"
ý # Join the alternating list above with it
'.« # Append a trailing "."
, # Print everything to STDOUT with a trailing newline
®3- # Decrease `n` by 3
Additional explanation why â€Â¥æ.â€Â
is "Yeah.", â€Â¥æ€¸â€Â
is "Yeah No", and â€Â€³â€Â
is "But".
add a comment |Â
up vote
1
down vote
05AB1E, 44 bytes
>iâ€Â¥æ.â€Âë[D1‹#©3‚ßEâ€Â¥æ€¸â€Â#Nè})â€Â€³â€Â¶.øý'.«,®3-
I have the feeling just know I'm hugely over-complicating things here.. >.>
Try it online.
Explanation:
>i # If the input is 0:
â€Â¥æ.†# Push (and implicitly output) "Yeah."
ë # Else:
[ # Start an infinite loop
# Take the (implicit) input `n`
D1‹# # If `n` is smaller than 1: stop the infinite loop
© # Temporary store `n` (without popping)
3‚ß # Take the max `m` of `n` and 3
Eâ€Â¥æ€¸â€Â#Nè}) # Create an alternating list of "Yeah" and "No" of size `m`
â€Â€³â€Â¶.ø # Push "nButn"
ý # Join the alternating list above with it
'.« # Append a trailing "."
, # Print everything to STDOUT with a trailing newline
®3- # Decrease `n` by 3
Additional explanation why â€Â¥æ.â€Â
is "Yeah.", â€Â¥æ€¸â€Â
is "Yeah No", and â€Â€³â€Â
is "But".
add a comment |Â
up vote
1
down vote
up vote
1
down vote
05AB1E, 44 bytes
>iâ€Â¥æ.â€Âë[D1‹#©3‚ßEâ€Â¥æ€¸â€Â#Nè})â€Â€³â€Â¶.øý'.«,®3-
I have the feeling just know I'm hugely over-complicating things here.. >.>
Try it online.
Explanation:
>i # If the input is 0:
â€Â¥æ.†# Push (and implicitly output) "Yeah."
ë # Else:
[ # Start an infinite loop
# Take the (implicit) input `n`
D1‹# # If `n` is smaller than 1: stop the infinite loop
© # Temporary store `n` (without popping)
3‚ß # Take the max `m` of `n` and 3
Eâ€Â¥æ€¸â€Â#Nè}) # Create an alternating list of "Yeah" and "No" of size `m`
â€Â€³â€Â¶.ø # Push "nButn"
ý # Join the alternating list above with it
'.« # Append a trailing "."
, # Print everything to STDOUT with a trailing newline
®3- # Decrease `n` by 3
Additional explanation why â€Â¥æ.â€Â
is "Yeah.", â€Â¥æ€¸â€Â
is "Yeah No", and â€Â€³â€Â
is "But".
05AB1E, 44 bytes
>iâ€Â¥æ.â€Âë[D1‹#©3‚ßEâ€Â¥æ€¸â€Â#Nè})â€Â€³â€Â¶.øý'.«,®3-
I have the feeling just know I'm hugely over-complicating things here.. >.>
Try it online.
Explanation:
>i # If the input is 0:
â€Â¥æ.†# Push (and implicitly output) "Yeah."
ë # Else:
[ # Start an infinite loop
# Take the (implicit) input `n`
D1‹# # If `n` is smaller than 1: stop the infinite loop
© # Temporary store `n` (without popping)
3‚ß # Take the max `m` of `n` and 3
Eâ€Â¥æ€¸â€Â#Nè}) # Create an alternating list of "Yeah" and "No" of size `m`
â€Â€³â€Â¶.ø # Push "nButn"
ý # Join the alternating list above with it
'.« # Append a trailing "."
, # Print everything to STDOUT with a trailing newline
®3- # Decrease `n` by 3
Additional explanation why â€Â¥æ.â€Â
is "Yeah.", â€Â¥æ€¸â€Â
is "Yeah No", and â€Â€³â€Â
is "But".
answered 22 mins ago


Kevin Cruijssen
30.3k553167
30.3k553167
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172595%2fno-trailing-butts-please%23new-answer', 'question_page');
);
Post as a guest
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
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
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
These programs should be able to be a bit shorter, though the period could add 2-3 bytes depending on the language. I'll have to create my own solution in MathGolf, but I don't think I'll be able to beat Jelly and 05AB1E for this one.
– maxb
4 hours ago
So if I understand correctly: 1. A dot should be added between every
No Yeah
orYeah No
. 2. A dot should be added at the very end. 3. A single line only containingYeah
orNo
should be removed. 4. When a sentence ends with aBut
theBut
should be removed? (not sure about this fourth one)– Kevin Cruijssen
4 hours ago
@KevinCruijssen I think you're overcomplicating it. You just have to output $2n+1$ lines of "YeahnButnNonButnYeahnButnNonBut..." and end with a period.
– maxb
3 hours ago
@maxb Then what is that dot between
No
andYeah
doing there in test casen=5
? And the trailingYeah.
is gone forn=3
.– Kevin Cruijssen
3 hours ago
2
Hmm, shouldn't the output for
n=0
be empty?.. It won't go into thefor(var i = 0; i < nrOfButs; ...
loop, so won't print anything there. And there is also the rule "A single trailing "Yeah." should be avoided." to consider. There are a bit too many unanswered questions, so I've voted to close as unclear for now.. Might change after some clarification and better (bullet-point) specified rules or step-by-step examples of the given test cases.– Kevin Cruijssen
3 hours ago