Yeah But No But Yeah

46

10

My colleague recently sent me 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 was written during work hours, it was obviously a huge waste of company resources. To prevent similar occurrences in the future, we must minimize the waste of worked hours. And since it is common knowledge that a shorter program is faster to write, we must golf this code to be as short as possible!

Input

A single non-negative integer. You must not handle faulty input.

Output

Your program must produce output identical to that of the script above. You should output one word per line, and the number of words should be consistent with the original script.

It is permissible to include non-newline whitespace characters at the end of each line (but not at the beginning) since they are invisible. One additional newline character is permissible at the very end of the output.

Examples

Input: 0
Output:


Input: 1
Output:
Yeah
But

Input: 2
Output:
Yeah
But
No

Input: 10
Output:
Yeah
But
No
But
Yeah
But
No
Yeah
But
No
But
Yeah

maxb

Posted 2018-09-12T07:59:37.640

Reputation: 5 754

3Can we return a list of lines? – Jo King – 2018-09-12T08:20:33.263

1@JoKing if your language allows it. I'm not 100% sure on the rules, but I think it's permissible to have a function return a list of lines in Python, which can then be joined in the footer. – maxb – 2018-09-12T08:31:30.127

10It must entertaining to work with such a funny chap! :s On a slightly more serious note: the nrOfButs variable is rather poorly-named and misleading. Nice simple challenge anyway. – Arnauld – 2018-09-12T09:54:47.387

1@Arnauld I contemplated renaming the variable before posting the challenge, but I wanted to stay true to the source. – maxb – 2018-09-12T10:00:47.253

10Do we get a bonus if the last line is "God can't believe you just said that!" – Ciaran_McCarthy – 2018-09-12T10:24:47.427

1Shouldn't the output be "Yeah / No / But / Yeah / But / Yeah..."? – Erik the Outgolfer – 2018-09-12T15:33:21.547

3@EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied. – dzaima – 2018-09-12T15:35:20.733

4The most Australian codegolf yet? Except it should be "nah" – Nacht - Reinstate Monica – 2018-09-13T02:00:12.293

3

@Nacht This is surely a Little Britain reference, no? That was my assumption, anyway.

– JBentley – 2018-09-14T00:32:11.523

2Has anyone noticed yet that this script is not only hideously verbose but also incorrect? The actual number of buts is only half of the demanded nrOfButs! (except for input 1) – Titus – 2018-09-14T06:35:14.740

1We must not handle faulty input? So I disqualify if I do? – Ingo Bürk – 2018-09-14T12:53:41.103

@IngoBürk Darn it, you got me. Now I'll have to disqualify you – maxb – 2018-09-14T13:13:36.623

In the input=10 example, there is a "No" immediately followed by a "Yeah". Is that intended? – JDL – 2018-09-14T14:07:50.570

@JDL yes and no. My colleague wrote the code in a slack post, probably without ever running it himself. I chose to keep the code as is, which makes it "intended", I guess. – maxb – 2018-09-14T14:11:46.453

okay --- so we are reproducing specifically that code, not the first n words of "yeah but no but" repeated ad infinitum. – JDL – 2018-09-14T14:13:24.180

1@JDL Exactly! I've had quite a few answers that didn't look at the code above, but instead just printed n lines of "Yeah But No". Those are not valid answers, as the challenge is to accurately imitate the code above. – maxb – 2018-09-14T14:14:55.867

@maxb One more serious note: "And since it is common knowledge that a shorter program is faster to write..." Here it is common knowledge that in code golfing, a shorter program is slower to write. – trolley813 – 2018-09-17T09:56:22.687

@trolley813 it should be faster to write, since the only limiting factor is the number of keystrokes. No I understand your point, I was just being sarcastic. – maxb – 2018-09-17T10:16:06.217

Answers

48

Excel, 78 bytes

Assumes input in cell A1, and that Wordwrap formatting is turned on for cell. Use Alt+Enter to add line feeds within the string and note the whitespace. Only handles input up to 3570 due to limit of REPT function (Good luck getting a cell to be that tall, though).

=LEFT(REPT("Yeah
But
No      
But     
Yeah    
But
No           
",595),A1*9)

Reprinting, with periods for whitespace

=LEFT(REPT("Yeah
But
No......
But.....
Yeah....
But
No...........
",595),A1*9)

How it works: The pattern repeats every 6 numbers:

0 = Yeah and But      Yeah + linefeed + But + linefeed
1 = No                No + 6 whitespace + line feed
2 = But               But + 5 whitespace + linefeed
3 = Yeah              Yeah + 4 whitespace + linefeed
4 = But and No        But + linefeed + No + 3 whitespace
5 = Blank             8 whitespace + linefeed

Each of these can be expressed with 9 characters, so a string is made of 54 characters (9 * 6), then repeated as large as Excel will allow. Then it takes the left 9 * (number of input) characters as the output.

Linefeed for the "but and no" one is placed after the blank so that the Yeah for #6, #12, (etc) is formatted to the left rather than the right, and so that there is no blank linefeed added every 6th line for that item.

Output

Keeta - reinstate Monica

Posted 2018-09-12T07:59:37.640

Reputation: 938

1I have no way of verifying this, but your description makes it seem correct. Can you add some example input/output pairs? One of the more ridiculous languages, but great answer nonetheless. – maxb – 2018-09-12T14:09:57.820

16@maxb Can't be all that ridiculous when it is beating other languages. – Keeta - reinstate Monica – 2018-09-12T14:21:09.833

1Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1 – ElPedro – 2018-09-12T17:32:33.047

20

JavaScript (ES6), 59 57 bytes

f=n=>n?f(n-1)+[s=n&1?`But
`:'',`Yeah
`+s,s+`No
`][n%3]:''

Try it online!

How?

We use a recursive function which goes from \$n\$ to \$1\$ rather than from \$0\$ to \$n-1\$.

As a result, the tests are off by \$1\$ compared to the reference code:

  • if \$n\equiv1\pmod 3\$, output "Yeah"
  • if \$n\equiv1\pmod 2\$, output "But"
  • if \$n\equiv2\pmod 3\$, output "No"

This allows us to store the simpler case \$n\equiv0\pmod 3\$ as the first entry of our lookup array, where we can define \$s\$: a variable holding either "But\n" or an empty string.

The two other entries are defined as "Yeah\n" + s and s + "No\n" respectively.

Note: By iterating from \$n-1\$ to \$0\$, we could define \$s\$ in the first entry just as well, but that would cost two extra parentheses.

Commented

f = n =>            // n = input
  n ?               // if n is not equal to 0:
    f(n - 1) +      //   prepend the result of a recursive call with n - 1
    [               //   define our lookup array:
      s = n & 1 ?   //     1st entry: if n is odd:
        `But\n`     //       set s to "But"
      :             //     else:
        '',         //       set s to an empty string
      `Yeah\n` + s, //     2nd entry: "Yeah" followed by s
      s + `No\n`    //     3rd entry: s followed by "No"
    ][n % 3]        //   append the correct entry for this iteration
  :                 // else:
    ''              //   return an empty string and stop recursion

Arnauld

Posted 2018-09-12T07:59:37.640

Reputation: 111 334

17

LOLCODE, 257 bytes

HAI 1.2
I HAS A B
GIMMEH B
B IS NOW A NUMBR
I HAS A C ITZ 0
IM IN YR L UPPIN YR C TIL BOTH SAEM B AN C
I HAS A D ITZ MOD OF C AN 3
D
WTF?
OMG 0
VISIBLE "Yeah"
OIC
MOD OF C AN 2
WTF?
OMG 0
VISIBLE "But"
OIC
D
WTF?
OMG 1
VISIBLE "No"
OIC
IM OUTTA YR L
KTHXBYE

Try it online!

JosiahRyanW

Posted 2018-09-12T07:59:37.640

Reputation: 2 600

2It looks awesome (I would hate to code this!), but in test case 10 the 2nd "No" and 3rd "But" get flipped... So Yeah, but no :D – seadoggie01 – 2018-09-13T03:23:58.440

2Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now. – JosiahRyanW – 2018-09-13T06:45:26.913

1I love the way it reads – LocustHorde – 2018-09-13T15:51:30.007

4Does VISIBLE "But" refer to the program's lack of trousers? – JDL – 2018-09-14T14:03:25.840

12

Whitespace, 315 304 300 277 276 bytes

Thanks to @JoKing for -11 bytes (reducing the amount of labels used from 8 to 7), and -24 more bytes (changing the general flow of the program and reducing the amount of labels used from 7 to 5 in the process).

[S S S N
_Push_0][T  N
T   T   _Read_STDIN_as_integer][N
S S N
_Create_Label_LOOP][S S S N
_Push_0][T  T   T   _Retrieve][N
T   S S N
_If_negative_jump_to_Label_PRINT][S S S N
_Push_0][T  T   T   _Retrieve][S S S T  T   N
_Push_3][T  S T T   _Modulo][S S S T    S N
_Push_2][T  S S T   _Subtract][N
T   T   T   N
_If_negative_jump_to_Label_SKIP_NO][S S T   T   S T T   T   T   S N
_Push_-94_\n][S S S T   T   T   N
_Push_7_o][S S T    T   T   S T S N
_Push_-26_N][N
S S T   N
_Create_Label_SKIP_NO][S S S N
_Push_0][T  T   T   _Retrieve][S S S T  S N
_Push_2][T  S T T   _Modulo][N
T   S S S N
_If_0_jump_to_Label_SKIP_BUT][S S T T   S T T   T   T   S N
_Push_-94_\n][S S S T   T   S S N
_Push_12_t][S S S T T   S T N
_Push_13_u][S S T   T   S S T   T   S N
_Push_-38_B][N
S S S S N
_Create_Label_RETURN_FROM_BUT][S S S N
_Push_0][S N
S _Duplicate_0][S N
S _Duplicate_0][T   T   T   _Retrieve][S S S T  N
_Push_1][T  S S T   _Subtract][T    T   S _Store][T T   T   _Retrieve][S S S T  T   N
_Push_3][T  S T T   _Modulo][N
T   S S T   N
_If_0_jump_to_Label_YEAH][N
S N
N
_Jump_to_Label_LOOP][N
S S S T N
_Create_Label_YEAH][S S T   T   S T T   T   T   S N
_Push_-94_\n][S S S N
_Push_0_h][S S T    T   T   T   N
_Push_-7_a][S S T   T   T   N
_Push_-3_e][S S T   T   T   T   T   N
_Push_-15_Y][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_PRINT][S S S T    T   S T S S S N
_Push_104][T    S S S _Add][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Whitespace is definitely not the right language for this challenge.. In Whitespace both loops and if-statements are made with labels and jumps to labels, and since they aren't if-elseif-else cases but multiple if-cases, it means I will have to jump back after every if, making it quite long it means I will have to slightly modify the checks to skip over some prints (thanks @JoKing).

Explanation in pseudo-code:

Read STDIN as integer, and store it in the heap
Start LOOP:
  Integer i = retrieve integer from heap
  If(i is negative):
    Call function PRINT
  If(i modulo-3 is NOT 2):
    Jump to Label SKIP_NO
  Push "\noN" to the stack
  Label: SKIP_NO
  If(i modulo-2 is 0):
    Jump to Label SKIP_BUT
  Push "\ntuB" to the stack
  Label: SKIP_BUT
  i = i - 1
  Replace i in the heap with this updated value
  If(i modulo-3 is 0):
    Call function YEAH
  Go to next iteration of LOOP

function YEAH:
  Push "\nhaeY" to the stack
  Go to next iteration of LOOP

function PRINT:
  Print top of the stack as character to STDOUT
  Go to next iteration of LOOP (which will enter the if and then
                                comes back to this PRINT again)

Additional explanation:

In general, it loops from the input down to 0, pushing a newline and the word reversed (so in the order "\noN", "\ntuB", "\nhaeY" instead of "Yeah\n", "But\n", "No\n"). And after the input has looped down to 0 and all the characters are on the stack, it will print those characters in reverse (so the correct output order).

More in depth however: Although we need to print words in the range (input, 0], it will loop in the range [input, 0) instead. Because of this, we can use the check if(i%3 == 2) for "\noN" (or actually, if(i%3 != 2) skip the pushing of "\noN"), and we use the check if(i%2 != 1) for "\ntuB" (or actually, if(i%2 == 0) skip the pushing of "\ntuB"). Only after these two checks we decrease the iteration i by 1. And then do the check if(i%3 == 0) to push "\nhaeY", similar as in the JS example code in the challenge description. Skipping with if-not checks instead of going to a label and return from the label with if-checks saved 23 bytes.

Also, in Whitespace character values are stored in the stack as their unicode values (i.e. 10 for new-lines, 65 for 'A', 97 for 'a', etc.). Since I already need to loop over the stack to print the characters, I am also able to use my Whitespace tip to lower the byte-count by adding a constant to the number values, before printing them as characters.
This constant is 104 in this case, which is generated with this Java program that I've also used to golf another Whitespace answer of mine before. That's also the reason why this part of the code:

[S S T  T   S T T   T   T   S N
_Push_-94_\n][S S S T   T   T   N
_Push_7_o][S S T    T   T   S T S N
_Push_-26_N]

has the values -94 for the newline, 7 for the 'o', and -26 for the 'N'. Because adding the constant of 104 will correctly give our unicode values 10, 111, and 78 for these characters respectively.

Kevin Cruijssen

Posted 2018-09-12T07:59:37.640

Reputation: 67 575

1I most certainly did not expect a Whitespace answer. Good job! – maxb – 2018-09-12T12:31:21.450

@maxb Thanks! Unfortunately it's quite a bit longer than expected due to the 8 labels it requires.. But I'm already happy it's working. :) – Kevin Cruijssen – 2018-09-12T12:37:20.467

Couldn't you halve the labels by skipping to the next if statement if the condition is false? e.g. if i modulo-3 != 1 jump to next if else push NO – Jo King – 2018-09-12T13:15:18.423

@JoKing In Whitespace unfortunately not. Whitespace only has three types of jumps for labels: "Jump unconditionally" (this is usually used for loops, or to return from a conditional jump), "Jump if the top of the stack is 0" (which is what I mainly used in my answer with the modulos), "Jump if top of the stack is negative" (which is what I've used to stop the outer loop in this case). Unfortunately there isn't any "Jump if top of the stack is positive" or "Jump if top of the stack is NOT 0/negative" available.. (PS: The i%3==1 case is done by subtracting 1 and using the "Jump if 0".) – Kevin Cruijssen – 2018-09-12T13:20:58.473

Okay, throwing stuff at the wall to see what sticks. Can you jump straight from the end of the Yeah function to the start of the loop? Can you move the check if printing time to the yeah function (since that's always last), thereby allowing you to move the i = i-1 lower in the loop and utilise the method I mentioned before for the first two push sections? – Jo King – 2018-09-12T13:51:02.413

@JoKing That first suggestion is indeed a great one. Instead of going to the RETURN_FROM_YEAH and then going to the next iteration of the LOOP, I can jump directly to the next iteration of the LOOP from the YEAH function. Will do that in a moment. – Kevin Cruijssen – 2018-09-12T14:06:43.377

@JoKing As for your second suggestion I'm not sure I follow. One concern is that it's not guaranteed to enter the functions for every iteration, so putting i = i-1 inside the YEAH function for iteration i = 9 for example would mean it will never decrease i and gets stuck in an infinite loop. Also, the range in the challenge is [0, n) (or (n, 0] in my case since I loop backwards), so doing the i = i-1 at the end of the loop iteration would mean it changes to [n, 0] instead, making the input inclusive. – Kevin Cruijssen – 2018-09-12T14:07:44.523

i meant moving it to after the return from BUT label. Theoretically you could then change the first if to if i%3 -2 < 0 jump to return from NO and the second to if i%2 == 0 jump to return from BUT. Then you could sub the corresponding functions inside without having to jump around – Jo King – 2018-09-12T14:15:11.467

It's really hard to edit existing whitespace code, but something like this?

– Jo King – 2018-09-13T08:28:58.520

@JoKing That does indeed look very promising and quite a bit shorter. I only see two small issues, but both are easily fixed. You now do if(i is 0) call PRINT first before retrieving i from the heap (probably by accident), so simply changing that order should fix it. And the other is with input = 10 the range should be (10,0) (excluding on both ends) but is [10,0) (including input) now. But I have a solution in mind. Will start trying to implement your pseudo-code and see what the total byte-count will become. :) – Kevin Cruijssen – 2018-09-13T09:51:01.543

1@JoKing Ah wait, I misunderstood a part of your pseudo-code. My first issue about not retrieving i before the if(i is 0) call PRINT is true, but your other is checking the i before subtracting it and skipping over the prints. Pretty smart actually. Will continue implementing it. – Kevin Cruijssen – 2018-09-13T10:00:12.663

@JoKing Thanks! -23 bytes right there. :D – Kevin Cruijssen – 2018-09-13T10:38:54.443

Would jumping to the start of the loop instead of jumping to the print label save bytes? Also, can't you have an empty label? – Jo King – 2018-09-13T11:13:41.993

@JoKing What do you mean by the first part? The Loop puts all the values in reverse on the stack, and the Print-loop prints them one by one (by adding a constant). When would I need to jump to the start of the loop when printing? And I already use an empty label. :) The five labels I now use are: PRINT (3x): empty label; LOOP (3x): label S; SKIP_NO (2x): label T; SKIP_BUT (2x): label SS; YEAH (2x): label ST. – Kevin Cruijssen – 2018-09-13T12:33:36.420

1Well, if you jump to the start of the loop, it will run the if statement again and jump straight back to the print function. Maybe this saves a byte if you change the loop label to the empty label – Jo King – 2018-09-13T12:40:01.167

@JoKing Oh, that's what you mean. Hmm, that does sound like it could work indeed (EDIT: It indeed does. :D). Then it will go from PRINT to LOOP to PRINT again since the if-statement is still the same, to LOOP, etc. saving 1 byte with this detour due to the empty LOOP label we go to, instead of the 1-byte S (PRINT) label we go to directly. Smart! – Kevin Cruijssen – 2018-09-13T12:49:31.847

11

Perl 6, 63 50 bytes

{<<"Yeah But"No But Yeah"But No">>[^$_ X%6].words}

Try it online!

Anonymous code block that takes a number and returns a list of lines

Explanation:

{                                                }   # Anonymous code block
 <<"Yeah But"No But Yeah"But No">>  # Create the list of strings:
                                     # Yeah But
                                     # No
                                     # But
                                     # Yeah
                                     # But No
                                  [       ]  # Index into this list
                                   ^$_  # The range from 0 to n-1
                                       X%6  # All modulo 6
                                           .words  # Convert the list to a string 
                                                   # Which joins by spaces
                                                   # And split by whitespace

Jo King

Posted 2018-09-12T07:59:37.640

Reputation: 38 234

11

Python 3, 85 82 bytes

def f(n):
 for i in range(n):yield from['Yeah'][i%3:]+['But'][i%2:]+['No'][i%3^1:]

Try it online!


Python 3, 79 76 bytes

Port of Keeta's Excel answer.

lambda n:(f"""Yeah
But
No      
But     
Yeah    
But
No{'':11}
"""*n)[:9*n]

Try it online!

ovs

Posted 2018-09-12T07:59:37.640

Reputation: 21 408

8

C (gcc), 75 bytes

f(o,_){for(_=0;o-_;_++%3-1||puts("No"))_%3||puts("Yeah"),1&_||puts("But");}

Try it online!


C (gcc), 60 + 11 = 71 bytes (using -D$=||puts()

f(o,_){for(_=0;o-_;_++%3-1 $"No"))_%3 $"Yeah"),1&_ $"But");}

Try it online!

Jonathan Frech

Posted 2018-09-12T07:59:37.640

Reputation: 6 681

8

05AB1E (legacy), 27 25 24 bytes

Saved 1 byte thanks to Kevin Cruijssen.

F”¥æ€³€¸”#N3ÖNÈN3%‚‚˜Ï`»

Try it online!

Explanation

F                          # for N in [0 ... input] do:
 ”¥æ€³€¸”#                 # push ['Yeah', 'But', 'No']
          N3Ö              # push N % 3 == 0
             NÈ            # push N % 2 == 0
               N3%         # push N % 3
                  ‚‚˜      # add the 3 numbers to a list
                     Ï     # keep only the strings whose corresponding value  
                           # in the int list is true (1)
                      `»   # push strings separately to stack and join stack on newlines

Emigna

Posted 2018-09-12T07:59:37.640

Reputation: 50 798

Dang, you beat me to it.. Was about to post an answer. Yours is shorter anyway, so +1 from me.. Nice use of ×, hadn't thought about that! – Kevin Cruijssen – 2018-09-12T08:27:15.987

Wow, I'd love an explanation on this one. My personal best was 44 bytes in CJam. – maxb – 2018-09-12T08:29:54.147

@maxb: I will of course add an explanation. I'm just checking to see if I can golf it down some more first ;) – Emigna – 2018-09-12T08:30:37.613

You can remove the Θ now that you're no longer using ×, since Ï will only look at 1s only, so it ignores the 2 (and 0 of course). – Kevin Cruijssen – 2018-09-12T09:32:42.410

@KevinCruijssen: Thanks! Not sure how I missed that :P – Emigna – 2018-09-12T09:51:59.603

7

Python 2, 73 bytes

lambda n:'\n'.join((["Yeah\nBut","No","But","Yeah","But\nNo"]*n)[:n-n/6])

Try it online!

Lynn

Posted 2018-09-12T07:59:37.640

Reputation: 55 648

6

Python 2, 97 95 92 90 83 81 bytes

lambda n:[w for i in range(n)for w in'Yeah','But','No'if('N'in w)==i%(3-(w<'N'))]

Try it online!

-2 bytes, thanks to ovs


Python 3, 92 90 85 83 bytes

lambda n:[w for i in range(n)for w in['Yeah','But','No']if('N'in w)==i%(3-(w<'N'))]

Try it online!

-4 bytes, thanks to ovs

-4 bytes, thanks to Jo King

TFeld

Posted 2018-09-12T07:59:37.640

Reputation: 19 246

86 bytes by combining the two and returning as a list of lines – Jo King – 2018-09-12T13:09:23.820

@JoKing Thanks, didn't know that I could return instead of printing when wrote it. – TFeld – 2018-09-12T13:14:07.620

82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N') – ovs – 2018-09-12T13:22:05.090

6

Canvas, 27 bytes

{╷⌐3%‽YeahP}2%‽ButP}3%╷‽NoP

Try it here!

dzaima

Posted 2018-09-12T07:59:37.640

Reputation: 19 048

6

Groovy (function), 79 bytes

Since initially submitting my answer, I've looked through some historic discussions here about what constitutes a suitable answer. Since it seems commonly accepted to provide just a method in Java (including return type and parameter declarations), here is a shorter, Groovy, method which has the method return value be the answer. Use of def means that the return type is inferred.

def a(int n){n?a(--n)+(n%3?'':'Yeah\n')+(n%2?'':'But\n')+(n%3==1?'No\n':''):''}

Unlike the original answer below, which loops from 0 up to n-1, this one calls itself from n down to 1, but decrements the input for the rest of the line in the recursive call.

Try it online!

Groovy (program), 87 bytes

Groovy scripts don't require certain common imports, so this can be a program printing the answer to Java's STDOUT without having to declare System.out. before print. It also provides some common utility methods, such as this toLong() which allows us to parse the input argument reasonably consicely.

Essentially the Java 10 answer, but leveraging Groovy's shorter loop syntax and ability to evaluate truthy statements.

args[0].toLong().times{print((it%3?'':'Yeah\n')+(it%2?'':'But\n')+(it%3==1?'No\n':''))}

Try it online!

archangel.mjj

Posted 2018-09-12T07:59:37.640

Reputation: 81

Welcome to PPCG! Great first answer! I haven't coded any Groovy myself, but might I suggest running your code on TIO? That way, it can be validated by others, and enjoyed by all.

– maxb – 2018-09-12T15:20:35.460

1@maxb Thanks! I've added one :) – archangel.mjj – 2018-09-12T15:29:52.313

Nice first answer and also welcome to PPCG. – ElPedro – 2018-09-12T18:03:59.120

5

Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeah\n":"")+(i%2<1?"But\n":"")+(++i%3>1?"No\n":""));}

-1 byte thanks to @OlivierGrégoire.

Try it online.

Explanation:

n->{                   // Method with integer parameter and no return-type
  for(int i=0;i<n;)    //  Loop `i` in the range [0, `n`)
    System.out.print(  //   Print to STDOUT:
      (i%3<1?          //    If `i` is divisible by 3:
        "Yeah\n"       //     Print "Yeah" with newline
      :"")+(i%2<1?     //    If `i` is even:
        "But\n"        //     Print "But" with newline
      :"")+(++i%3>1?   //    If `i` modulo-3 is 1:
        "No\n"         //     Print "No" with newline
      :                //    If none of the above three if's applied to the current `i`:
       ""));}          //     Print nothing for the current `i`

Kevin Cruijssen

Posted 2018-09-12T07:59:37.640

Reputation: 67 575

1++i%3>1 will likely save you a byte – Olivier Grégoire – 2018-09-12T22:56:53.297

@OlivierGrégoire Ah, of course. Thanks! – Kevin Cruijssen – 2018-09-13T07:40:01.937

5

Retina 0.8.2, 45 bytes

.+
$*
1
$`Yeah¶$`But¶$`11No¶
+`11B
B
111

A`1

Try it online! Explanation:

.+
$*

Convert the input to unary.

1
$`Yeah¶$`But¶$`11No¶

For each integer 0...n-1, generate three lines of text, one for each word, each with i 1s before it, except for No, which has two extra 1s so that we calculate (i+2)%3==0 which is equivalent to i%3==1.

+`11B
B

Remove pairs of 1s before Bs.

111

Remove 1s in groups of three everywhere else.

A`1

Delete all lines that still have a 1.

Neil

Posted 2018-09-12T07:59:37.640

Reputation: 95 035

Oh, now that I see 11No¶ to calculate (i+2)%3==0 (so all three are if-checks for ==0) it looks so obvious, but I wouldn't have thought of that myself, so it's actually quite ingenious. +1 from me, nice answer! – Kevin Cruijssen – 2018-09-12T12:51:34.627

5

Powershell, 75 74 72 67 66 bytes

-1 byte thanks TessellatingHeckler

param($n)(" Yeah
But No But Yeah But
No "*$n-split' ')[1..$n]-ne''

Test script and explanation:

$f = {

param($n)(" Yeah
But No But Yeah But
No "*$n-split' ')[1..$n]-ne''

# 1. repeat the string $n times
# 2. split by space
# 3. get elements from 1 to $n
# some elements are multiline strings, some elements are $null:
# ($null,"Yeah`nBut","But","No","But","Yeah","But`nNo",$null,...)
# 4. remove $null elements from result array

}

# Output results
@(
    0,1,2,10
) | % {
    &$f $_
    "======"
}

# Advanced test
@(
    ,(0,'')
    ,(1,'Yeah But')
    ,(2,'Yeah But No')
    ,(3,'Yeah But No But')
    ,(4,'Yeah But No But Yeah')
    ,(5,'Yeah But No But Yeah But No')
    ,(6,'Yeah But No But Yeah But No')
    ,(7,'Yeah But No But Yeah But No Yeah But')
    ,(8,'Yeah But No But Yeah But No Yeah But No')
    ,(9,'Yeah But No But Yeah But No Yeah But No But')
    ,(10,'Yeah But No But Yeah But No Yeah But No But Yeah')
    ,(20,'Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No')
) | % {
    $n,$e = $_
    $r = &$f $n
    $r = $r-split"`n"       # simplify test string
    "$($e-eq$r): $n : $r"
}

Output:

======
Yeah
But
======
Yeah
But
No
======
Yeah
But
No
But
Yeah
But
No
Yeah
But
No
But
Yeah
======
True: 0 :
True: 1 : Yeah But
True: 2 : Yeah But No
True: 3 : Yeah But No But
True: 4 : Yeah But No But Yeah
True: 5 : Yeah But No But Yeah But No
True: 6 : Yeah But No But Yeah But No
True: 7 : Yeah But No But Yeah But No Yeah But
True: 8 : Yeah But No But Yeah But No Yeah But No
True: 9 : Yeah But No But Yeah But No Yeah But No But
True: 10 : Yeah But No But Yeah But No Yeah But No But Yeah
True: 20 : Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No

Straightforward script, 72 bytes:

$args|?{$_}|%{0..--$_|%{@('Yeah')[$_%3]
@('But')[$_%2]
@{1='No'}[$_%3]}}

mazzy

Posted 2018-09-12T07:59:37.640

Reputation: 4 832

1Great answer! Would it be possible to add some output to the answer, since it doesn't include an online interpreter? – maxb – 2018-09-12T13:36:01.927

The answer scriptblock does not return ======. It generates Yeah,But,No strings only. The test script shows a separator for easier reading of the results only. – mazzy – 2018-09-12T14:10:57.080

That hashtable usage is clever. I'm going to need to remember that. – AdmBorkBork – 2018-09-12T18:35:34.217

@maxb - a tio.run online interpreter link for the 67 byte answer

– TessellatingHeckler – 2018-09-17T05:07:24.043

1@mazzy I can reformulate yours, but still can't beat 67 (replace the two \n with real newlines) (" Yeah\nBut No But Yeah But\nNo "*($j="$args")|% s*t 32)[1..$j]-ne'' – TessellatingHeckler – 2018-09-17T05:49:31.497

nice split. it saves a byte. – mazzy – 2018-09-17T07:45:34.340

4

C# (Visual C# Interactive Compiler), 105 99 94 96 89bytes

i=>{for(int x=0;x<i;)Write((x%3<1?"Yeah\n":"")+(x%2<1?"But\n":"")+(x++%3==1?"No\n":""));}

Try it online!

auhmaan

Posted 2018-09-12T07:59:37.640

Reputation: 906

4

Removing the interpolation like this saves 7 bytes.

– Emigna – 2018-09-12T10:43:52.970

@Emigna Thanks for the tip, changed the answer – auhmaan – 2018-09-12T16:33:05.497

1x++%3==1? can be ++x%3>1?. Someone else just tipped it for my Java answer, but the same applies to your C# answer. :) – Kevin Cruijssen – 2018-09-13T07:41:02.727

4

Haskell, 71 bytes

f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No"
(a?b)c n=[c|n`mod`a==b]

Try it online!

Explanation

Pretty simple, saved two bytes by using [1..n] instead of [0..n-1] and adjusted the remainders: The operator (?) tests takes four arguments, returning an empty list or the provided string as a singleton if the result is correct.

By currying the fourth argument of (?) we can make use of (<>) to concatenate the results of each function, ie.:

(3?1)"Yeah" <> (2?1)"But" <> (3?2)"No" ≡ \i-> (3?1)"Yeah" i ++ (2?1)"But" i ++ (3?2)"No" i

ბიმო

Posted 2018-09-12T07:59:37.640

Reputation: 15 345

4

Pip, 37 35 33 bytes

"But 
Yeah
No
"<>5@:^[t2io02x]@<a

(Note the space after But.) Takes input as a command-line argument. Try it online!

Explanation

This explanation is for the previous version--see below for changelog

Inspired by Jo King's Perl 6 answer. We construct this list:

[
 "Yeah
 But
 ";
 "No
 ";
 "But
 ";
 "Yeah
 ";
 "But
 No
 ";
 ""
]

and output the first a elements of it using cyclic indexing.

[t2io02x]R,3["But""Yeah""No"].n@<:a
                                     i is 0; o is 1; t is 10; x is ""; n is newline;
                                     a is 1st cmdline arg (implicit)
[       ]                            Construct this list of scalars:
 t                                    10
  2                                   2
   i                                  0
    o                                 1
     02                               02
       x                              <empty string>
         R                           Treating each of these as a string, we're going to
                                     replace:
          ,3                          0, 1, and 2 (respectively)
                                     with the corresponding values from this list:
            ["But""Yeah""No"].n       These strings, each with a newline appended
                                     We now have constructed the list shown above
                               @<:a  Take the first a elements from this list, with
                                     cyclical indexing (the : is for parsing reasons)
                                     Concatenate them together and print (implicit)

Update: I realized that I don't need to use replace to change 0/1/2 into strings--I can use those numbers to index into a list directly. To do this, we have to make sure the multi-digit numbers are split into lists of their digits (otherwise, we'll be selecting index 10 instead of indexes 1 and 0). Fortunately, using an arbitrarily nested list as an index in Pip works as expected, giving a (nested) list of results. For input of 3, we get this data progression (where _ represents a newline):

"But _Yeah_No_"<>5                       ["But _"; "Yeah_"; "No_"]
                     [t2io02x]           [10; 2; 0; 1; 02; ""]
                              @<a        [10; 2; 0]
                    ^                    [[1; 0]; [2]; [0]]
                  @:                     [["Yeah_"; "But _"]; ["No_"]; ["But _"]]

As before, the final result is concatenated together and autoprinted.

DLosc

Posted 2018-09-12T07:59:37.640

Reputation: 21 213

4

Attache, 48 bytes

Flat##{Mask[_%3'2'3=0'0'1,$Yeah'$But'$No]}=>Iota

Try it online!

Explanation

Flat##{Mask[_%3'2'3=0'0'1,$Yeah'$But'$No]}=>Iota   input: an integer
      {                                  }=>Iota   over each number from 0 to that integer exclusive
       Mask[             ,$Yeah'$But'$No]          select values from that array according to:
            _%3'2'3                                    whether or not the input mod 3, 2, 3
                   =0'0'1                              is 0, 0, 1
Flat##                                             flatten the intermediate results

Conor O'Brien

Posted 2018-09-12T07:59:37.640

Reputation: 36 228

4

C (gcc), 77 71 74 72 69 bytes

There's already a better C answer here but this one is recursive and it took me some time to get straight so I'm posting it.

Down to 69 bytes thanks to both @ceilingcat and @JonathanFrech

(I never think to use n-~-i in place of n-i+1)

i;f(n){i=n&&n-i>=~n/6&&f(n,i++,puts(i%7%4?i%7%2?"But":"No":"Yeah"));}

Try it online!

cleblanc

Posted 2018-09-12T07:59:37.640

Reputation: 3 360

@JonathanFrech Nice but doesn't work for zero, or 5 – cleblanc – 2018-09-18T17:04:58.007

@cleblanc Oh, sorry. Did not realize ... At least removing j saved you two bytes. – Jonathan Frech – 2018-09-18T17:46:26.047

170 bytes -- incorporating @ceilingcat's one saved byte. – Jonathan Frech – 2018-09-18T18:01:22.373

1n-~-i is equivalent to n-i+1 -- not i<n+1 -- and so does not actually save any bytes ... – Jonathan Frech – 2018-09-18T19:16:59.187

3

sed -E, 179 150 bytes

/^0/!s:$:g:
:l;y:abcdefg:bcdefga:
/[ae]/iYeah
/[bdf]/iBut
/[cg]/iNo
s:.$:-&:;:s;s:0-:-9:;ts;h
y:123456789:012345678:;G
s:.*(.)-.*\n(.*).-:\2\1:;tl;c\ 

The hardest part was not to construct the list but to actually parse the decimal number.

2 bytes may be saved if the newline at the end is not required: c\ d.

Still requires optimization.

Try it online.

Explanation

/^0/!                            | if the input number doesn`t begin with a '0'…
     s:$:g:                      | …then append a 'g' to it and proceed
                                 |
:l;                              | loop label 'l':
   y:abcdefg:bcdefga:            | shift all occurences of [abcdef] 1 letter forward, and all 'g'-s to 'a'-s
                                 |
/[ae]/                           | if there`s an 'a' or 'e' in the input…
      iYeah                      | …output 'Yeah'
                                 |
/[bdf]/                          | if there`s a 'b' or 'd' or 'f' in the input…
       iBut                      | …output 'But'
                                 |
/[cg]/                           | if there`s a 'c' or 'g' in the input…
      iNo                        | …output 'No' 
                                 |
s:.$:-&:;                        | insert '-' before the last character
         :s;                     | loop label 's':
            s:0-:-9:;            | transform the next consecutive '0' in the end of the number to '9', if any
                     ts;         | loop to 's' if more consecutive zeroes are available
                        h        | copy the result to the temporary buffer
                                 |
y:123456789:012345678:;          | decrement all digits except '0' (N.B.: digits, not numbers)
                       G         | append the temporary buffer to the result
                                 |
s:.*(.)-.*\n(.*).-:\2\1:;        | cut and replace the digit left to the last consecutive 0 in the original
                                 | number pasted from the temporary buffer, then discard all other digits decremented
                         tl;     | …then loop to 'l' if the number is ≥0
                            c\   | insert a carriage return and exit

hidefromkgb

Posted 2018-09-12T07:59:37.640

Reputation: 211

Can you add some explanations please ? – user285259 – 2018-09-21T08:30:01.820

1@user285259 Done. – hidefromkgb – 2018-09-21T13:21:56.747

3

Ruby, 69 72 74 Bytes

->y{puts *(1..y).map{|i|[i%3==1&&:Yeah,i%2>0&&:But,i%3>1&&:No]-[!0]}}

Very straight-forward answer, checking for a shorter, recursive method right now.

Saved two bytes thanks to @BWO :)

Saved another three bytes by using symbols instead of strings

Håvard Nygård

Posted 2018-09-12T07:59:37.640

Reputation: 341

3

Python 3, 93 bytes

[print("Yeah\n"*(i%3<1)+"But\n"*(i%2<1)+"No\n"*(i%3==1),end="")for i in range(int(input()))]

This isn't exactly the best solution but it's my take on it.

Try it online!

Josh B.

Posted 2018-09-12T07:59:37.640

Reputation: 105

1If you already have an expression you can use in a list comprehension but your list comprehension only exists to evoke that expression's side effects, a plain for loop requires less bytes. – Jonathan Frech – 2018-09-14T02:21:48.217

3

R, 65 bytes

cat(c("yeah","but","no")[c(3,1:3,2,1,2)][1:scan()%%7+1],sep="\n")

Due to the fact that we are replicating a slightly flawed program (it misses out every fourth "but" — it should have used %4 == 1 and %4 == 3 rather than %3 conditions), we have to use an awkward call to c and work in base seven. Still, it's shorter than LOLCODE...

(I was hoping that (3,1,2,3,2,1,2) or a similar permutation might appear in the lh dataset somewhere but it doesn't look like it)

JDL

Posted 2018-09-12T07:59:37.640

Reputation: 1 135

2

Python 2, 93 92 83 bytes

lambda i:''.join('Yeah\n'*(x%3<1)+'But\n'*(x%2<1)+'No\n'*(x%3==1)for x in range(i))

Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

ElPedro

Posted 2018-09-12T07:59:37.640

Reputation: 5 301

You could use string repetition instead of tuple indexing -- ('','Yeah\n')[x%3<1] is equivalent to "Yeah\n"*(x%3<1). – Jonathan Frech – 2018-09-16T10:34:34.377

@JonathanFrech - very cool! Similar technique can be applied to the other cases as well. Many thanks! – ElPedro – 2018-09-17T08:10:18.493

2

Clean, 116 bytes

import StdEnv,Data.List
r=cycle
$n=[e\\_<-[1..n]&a<-r["Yeah","",""]&b<-r["But",""]&c<-r["","No",""],e<-[a,b,c]|e>""]

Try it online!

Οurous

Posted 2018-09-12T07:59:37.640

Reputation: 7 916

2

VBA (Excel), 105, 101, 99 Bytes

Edit: -4 bytes from Keeta! Thanks!

Edit 2: -2 bytes from Chronocidal! Woot! (Realized that test cases only worked for 10. Fixed now)

Yeah, Excel beat VBA this time. Whatever. (We're coming for you)

d=vbCr:For i=1To[a1]:a=i Mod 3:?IIf(a=1,"Yeah"+d,"")IIf(i/2=i\2,"","But"+d)IIf(a=2,"No"+d,"");:Next

^This is pasted into the Immediate window and outputs to the debug window

Ungolfed

d = vbCr
'For 1 to the value in A1 (using 0 gave extra values, and VBA skips the for loop if 0)
For i = 1 To [a1]    'aka: Range("A1").value
    a = i mod 3
    '? is the same as Print (Debug.Print when not in the Immediate Window)
    Print IIf(a = 1, "Yeah" + d, "") _ '<-- Just a line continuation
          'Keeta taught me that the \ operator is division with truncation,
          '     so if they are equal then there is no remainder!
          IIf(i / 2 = i \ 2, "", "But" + d) _
          IIf(a = 2, "No" + d, "");
    'Print usually prints a newline, but it still outputs if the string is blank...
    '   So we append a newline -if true- and use a semi-colon to kill the newline
Next

seadoggie01

Posted 2018-09-12T07:59:37.640

Reputation: 181

@Keeta good idea, but no... If you look at my first code, I use [a1] which means Range/cell .value :) I should've made it more clear that was an explanation though, sorry :/ – seadoggie01 – 2018-09-14T13:20:22.570

1Yeah, I saw that and tried to delete the comment. How about using i/3=i\3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven't tried it, but would it work? – Keeta - reinstate Monica – 2018-09-14T13:24:09.933

@Keeta I've never seen the \ operator before... I don't think so though, it returns the value of division without the remainder... like the opposite of Mod I think – seadoggie01 – 2018-09-14T13:28:40.077

One is integer division and one is floating point. 7/3 = 2.3333 where 7\3 = 2 (truncate division). 6/3 should be 2, and 6\3 should also be 2 so it should work whenever remainder is zero (I think). – Keeta - reinstate Monica – 2018-09-14T13:30:16.167

@Keeta Oh... yeah, but no, but yeah! Nice! – seadoggie01 – 2018-09-14T13:35:04.523

1VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes – Chronocidal – 2018-09-14T15:40:47.193

2

F#, 108 106 bytes

let v p=seq{for i=1 to p do
 if i%3=1 then yield"Yeah"
 if i%2=1 then yield"But"
 if i%3=2 then yield"No"}

Try it online!

-2 bytes changing from i=0 to p-1 to i=1 to p and adjusting modulos. Apart from that, pretty straight-forward.

Ciaran_McCarthy

Posted 2018-09-12T07:59:37.640

Reputation: 689

1I get some kind of build error for the TIO link, perhaps a syntax error in the testing code? – maxb – 2018-09-13T08:15:50.327

Thanks for that. My original solution printed directly to the console, but then I tried returning a sequence and it turned out to be shorter by about 2 bytes. So I changed the code in the TIO but forgot to update the footer - which was still expecting the v function to print everything out. – Ciaran_McCarthy – 2018-09-13T08:36:15.393

2Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. :) – None – 2018-09-13T18:16:40.767

Nice! I've added that. Thanks! :) – Ciaran_McCarthy – 2018-09-13T20:56:38.653

2

PHP, 65 68 bytes

while($i<$argn)echo["Yeah
"][$i%3],["But
"][$i%2],["No
"][~-$i++%3];

Run as pipe with -nR or try it online.

Titus

Posted 2018-09-12T07:59:37.640

Reputation: 13 814

It looks good, but it produces an extra newline in the middle for n=10 – maxb – 2018-09-13T21:02:00.033

@maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter. – Titus – 2018-09-13T23:50:37.973

2

Jelly, 22 bytes

5Rż7FṚṁị“'⁴\ÆẓNƇ»ḲŒP¤Ẏ

A monadic Link yielding a list of lines (which seems to have been allowed in comments)

Try it online! (the footer calls the Link using Ç and joins with newlines using Y since implicit printing in Jelly smashes everything together if it can)

How?

First note that we have a period of \$2\times3=6\$ due to the modulo definition.

Now note that the first six values are:

["Yeah", "But"]
["No"]
["But"]
["Yeah"]
["But", "No"]
[]

So the resulting list of lines should be these values repeated (or truncated) to length n concatenated together.

Now note that the power-set of "Yeah", "But", "No" is:

[]
["Yeah"]
["But"]
["No"]
["Yeah", "But"]
["Yeah", "No"]
["But", "No"]
["Yeah", "But", "No"]

So each period is these 1-indexed values of the power-set of "Yeah", "But", "No":

5, 4, 3, 2, 7, 1

The code makes this list, moulds it to length n, indexes into the power-set, and then removes the inner lists (which also removes the empty strings, since strings are lists in Jelly)...

5Rż7FṚṁị“'⁴\ÆẓNƇ»ḲŒP¤Ẏ - Link: integer, n   e.g. 10
5                      - literal five            5
 R                     - range                   [1,2,3,4,5]
   7                   - literal seven           7
  ż                    - zip together            [[1,7],[2],[3],[4],[5]]
    F                  - flatten                 [1,7,2,3,4,5]
     Ṛ                 - reverse                 [5,4,3,2,7,1]
      ṁ                - mould like (n)          [5,4,3,2,7,1,5,4,3,2]
                    ¤  - nilad followed by link(s) as a nilad:
        “'⁴\ÆẓNƇ»      -   compressed string     "Yeah But No"
                 Ḳ     -   split at spaces       ["Yeah","But","No"]
                  ŒP   -   power-set             [[],["Yeah"],["But"],["No"],["Yeah","But"],["Yeah","No"],["But","No"],["Yeah","But","No"]]
       ị               - index into              [["Yeah","But"],["No"],["But"],["Yeah"],["But","No"],[],["Yeah","But"],["No"],["But"],["Yeah"]]
                     Ẏ - tighten                 ["Yeah","But","No","But","Yeah","But","No","Yeah","But","No","But","Yeah"]

Jonathan Allan

Posted 2018-09-12T07:59:37.640

Reputation: 67 804

I doubt it's going to get any shorter than this. Fantastic answer, and a great explanation, well done! – maxb – 2018-09-17T05:01:13.623

2

Python 3, 154 153 85 90 bytes

n=10
print(''.join(('Yeah\n'*(i%3==0)+'But\n'*(i%2==0)+'No\n'*(i%3==1))for i in range(n)))

Try it online!

Emil Carr

Posted 2018-09-12T07:59:37.640

Reputation: 21

Nice answer! But if you're using python, you have to include the n=5 in the byte count, or use a function or lambda expression – maxb – 2018-09-18T18:49:31.083

@maxb ah, didn't realise, thanks – Emil Carr – 2018-09-18T19:58:34.743

85 bytes – Stephen – 2018-09-19T02:06:52.553

1

Vim, 67 bytes

<C-a>A@m<Return>Yeah_But<Return>No<Return>But<Return>Yeah<Return>But_No<Esc>qm5kYGpqD@"Dgg6dj:%s,_,<C-v><Return>,|%s,\n$<Return>

Assuming the file contains only the input and the cursor is at the beginning.

Some explanations:

<C-a>                  Increment the input, because running 0@m do not work as expected
A@m<Return>            Write @m after the input
Yeah_But<Return>
No<Return>
But<Return>
Yeah<Return>
But_No<Esc>
qm5kYGpq               Record macro m
D                      Cut the text pasted just before, into "
@"                     Execute the macro "
D                      Remove the last line (because I incremented the input)
gg6dj                  Remove the 6 first lines
:%s,_,<C-v><Return>,|%s,\n$<Return>       Replace _ by a newline and remove empty lines

user285259

Posted 2018-09-12T07:59:37.640

Reputation: 201

1I have no way of validating this (if I open Vim I'll never get out of there), but your logic looks correct. Nice answer! – maxb – 2018-09-17T15:35:30.717

1

MBASIC, 127 118 116 bytes

First time, hope I'm doing this right.

1 INPUT X:FOR I=0 TO X-1:IF I MOD 3=0 THEN PRINT"Yeah
2 IF I MOD 2=0 THEN PRINT"But
3 IF I MOD 3=1 THEN PRINT"No
4 NEXT

RUN
? 10
Yeah
But
No
But
Yeah
But
No
Yeah
But
No
But
Yeah

wooshinyobject

Posted 2018-09-12T07:59:37.640

Reputation: 171

Welcome to PPCG! Great first answer, might I suggest adding a link to tio.run? If you haven't done it before, I'll suggest an edit in a short while. – maxb – 2018-09-18T16:00:22.253

@maxb I am afraid TIO does not support MBASIC. – Jonathan Frech – 2018-09-18T16:02:28.780

I'm not really familiar with BASIC, but the script ran just fine in MY-BASIC – maxb – 2018-09-18T18:31:03.873

That may only work for simple programs. Would it help if I linked to the MBASIC reference manual? – wooshinyobject – 2018-09-20T15:35:34.857

1

JavaScript (Node.js), 92 bytes

f=(n,i=0,l=console.log)=>{for(;i<n;i++){0==i%3&&l('Yeah');0==i%2&&l('But');1==i%3&&l('No')}}

Try it online!

user58120

Posted 2018-09-12T07:59:37.640

Reputation:

1

Julia 1.0, 80 bytes

f(i,p=println)=(i%3<1&&p("Yeah");i%2<1&&p("But");i%3==1&&p("No"))
g(n)=f.(0:n-1)

Called as g(2) for example.

Try it online!

gggg

Posted 2018-09-12T07:59:37.640

Reputation: 1 715

1

ORK, 1065 1188 1185 bytes

+123 bytes to account for an input of 0.

-3 bytes because using "my" to refer to an object's variable is redundant inside the object itself.

There is such a thing as a y
A y can Y a number
A y can W a number
A y has a l which is a number

When a y is to Y a number:
I am to W the number
I have a mathematician called M
M's first operand is the number
M's second operand is 1
M is to add
The number is M's result
M's first operand is the number
M's second operand is l
M is to compare
If M says it's less then I am to loop

When a y is to W a number:
I have a mathematician called M
M's first operand is the number
M's second operand is 3
M is to modulo
M's first operand is M's result
M's second operand is 1
M is to compare
I have a mathematician called N
N's first operand is the number
N's second operand is 2
N is to modulo
N's first operand is N's result
N's second operand is 1
N is to compare
I have a scribe called W
If M says it's less then W is to write "Yeah\n"
If N says it's less then W is to write "But\n"
If M says it's equal then W is to write "No\n"

When this program starts:
I have a inputter called I
I have a number called n
I is to read n
I have a y called Y
Y's l is n
I have a mathematician called M
M's first operand is n
M's second operand is 0
M is to compare
If M says it's greater then Y is to Y 0

Try it online!

Objects R Kool. They are kool indeed. But looping is hell. It's nice that the mathematicians' results are reusable, though.

JosiahRyanW

Posted 2018-09-12T07:59:37.640

Reputation: 2 600

I've never heard of this language! Even though I really like the submission, I must point out that it produces incorrect output for input 0. It should produce an empty string (or whitespace only). – maxb – 2018-10-02T21:58:35.487

1My mistake. Thanks for adding 123 bytes to the program, though :P – JosiahRyanW – 2018-10-03T00:36:16.573

1

Stax, 21 bytes

ë╗ô┤z‼╔@qgx╕π♣►Ü~Y↓├Φ

Run and debug it

recursive

Posted 2018-09-12T07:59:37.640

Reputation: 8 616

One of the shortest answers, nicely done! – maxb – 2018-10-10T05:02:18.620

1

Python 3, 89

f=lambda n:f(n-1)+'Yeah\n'*((n-1)%3<1)+'But\n'*((n-1)%2<1)+'No\n'*((n-1)%3==1)if n else""

teafellow

Posted 2018-09-12T07:59:37.640

Reputation: 11

Welcome to PPCG -- 82 bytes.

– Jonathan Frech – 2018-10-13T18:12:09.927