## Fedora 28: Generate kerberos ticket on login

Clash Royale CLAN TAG#URR8PPP

I’m trying to generate kerberos ticket when I login on my computer(Fedora 28). I want to achieve it using PAM. my /etc/pam.d/system-auth looks like this:

auth        required                                     pam_env.so
auth        required                                     pam_faildelay.so delay=2000000
auth        [default=1 ignore=ignore success=ok]         pam_succeed_if.so uid >= 1000 quiet
auth        [default=1 ignore=ignore success=ok]         pam_localuser.so
auth        sufficient                                   pam_unix.so nullok try_first_pass
auth        requisite                                    pam_succeed_if.so uid >= 1000 quiet_success
#auth        sufficient                                   pam_sss.so forward_pass
auth        sufficient                                   pam_krb5.so try_first_pass
auth        required                                     pam_deny.so

account     required                                     pam_unix.so
account     sufficient                                   pam_localuser.so
account     sufficient                                   pam_succeed_if.so uid < 1000 quiet
account     required                                     pam_permit.so

session     optional                                     pam_keyinit.so revoke
session     required                                     pam_limits.so
-session    optional                                     pam_systemd.so
session     [success=1 default=ignore]                   pam_succeed_if.so service in crond quiet use_uid
session     required                                     pam_unix.so
#session     optional                                     pam_sss.so
session     optional                                     pam_krb5.so


and here are the logs from /var/log/secure:

Sep 12 12:48:04 vbox sudo[1408]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:05 vbox sudo[1408]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/chown root:root krb5.keytab
Sep 12 12:48:05 vbox sudo[1408]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox sudo[1413]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:07 vbox sudo[1413]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/sbin/reboot
Sep 12 12:48:07 vbox sudo[1413]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing Kerberos
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox systemd[1092]: pam_unix(systemd-user:session): session closed for user vbox
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing Kerberos
Sep 12 12:48:13 vbox sshd[739]: Received signal 15; terminating.
Sep 12 12:48:43 vbox sshd[728]: Server listening on 0.0.0.0 port 22.
Sep 12 12:48:43 vbox sshd[728]: Server listening on :: port 22.
Sep 12 12:48:47 vbox polkitd[766]: Finished loading, compiling and executing 13 rules
Sep 12 12:48:47 vbox polkitd[766]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Sep 12 12:49:11 vbox systemd[1093]: pam_unix(systemd-user:session): session opened for user vbox by (uid=0)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing Kerberos
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing Kerberos
Sep 12 12:57:20 vbox sshd[1200]: Accepted password for vbox from 192.168.1.53 port 54824 ssh2
Sep 12 12:57:20 vbox sshd[1200]: pam_unix(sshd:session): session opened for user vbox by (uid=0)
Sep 12 12:58:26 vbox sudo[1255]:    vbox : problem with defaults entries ; TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ;


As you can see I have pam_krb5[745]: error initializing kerberos: 13 (Permission denied). I’ve searched and found that the problem could be the permissions of krb5.conf, I’ve set it to 644:

-rw-r--r--. 1 root root 3.8K Jul 31 13:29 krb5.conf

but I have same error. I’ve also noticed that if I login and manually type kinit vbox I’m able to get the ticket. I can’t understand why I have Permission Denied error.

P.S
Here is the content of krb5.conf. https://pastebin.com/t7T2CsBH

âÂ Rui F Ribeiro
Sep 12 at 9:41

• pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

• You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

I’m trying to generate kerberos ticket when I login on my computer(Fedora 28). I want to achieve it using PAM. my /etc/pam.d/system-auth looks like this:

auth        required                                     pam_env.so
auth        required                                     pam_faildelay.so delay=2000000
auth        [default=1 ignore=ignore success=ok]         pam_succeed_if.so uid >= 1000 quiet
auth        [default=1 ignore=ignore success=ok]         pam_localuser.so
auth        sufficient                                   pam_unix.so nullok try_first_pass
auth        requisite                                    pam_succeed_if.so uid >= 1000 quiet_success
#auth        sufficient                                   pam_sss.so forward_pass
auth        sufficient                                   pam_krb5.so try_first_pass
auth        required                                     pam_deny.so

account     required                                     pam_unix.so
account     sufficient                                   pam_localuser.so
account     sufficient                                   pam_succeed_if.so uid < 1000 quiet
account     required                                     pam_permit.so

session     optional                                     pam_keyinit.so revoke
session     required                                     pam_limits.so
-session    optional                                     pam_systemd.so
session     [success=1 default=ignore]                   pam_succeed_if.so service in crond quiet use_uid
session     required                                     pam_unix.so
#session     optional                                     pam_sss.so
session     optional                                     pam_krb5.so


and here are the logs from /var/log/secure:

Sep 12 12:48:04 vbox sudo[1408]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:05 vbox sudo[1408]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/chown root:root krb5.keytab
Sep 12 12:48:05 vbox sudo[1408]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox sudo[1413]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:07 vbox sudo[1413]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/sbin/reboot
Sep 12 12:48:07 vbox sudo[1413]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing Kerberos
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox systemd[1092]: pam_unix(systemd-user:session): session closed for user vbox
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing Kerberos
Sep 12 12:48:13 vbox sshd[739]: Received signal 15; terminating.
Sep 12 12:48:43 vbox sshd[728]: Server listening on 0.0.0.0 port 22.
Sep 12 12:48:43 vbox sshd[728]: Server listening on :: port 22.
Sep 12 12:48:47 vbox polkitd[766]: Finished loading, compiling and executing 13 rules
Sep 12 12:48:47 vbox polkitd[766]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Sep 12 12:49:11 vbox systemd[1093]: pam_unix(systemd-user:session): session opened for user vbox by (uid=0)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing Kerberos
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing Kerberos
Sep 12 12:57:20 vbox sshd[1200]: Accepted password for vbox from 192.168.1.53 port 54824 ssh2
Sep 12 12:57:20 vbox sshd[1200]: pam_unix(sshd:session): session opened for user vbox by (uid=0)
Sep 12 12:58:26 vbox sudo[1255]:    vbox : problem with defaults entries ; TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ;


As you can see I have pam_krb5[745]: error initializing kerberos: 13 (Permission denied). I’ve searched and found that the problem could be the permissions of krb5.conf, I’ve set it to 644:

-rw-r--r--. 1 root root 3.8K Jul 31 13:29 krb5.conf

but I have same error. I’ve also noticed that if I login and manually type kinit vbox I’m able to get the ticket. I can’t understand why I have Permission Denied error.

P.S
Here is the content of krb5.conf. https://pastebin.com/t7T2CsBH

âÂ Rui F Ribeiro
Sep 12 at 9:41

• pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

• You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

I’m trying to generate kerberos ticket when I login on my computer(Fedora 28). I want to achieve it using PAM. my /etc/pam.d/system-auth looks like this:

auth        required                                     pam_env.so
auth        required                                     pam_faildelay.so delay=2000000
auth        [default=1 ignore=ignore success=ok]         pam_succeed_if.so uid >= 1000 quiet
auth        [default=1 ignore=ignore success=ok]         pam_localuser.so
auth        sufficient                                   pam_unix.so nullok try_first_pass
auth        requisite                                    pam_succeed_if.so uid >= 1000 quiet_success
#auth        sufficient                                   pam_sss.so forward_pass
auth        sufficient                                   pam_krb5.so try_first_pass
auth        required                                     pam_deny.so

account     required                                     pam_unix.so
account     sufficient                                   pam_localuser.so
account     sufficient                                   pam_succeed_if.so uid < 1000 quiet
account     required                                     pam_permit.so

session     optional                                     pam_keyinit.so revoke
session     required                                     pam_limits.so
-session    optional                                     pam_systemd.so
session     [success=1 default=ignore]                   pam_succeed_if.so service in crond quiet use_uid
session     required                                     pam_unix.so
#session     optional                                     pam_sss.so
session     optional                                     pam_krb5.so


and here are the logs from /var/log/secure:

Sep 12 12:48:04 vbox sudo[1408]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:05 vbox sudo[1408]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/chown root:root krb5.keytab
Sep 12 12:48:05 vbox sudo[1408]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox sudo[1413]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:07 vbox sudo[1413]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/sbin/reboot
Sep 12 12:48:07 vbox sudo[1413]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing Kerberos
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox systemd[1092]: pam_unix(systemd-user:session): session closed for user vbox
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing Kerberos
Sep 12 12:48:13 vbox sshd[739]: Received signal 15; terminating.
Sep 12 12:48:43 vbox sshd[728]: Server listening on 0.0.0.0 port 22.
Sep 12 12:48:43 vbox sshd[728]: Server listening on :: port 22.
Sep 12 12:48:47 vbox polkitd[766]: Finished loading, compiling and executing 13 rules
Sep 12 12:48:47 vbox polkitd[766]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Sep 12 12:49:11 vbox systemd[1093]: pam_unix(systemd-user:session): session opened for user vbox by (uid=0)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing Kerberos
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing Kerberos
Sep 12 12:57:20 vbox sshd[1200]: Accepted password for vbox from 192.168.1.53 port 54824 ssh2
Sep 12 12:57:20 vbox sshd[1200]: pam_unix(sshd:session): session opened for user vbox by (uid=0)
Sep 12 12:58:26 vbox sudo[1255]:    vbox : problem with defaults entries ; TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ;


As you can see I have pam_krb5[745]: error initializing kerberos: 13 (Permission denied). I’ve searched and found that the problem could be the permissions of krb5.conf, I’ve set it to 644:

-rw-r--r--. 1 root root 3.8K Jul 31 13:29 krb5.conf

but I have same error. I’ve also noticed that if I login and manually type kinit vbox I’m able to get the ticket. I can’t understand why I have Permission Denied error.

P.S
Here is the content of krb5.conf. https://pastebin.com/t7T2CsBH

I’m trying to generate kerberos ticket when I login on my computer(Fedora 28). I want to achieve it using PAM. my /etc/pam.d/system-auth looks like this:

auth        required                                     pam_env.so
auth        required                                     pam_faildelay.so delay=2000000
auth        [default=1 ignore=ignore success=ok]         pam_succeed_if.so uid >= 1000 quiet
auth        [default=1 ignore=ignore success=ok]         pam_localuser.so
auth        sufficient                                   pam_unix.so nullok try_first_pass
auth        requisite                                    pam_succeed_if.so uid >= 1000 quiet_success
#auth        sufficient                                   pam_sss.so forward_pass
auth        sufficient                                   pam_krb5.so try_first_pass
auth        required                                     pam_deny.so

account     required                                     pam_unix.so
account     sufficient                                   pam_localuser.so
account     sufficient                                   pam_succeed_if.so uid < 1000 quiet
account     required                                     pam_permit.so

session     optional                                     pam_keyinit.so revoke
session     required                                     pam_limits.so
-session    optional                                     pam_systemd.so
session     [success=1 default=ignore]                   pam_succeed_if.so service in crond quiet use_uid
session     required                                     pam_unix.so
#session     optional                                     pam_sss.so
session     optional                                     pam_krb5.so


and here are the logs from /var/log/secure:

Sep 12 12:48:04 vbox sudo[1408]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:05 vbox sudo[1408]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/chown root:root krb5.keytab
Sep 12 12:48:05 vbox sudo[1408]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:05 vbox sudo[1408]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox sudo[1413]:    vbox : problem with defaults entries ; TTY=tty1 ; PWD=/etc ; USER=root ;
Sep 12 12:48:07 vbox sudo[1413]:    vbox : TTY=tty1 ; PWD=/etc ; USER=root ; COMMAND=/usr/sbin/reboot
Sep 12 12:48:07 vbox sudo[1413]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session opened for user root by vbox(uid=0)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox login[746]: pam_krb5[746]: error initializing Kerberos
Sep 12 12:48:07 vbox sudo[1413]: pam_unix(sudo:session): session closed for user root
Sep 12 12:48:07 vbox systemd[1092]: pam_unix(systemd-user:session): session closed for user vbox
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:48:07 vbox systemd[1092]: pam_krb5[1092]: error initializing Kerberos
Sep 12 12:48:13 vbox sshd[739]: Received signal 15; terminating.
Sep 12 12:48:43 vbox sshd[728]: Server listening on 0.0.0.0 port 22.
Sep 12 12:48:43 vbox sshd[728]: Server listening on :: port 22.
Sep 12 12:48:47 vbox polkitd[766]: Finished loading, compiling and executing 13 rules
Sep 12 12:48:47 vbox polkitd[766]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Sep 12 12:49:11 vbox systemd[1093]: pam_unix(systemd-user:session): session opened for user vbox by (uid=0)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:11 vbox systemd[1093]: pam_krb5[1093]: error initializing Kerberos
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing kerberos: 13 (Permission denied)
Sep 12 12:49:12 vbox login[745]: pam_krb5[745]: error initializing Kerberos
Sep 12 12:57:20 vbox sshd[1200]: Accepted password for vbox from 192.168.1.53 port 54824 ssh2
Sep 12 12:57:20 vbox sshd[1200]: pam_unix(sshd:session): session opened for user vbox by (uid=0)
Sep 12 12:58:26 vbox sudo[1255]:    vbox : problem with defaults entries ; TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ;


As you can see I have pam_krb5[745]: error initializing kerberos: 13 (Permission denied). I’ve searched and found that the problem could be the permissions of krb5.conf, I’ve set it to 644:

-rw-r--r--. 1 root root 3.8K Jul 31 13:29 krb5.conf

but I have same error. I’ve also noticed that if I login and manually type kinit vbox I’m able to get the ticket. I can’t understand why I have Permission Denied error.

P.S
Here is the content of krb5.conf. https://pastebin.com/t7T2CsBH

edited Sep 12 at 9:50

user3503143

162

162

âÂ Rui F Ribeiro
Sep 12 at 9:41

• pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

• You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

âÂ Rui F Ribeiro
Sep 12 at 9:41

• pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

• You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

âÂ Rui F Ribeiro
Sep 12 at 9:41

âÂ Rui F Ribeiro
Sep 12 at 9:41

pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

pastebin.com/t7T2CsBH thank you for your response 🙂
âÂ user3503143
Sep 12 at 9:50

You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

You should have your domain in there for tickets to work, I think. At least that what I used to do. I usually only had a few lines in that file. From the top of my head, I also think that file does not like comments, or at least not comments on the configuration lines.
âÂ Rui F Ribeiro
Sep 12 at 9:56

active

oldest

active

oldest

active

oldest

active

oldest

active

oldest

Â

draft saved

function () {
}
);

## Yeah But No But Yeah

Clash Royale CLAN TAG#URR8PPP

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


• Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

• It 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
Sep 12 at 9:54

• Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

• @EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

• The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

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


• Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

• It 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
Sep 12 at 9:54

• Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

• @EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

• The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

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


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


code-golf string

maxb

1,5491621

1,5491621

• Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

• It 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
Sep 12 at 9:54

• Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

• @EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

• The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

• Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

• It 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
Sep 12 at 9:54

• Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

• @EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

• The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

3

Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

Can we return a list of lines?
âÂ Jo King
Sep 12 at 8:20

10

It 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
Sep 12 at 9:54

It 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
Sep 12 at 9:54

9

Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

Do we get a bonus if the last line is “God can’t believe you just said that!”
âÂ Ciaran_McCarthy
Sep 12 at 10:24

3

@EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

@EriktheOutgolfer the ifs fall trough and continue in the current loop if their condition was satisfied.
âÂ dzaima
Sep 12 at 15:35

4

The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

The most Australian codegolf yet? Except it should be “nah”
âÂ Nacht
Sep 13 at 2:00

active

oldest

1 2
next

# 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.

• I 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
Sep 12 at 14:09

• @maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

• Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

# 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 $nequiv1pmod 3$, output “Yeah”
• if $nequiv1pmod 2$, output “But”
• if $nequiv2pmod 3$, output “No”

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

The two other entries are defined as "Yeahn" + s and s + "Non" 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:
Butn     //       set s to "But"
:             //     else:
'',         //       set s to an empty string
Yeahn + s, //     2nd entry: "Yeah" followed by s
s + Non    //     3rd entry: s followed by "No"
][n % 3]        //   append the correct entry for this iteration
:                 // else:
''              //   return an empty string and stop recursion


# 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!

• It 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 😀
Sep 13 at 3:23

• Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

• I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

• Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

# Whitespace, 315304300277 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
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):
Push "noN" to the stack
Label: SKIP_NO
If(i modulo-2 is 0):
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)


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 “Yeahn”, “Butn”, “Non”). 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.

• I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

• @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
Sep 12 at 12:37

• 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
Sep 12 at 13:15

• @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
Sep 13 at 10:00

• Well, 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
Sep 13 at 12:40

# 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

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


Try it online!

# 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


# 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!

# 05AB1E (legacy), 2725 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


• 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
Sep 12 at 8:27

• Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

• @maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

• 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
Sep 12 at 9:32

• @KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

# Python 2, 73 bytes

lambda n:'n'.join((["YeahnBut","No","But","Yeah","ButnNo"]*n)[:n-n/6])


Try it online!

# Python 2, 9795929083 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, 929085 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

• 86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

• @JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

• 82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

• @ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

# 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?'':'Yeahn')+(n%2?'':'Butn')+(n%3==1?'Non':''):''}


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?'':'Yeahn')+(it%2?'':'Butn')+(it%3==1?'Non':''))}


Try it online!

• 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
Sep 12 at 15:20

• @maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

• Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

# Retina 0.8.2, 45 bytes

.+
$* 1$YeahÃÂ¶$ButÃÂ¶$11NoÃÂ¶
+11B
B
111

A1


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.

A1


Delete all lines that still have a 1.

• 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
Sep 12 at 12:51

# Canvas, 27 bytes

Ã¯Â½ÂÃ¢ÂÂ·Ã¢ÂÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½YeahÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½ButÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ·Ã¢ÂÂ½NoÃ¯Â¼Â°


Try it here!

# Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeahn":"")+(i%2<1?"Butn":"")+(++i%3>1?"Non":""));}


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:
"Yeahn"       //     Print "Yeah" with newline
:"")+(i%2<1?     //    If i is even:
"Butn"        //     Print "But" with newline
:"")+(++i%3>1?   //    If i modulo-3 is 1:
"Non"         //     Print "No" with newline
:                //    If none of the above three if's applied to the current i:
""));}          //     Print nothing for the current i


• ++i%3>1 will likely save you a byte
Sep 12 at 22:56

• @OlivierGrÃ©goire Ah, of course. Thanks!
âÂ Kevin Cruijssen
Sep 13 at 7:40

# Powershell, 75747267 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,"YeahnBut","But","No","But","Yeah","ButnNo",$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]}}


• Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter?
âÂ maxb
Sep 12 at 13:36

• 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
Sep 12 at 14:10

• That hashtable usage is clever. I’m going to need to remember that.
Sep 12 at 18:35

• @maxb – a tio.run online interpreter link for the 67 byte answer
âÂ TessellatingHeckler
Sep 17 at 5:07

• @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne'' âÂ TessellatingHeckler Sep 17 at 5:49 # Haskell, 71 bytes f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No" (a?b)c n=[c|nmoda==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  # C# (Visual C# Interactive Compiler), 105999496 89bytes i=>{for(int x=0;x<i;)Write((x%3<1?"Yeahn":"")+(x%2<1?"Butn":"")+(x++%3==1?"Non":""));}  Try it online! • Removing the interpolation like this saves 7 bytes. âÂ Emigna Sep 12 at 10:43 • @Emigna Thanks for the tip, changed the answer âÂ auhmaan Sep 12 at 16:33 • x++%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 Sep 13 at 7:41 # Pip, 3735 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. # 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


# C (gcc), 77717472 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!

• @JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

• @cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

• 70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

• n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

# Ruby, 69 7274 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

# Python 3, 93 bytes

[print("Yeahn"*(i%3<1)+"Butn"*(i%2<1)+"Non"*(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!

• If 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
Sep 14 at 2:21

## 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)

# 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(.*).-:21:;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 doesnt 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 theres an 'a' or 'e' in the inputÃ¢ÂÂ¦ iYeah | Ã¢ÂÂ¦output 'Yeah' | /[bdf]/ | if theres a 'b' or 'd' or 'f' in the inputÃ¢ÂÂ¦ iBut | Ã¢ÂÂ¦output 'But' | /[cg]/ | if theres 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(.*).-:21:;        | 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


âÂ user285259
Sep 21 at 8:30

• @user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

# 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! ## 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. • I get some kind of build error for the TIO link, perhaps a syntax error in the testing code? âÂ maxb Sep 13 at 8:15 • 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 Sep 13 at 8:36 • Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂 âÂ user82031 Sep 13 at 18:16 • Nice! I’ve added that. Thanks! 🙂 âÂ Ciaran_McCarthy Sep 13 at 20:56 # 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.

• It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

• @maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

# 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=i2,"","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


• @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 :/
Sep 14 at 13:20

• Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

• @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
Sep 14 at 13:28

• One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

• VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

# Jelly, 22 bytes

5RÃÂ¼7FÃ¡Â¹ÂÃ¡Â¹ÂÃ¡Â»ÂÃ¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂNÃÂÃÂ»Ã¡Â¸Â²ÃÂPÃÂ¤Ã¡ÂºÂ


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 $2times3=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]
Ã¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂ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"]


• I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

# Python 2, 9392 83 bytes

lambda i:''.join('Yeahn'*(x%3<1)+'Butn'*(x%2<1)+'Non'*(x%3==1)for x in range(i))


Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

• You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

• @JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

1 2
next

active

oldest

active

oldest

active

oldest

active

oldest

1 2
next

# 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.

• I 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
Sep 12 at 14:09

• @maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

• Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

# 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.

• I 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
Sep 12 at 14:09

• @maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

• Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

# 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.

# 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.

edited Sep 12 at 14:18

Keeta

737310

737310

• I 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
Sep 12 at 14:09

• @maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

• Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

• I 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
Sep 12 at 14:09

• @maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

• Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

1

I 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
Sep 12 at 14:09

I 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
Sep 12 at 14:09

15

@maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

@maxb Can’t be all that ridiculous when it is beating other languages.
âÂ Keeta
Sep 12 at 14:21

1

Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

Great explanation and very cool technique. Works in LibreOffice Calc as well but might need some playing with the formatting. +1
âÂ ElPedro
Sep 12 at 17:32

# 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 $nequiv1pmod 3$, output “Yeah”
• if $nequiv1pmod 2$, output “But”
• if $nequiv2pmod 3$, output “No”

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

The two other entries are defined as "Yeahn" + s and s + "Non" 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:
Butn     //       set s to "But"
:             //     else:
'',         //       set s to an empty string
Yeahn + s, //     2nd entry: "Yeah" followed by s
s + Non    //     3rd entry: s followed by "No"
][n % 3]        //   append the correct entry for this iteration
:                 // else:
''              //   return an empty string and stop recursion


# 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 $nequiv1pmod 3$, output “Yeah”
• if $nequiv1pmod 2$, output “But”
• if $nequiv2pmod 3$, output “No”

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

The two other entries are defined as "Yeahn" + s and s + "Non" 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:
Butn     //       set s to "But"
:             //     else:
'',         //       set s to an empty string
Yeahn + s, //     2nd entry: "Yeah" followed by s
s + Non    //     3rd entry: s followed by "No"
][n % 3]        //   append the correct entry for this iteration
:                 // else:
''              //   return an empty string and stop recursion


# 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 $nequiv1pmod 3$, output “Yeah”
• if $nequiv1pmod 2$, output “But”
• if $nequiv2pmod 3$, output “No”

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

The two other entries are defined as "Yeahn" + s and s + "Non" 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:
Butn     //       set s to "But"
:             //     else:
'',         //       set s to an empty string
Yeahn + s, //     2nd entry: "Yeah" followed by s
s + Non    //     3rd entry: s followed by "No"
][n % 3]        //   append the correct entry for this iteration
:                 // else:
''              //   return an empty string and stop recursion


# 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 $nequiv1pmod 3$, output “Yeah”
• if $nequiv1pmod 2$, output “But”
• if $nequiv2pmod 3$, output “No”

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

The two other entries are defined as "Yeahn" + s and s + "Non" 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:
Butn     //       set s to "But"
:             //     else:
'',         //       set s to an empty string
Yeahn + s, //     2nd entry: "Yeah" followed by s
s + Non    //     3rd entry: s followed by "No"
][n % 3]        //   append the correct entry for this iteration
:                 // else:
''              //   return an empty string and stop recursion


edited Sep 12 at 9:33

Arnauld

65.5k581277

65.5k581277

# 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!

• It 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 😀
Sep 13 at 3:23

• Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

• I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

• Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

# 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!

• It 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 😀
Sep 13 at 3:23

• Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

• I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

• Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

# 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!

# 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!

edited Sep 13 at 6:44

JosiahRyanW

5216

5216

• It 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 😀
Sep 13 at 3:23

• Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

• I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

• Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

• It 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 😀
Sep 13 at 3:23

• Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

• I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

• Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

2

It 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 😀
Sep 13 at 3:23

It 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 😀
Sep 13 at 3:23

2

Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

Whoops, thought I could optimize there. This is a tricky pattern. I fixed it now.
âÂ JosiahRyanW
Sep 13 at 6:45

1

I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

I love the way it reads
âÂ LocustHorde
Sep 13 at 15:51

3

Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

Does VISIBLE "But" refer to the program’s lack of trousers?
âÂ JDL
Sep 14 at 14:03

# Whitespace, 315304300277 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
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):
Push "noN" to the stack
Label: SKIP_NO
If(i modulo-2 is 0):
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)


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 “Yeahn”, “Butn”, “Non”). 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.

• I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

• @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
Sep 12 at 12:37

• 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
Sep 12 at 13:15

• @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
Sep 13 at 10:00

• Well, 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
Sep 13 at 12:40

# Whitespace, 315304300277 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
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):
Push "noN" to the stack
Label: SKIP_NO
If(i modulo-2 is 0):
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)


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 “Yeahn”, “Butn”, “Non”). 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.

• I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

• @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
Sep 12 at 12:37

• 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
Sep 12 at 13:15

• @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
Sep 13 at 10:00

• Well, 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
Sep 13 at 12:40

# Whitespace, 315304300277 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
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):
Push "noN" to the stack
Label: SKIP_NO
If(i modulo-2 is 0):
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)


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 “Yeahn”, “Butn”, “Non”). 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.

# Whitespace, 315304300277 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
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):
Push "noN" to the stack
Label: SKIP_NO
If(i modulo-2 is 0):
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)


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 “Yeahn”, “Butn”, “Non”). 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.

edited Sep 13 at 12:48

Kevin Cruijssen

30.6k553167

30.6k553167

• I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

• @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
Sep 12 at 12:37

• 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
Sep 12 at 13:15

• @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
Sep 13 at 10:00

• Well, 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
Sep 13 at 12:40

• I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

• @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
Sep 12 at 12:37

• 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
Sep 12 at 13:15

• @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
Sep 13 at 10:00

• Well, 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
Sep 13 at 12:40

1

I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

I most certainly did not expect a Whitespace answer. Good job!
âÂ maxb
Sep 12 at 12:31

@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
Sep 12 at 12:37

@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
Sep 12 at 12:37

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
Sep 12 at 13:15

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
Sep 12 at 13:15

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
Sep 13 at 10:00

@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
Sep 13 at 10:00

1

Well, 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
Sep 13 at 12:40

Well, 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
Sep 13 at 12:40

# 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

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


Try it online!

# 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

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


Try it online!

# 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

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


Try it online!

# 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

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


Try it online!

edited Sep 12 at 14:59

ovs

17.5k21058

17.5k21058

# 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


# 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


# 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


# 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


edited Sep 13 at 3:19

Jo King

16.5k24190

16.5k24190

# 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!

# 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!

# 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!

# 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!

edited Sep 12 at 9:01

Jonathan Frech

6,06311040

6,06311040

# 05AB1E (legacy), 2725 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


• 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
Sep 12 at 8:27

• Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

• @maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

• 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
Sep 12 at 9:32

• @KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

# 05AB1E (legacy), 2725 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


• 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
Sep 12 at 8:27

• Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

• @maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

• 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
Sep 12 at 9:32

• @KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

# 05AB1E (legacy), 2725 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


# 05AB1E (legacy), 2725 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


edited Sep 12 at 9:51

Emigna

43.4k431131

43.4k431131

• 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
Sep 12 at 8:27

• Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

• @maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

• 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
Sep 12 at 9:32

• @KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

• 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
Sep 12 at 8:27

• Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

• @maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

• 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
Sep 12 at 9:32

• @KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

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
Sep 12 at 8:27

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
Sep 12 at 8:27

Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

Wow, I’d love an explanation on this one. My personal best was 44 bytes in CJam.
âÂ maxb
Sep 12 at 8:29

@maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

@maxb: I will of course add an explanation. I’m just checking to see if I can golf it down some more first 😉
âÂ Emigna
Sep 12 at 8:30

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
Sep 12 at 9:32

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
Sep 12 at 9:32

@KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

@KevinCruijssen: Thanks! Not sure how I missed that 😛
âÂ Emigna
Sep 12 at 9:51

# Python 2, 73 bytes

lambda n:'n'.join((["YeahnBut","No","But","Yeah","ButnNo"]*n)[:n-n/6])


Try it online!

# Python 2, 73 bytes

lambda n:'n'.join((["YeahnBut","No","But","Yeah","ButnNo"]*n)[:n-n/6])


Try it online!

# Python 2, 73 bytes

lambda n:'n'.join((["YeahnBut","No","But","Yeah","ButnNo"]*n)[:n-n/6])


Try it online!

# Python 2, 73 bytes

lambda n:'n'.join((["YeahnBut","No","But","Yeah","ButnNo"]*n)[:n-n/6])


Try it online!

edited Sep 12 at 15:15

Lynn

48.1k694223

48.1k694223

# Python 2, 9795929083 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, 929085 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

• 86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

• @JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

• 82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

• @ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

# Python 2, 9795929083 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, 929085 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

• 86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

• @JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

• 82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

• @ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

# Python 2, 9795929083 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, 929085 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

# Python 2, 9795929083 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, 929085 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

edited Sep 12 at 13:27

TFeld

11.9k2833

11.9k2833

• 86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

• @JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

• 82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

• @ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

• 86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

• @JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

• 82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

• @ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

86 bytes by combining the two and returning as a list of lines
âÂ Jo King
Sep 12 at 13:09

@JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

@JoKing Thanks, didn’t know that I could return instead of printing when wrote it.
âÂ TFeld
Sep 12 at 13:14

82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

82 bytes: len(w)<3 -> 'N'in w, 81 bytes : len(w)%2 -> (w<'N')
âÂ ovs
Sep 12 at 13:22

@ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

@ovs Thanks, 🙂
âÂ TFeld
Sep 12 at 13:27

# 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?'':'Yeahn')+(n%2?'':'Butn')+(n%3==1?'Non':''):''}


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?'':'Yeahn')+(it%2?'':'Butn')+(it%3==1?'Non':''))}


Try it online!

• 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
Sep 12 at 15:20

• @maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

• Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

# 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?'':'Yeahn')+(n%2?'':'Butn')+(n%3==1?'Non':''):''}


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?'':'Yeahn')+(it%2?'':'Butn')+(it%3==1?'Non':''))}


Try it online!

• 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
Sep 12 at 15:20

• @maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

• Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

# 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?'':'Yeahn')+(n%2?'':'Butn')+(n%3==1?'Non':''):''}


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?'':'Yeahn')+(it%2?'':'Butn')+(it%3==1?'Non':''))}


Try it online!

# 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?'':'Yeahn')+(n%2?'':'Butn')+(n%3==1?'Non':''):''}


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?'':'Yeahn')+(it%2?'':'Butn')+(it%3==1?'Non':''))}


Try it online!

edited Sep 14 at 12:38

archangel.mjj

813

813

• 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
Sep 12 at 15:20

• @maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

• Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

• 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
Sep 12 at 15:20

• @maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

• Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

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
Sep 12 at 15:20

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
Sep 12 at 15:20

1

@maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

@maxb Thanks! I’ve added one 🙂
âÂ archangel.mjj
Sep 12 at 15:29

Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

Nice first answer and also welcome to PPCG.
âÂ ElPedro
Sep 12 at 18:03

# Retina 0.8.2, 45 bytes

.+
$* 1$YeahÃÂ¶$ButÃÂ¶$11NoÃÂ¶
+11B
B
111

A1


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.

A1


Delete all lines that still have a 1.

• 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
Sep 12 at 12:51

# Retina 0.8.2, 45 bytes

.+
$* 1$YeahÃÂ¶$ButÃÂ¶$11NoÃÂ¶
+11B
B
111

A1


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.

A1


Delete all lines that still have a 1.

• 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
Sep 12 at 12:51

# Retina 0.8.2, 45 bytes

.+
$* 1$YeahÃÂ¶$ButÃÂ¶$11NoÃÂ¶
+11B
B
111

A1


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.

A1


Delete all lines that still have a 1.

# Retina 0.8.2, 45 bytes

.+
$* 1$YeahÃÂ¶$ButÃÂ¶$11NoÃÂ¶
+11B
B
111

A1


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.

A1


Delete all lines that still have a 1.

Neil

75.8k744171

75.8k744171

• 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
Sep 12 at 12:51

• 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
Sep 12 at 12:51

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
Sep 12 at 12:51

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
Sep 12 at 12:51

# Canvas, 27 bytes

Ã¯Â½ÂÃ¢ÂÂ·Ã¢ÂÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½YeahÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½ButÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ·Ã¢ÂÂ½NoÃ¯Â¼Â°


Try it here!

# Canvas, 27 bytes

Ã¯Â½ÂÃ¢ÂÂ·Ã¢ÂÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½YeahÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½ButÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ·Ã¢ÂÂ½NoÃ¯Â¼Â°


Try it here!

# Canvas, 27 bytes

Ã¯Â½ÂÃ¢ÂÂ·Ã¢ÂÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½YeahÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½ButÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ·Ã¢ÂÂ½NoÃ¯Â¼Â°


Try it here!

# Canvas, 27 bytes

Ã¯Â½ÂÃ¢ÂÂ·Ã¢ÂÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½YeahÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ½ButÃ¯Â¼Â°Ã¯Â½ÂÃ¯Â¼ÂÃ¯Â¼ÂÃ¢ÂÂ·Ã¢ÂÂ½NoÃ¯Â¼Â°


Try it here!

dzaima

13.1k21652

13.1k21652

# Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeahn":"")+(i%2<1?"Butn":"")+(++i%3>1?"Non":""));}


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:
"Yeahn"       //     Print "Yeah" with newline
:"")+(i%2<1?     //    If i is even:
"Butn"        //     Print "But" with newline
:"")+(++i%3>1?   //    If i modulo-3 is 1:
"Non"         //     Print "No" with newline
:                //    If none of the above three if's applied to the current i:
""));}          //     Print nothing for the current i


• ++i%3>1 will likely save you a byte
Sep 12 at 22:56

• @OlivierGrÃ©goire Ah, of course. Thanks!
âÂ Kevin Cruijssen
Sep 13 at 7:40

# Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeahn":"")+(i%2<1?"Butn":"")+(++i%3>1?"Non":""));}


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:
"Yeahn"       //     Print "Yeah" with newline
:"")+(i%2<1?     //    If i is even:
"Butn"        //     Print "But" with newline
:"")+(++i%3>1?   //    If i modulo-3 is 1:
"Non"         //     Print "No" with newline
:                //    If none of the above three if's applied to the current i:
""));}          //     Print nothing for the current i


• ++i%3>1 will likely save you a byte
Sep 12 at 22:56

• @OlivierGrÃ©goire Ah, of course. Thanks!
âÂ Kevin Cruijssen
Sep 13 at 7:40

# Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeahn":"")+(i%2<1?"Butn":"")+(++i%3>1?"Non":""));}


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:
"Yeahn"       //     Print "Yeah" with newline
:"")+(i%2<1?     //    If i is even:
"Butn"        //     Print "But" with newline
:"")+(++i%3>1?   //    If i modulo-3 is 1:
"Non"         //     Print "No" with newline
:                //    If none of the above three if's applied to the current i:
""));}          //     Print nothing for the current i


# Java 10, 100 99 bytes

n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeahn":"")+(i%2<1?"Butn":"")+(++i%3>1?"Non":""));}


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:
"Yeahn"       //     Print "Yeah" with newline
:"")+(i%2<1?     //    If i is even:
"Butn"        //     Print "But" with newline
:"")+(++i%3>1?   //    If i modulo-3 is 1:
"Non"         //     Print "No" with newline
:                //    If none of the above three if's applied to the current i:
""));}          //     Print nothing for the current i


edited Sep 13 at 7:39

Kevin Cruijssen

30.6k553167

30.6k553167

• ++i%3>1 will likely save you a byte
Sep 12 at 22:56

• @OlivierGrÃ©goire Ah, of course. Thanks!
âÂ Kevin Cruijssen
Sep 13 at 7:40

• ++i%3>1 will likely save you a byte
Sep 12 at 22:56

• @OlivierGrÃ©goire Ah, of course. Thanks!
âÂ Kevin Cruijssen
Sep 13 at 7:40

1

++i%3>1 will likely save you a byte
Sep 12 at 22:56

++i%3>1 will likely save you a byte
Sep 12 at 22:56

âÂ Kevin Cruijssen
Sep 13 at 7:40

âÂ Kevin Cruijssen
Sep 13 at 7:40

# Powershell, 75747267 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,"YeahnBut","But","No","But","Yeah","ButnNo",$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]}}


• Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter?
âÂ maxb
Sep 12 at 13:36

• 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
Sep 12 at 14:10

• That hashtable usage is clever. I’m going to need to remember that.
Sep 12 at 18:35

• @maxb – a tio.run online interpreter link for the 67 byte answer
âÂ TessellatingHeckler
Sep 17 at 5:07

• @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne'' âÂ TessellatingHeckler Sep 17 at 5:49 # Powershell, 75747267 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,"YeahnBut","But","No","But","Yeah","ButnNo",$null,...) # 4. remove$null elements from result array

}

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

@(
,(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]}}  • Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter? âÂ maxb Sep 12 at 13:36 • 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 Sep 12 at 14:10 • That hashtable usage is clever. I’m going to need to remember that. âÂ AdmBorkBork Sep 12 at 18:35 • @maxb – a tio.run online interpreter link for the 67 byte answer âÂ TessellatingHeckler Sep 17 at 5:07 • @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne''
âÂ TessellatingHeckler
Sep 17 at 5:49

# Powershell, 75747267 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,"YeahnBut","But","No","But","Yeah","ButnNo",$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]}}


# Powershell, 75747267 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,"YeahnBut","But","No","But","Yeah","ButnNo",$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]}}


edited Sep 17 at 8:40

mazzy

86639

86639

• Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter?
âÂ maxb
Sep 12 at 13:36

• 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
Sep 12 at 14:10

• That hashtable usage is clever. I’m going to need to remember that.
Sep 12 at 18:35

• @maxb – a tio.run online interpreter link for the 67 byte answer
âÂ TessellatingHeckler
Sep 17 at 5:07

• @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne'' âÂ TessellatingHeckler Sep 17 at 5:49 • Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter? âÂ maxb Sep 12 at 13:36 • 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 Sep 12 at 14:10 • That hashtable usage is clever. I’m going to need to remember that. âÂ AdmBorkBork Sep 12 at 18:35 • @maxb – a tio.run online interpreter link for the 67 byte answer âÂ TessellatingHeckler Sep 17 at 5:07 • @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne''
âÂ TessellatingHeckler
Sep 17 at 5:49

1

Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter?
âÂ maxb
Sep 12 at 13:36

Great answer! Would it be possible to add some output to the answer, since it doesn’t include an online interpreter?
âÂ maxb
Sep 12 at 13:36

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
Sep 12 at 14:10

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
Sep 12 at 14:10

That hashtable usage is clever. I’m going to need to remember that.
Sep 12 at 18:35

That hashtable usage is clever. I’m going to need to remember that.
Sep 12 at 18:35

@maxb – a tio.run online interpreter link for the 67 byte answer
âÂ TessellatingHeckler
Sep 17 at 5:07

@maxb – a tio.run online interpreter link for the 67 byte answer
âÂ TessellatingHeckler
Sep 17 at 5:07

1

@mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne'' âÂ TessellatingHeckler Sep 17 at 5:49 @mazzy I can reformulate yours, but still can’t beat 67 (replace the two n with real newlines) (" YeahnBut No But Yeah ButnNo "*($j="$args")|% s*t 32)[1..$j]-ne''
âÂ TessellatingHeckler
Sep 17 at 5:49

f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No"
(a?b)c n=[c|nmoda==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


f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No"
(a?b)c n=[c|nmoda==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


f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No"
(a?b)c n=[c|nmoda==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


f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No"
(a?b)c n=[c|nmoda==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


edited Sep 12 at 13:49

BMO

9,89911774

9,89911774

# C# (Visual C# Interactive Compiler), 105999496 89bytes

i=>{for(int x=0;x<i;)Write((x%3<1?"Yeahn":"")+(x%2<1?"Butn":"")+(x++%3==1?"Non":""));}


Try it online!

• Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

• @Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

• x++%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
Sep 13 at 7:41

# C# (Visual C# Interactive Compiler), 105999496 89bytes

i=>{for(int x=0;x<i;)Write((x%3<1?"Yeahn":"")+(x%2<1?"Butn":"")+(x++%3==1?"Non":""));}


Try it online!

• Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

• @Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

• x++%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
Sep 13 at 7:41

# C# (Visual C# Interactive Compiler), 105999496 89bytes

i=>{for(int x=0;x<i;)Write((x%3<1?"Yeahn":"")+(x%2<1?"Butn":"")+(x++%3==1?"Non":""));}


Try it online!

# C# (Visual C# Interactive Compiler), 105999496 89bytes

i=>{for(int x=0;x<i;)Write((x%3<1?"Yeahn":"")+(x%2<1?"Butn":"")+(x++%3==1?"Non":""));}


Try it online!

edited Sep 12 at 16:32

auhmaan

85637

85637

• Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

• @Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

• x++%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
Sep 13 at 7:41

• Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

• @Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

• x++%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
Sep 13 at 7:41

4

Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

Removing the interpolation like this saves 7 bytes.
âÂ Emigna
Sep 12 at 10:43

@Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

@Emigna Thanks for the tip, changed the answer
âÂ auhmaan
Sep 12 at 16:33

1

x++%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
Sep 13 at 7:41

x++%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
Sep 13 at 7:41

# Pip, 3735 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.

# Pip, 3735 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.

# Pip, 3735 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.

# Pip, 3735 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.

edited Sep 12 at 20:37

DLosc

18.3k33588

18.3k33588

# 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  # 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


# 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  # 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

28.5k262158

28.5k262158

# C (gcc), 77717472 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!

• @JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

• @cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

• 70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

• n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

# C (gcc), 77717472 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!

• @JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

• @cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

• 70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

• n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

# C (gcc), 77717472 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!

# C (gcc), 77717472 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!

edited Sep 21 at 13:13

cleblanc

3,170216

3,170216

• @JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

• @cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

• 70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

• n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

• @JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

• @cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

• 70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

• n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

@JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

@JonathanFrech Nice but doesn’t work for zero, or 5
âÂ cleblanc
Sep 18 at 17:04

@cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

@cleblanc Oh, sorry. Did not realize … At least removing j saved you two bytes.
âÂ Jonathan Frech
Sep 18 at 17:46

1

70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

70 bytes — incorporating @ceilingcat’s one saved byte.
âÂ Jonathan Frech
Sep 18 at 18:01

1

n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

n-~-i is equivalent to n-i+1 — not i<n+1 — and so does not actually save any bytes …
âÂ Jonathan Frech
Sep 18 at 19:16

# Ruby, 69 7274 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

# Ruby, 69 7274 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

# Ruby, 69 7274 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

# Ruby, 69 7274 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

edited Sep 12 at 22:20

HÃ¥vard NygÃ¥rd

31117

31117

# Python 3, 93 bytes

[print("Yeahn"*(i%3<1)+"Butn"*(i%2<1)+"Non"*(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!

• If 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
Sep 14 at 2:21

# Python 3, 93 bytes

[print("Yeahn"*(i%3<1)+"Butn"*(i%2<1)+"Non"*(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!

• If 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
Sep 14 at 2:21

# Python 3, 93 bytes

[print("Yeahn"*(i%3<1)+"Butn"*(i%2<1)+"Non"*(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!

# Python 3, 93 bytes

[print("Yeahn"*(i%3<1)+"Butn"*(i%2<1)+"Non"*(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!

edited Sep 13 at 3:56

Timtech

11.4k13659

11.4k13659

Josh B.

612

612

• If 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
Sep 14 at 2:21

• If 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
Sep 14 at 2:21

1

If 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
Sep 14 at 2:21

If 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
Sep 14 at 2:21

## 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)

## 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)

## 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)

## 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)

edited Sep 14 at 14:35

JDL

1,235410

1,235410

# 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(.*).-:21:;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 doesnt 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 theres an 'a' or 'e' in the inputÃ¢ÂÂ¦ iYeah | Ã¢ÂÂ¦output 'Yeah' | /[bdf]/ | if theres a 'b' or 'd' or 'f' in the inputÃ¢ÂÂ¦ iBut | Ã¢ÂÂ¦output 'But' | /[cg]/ | if theres 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(.*).-:21:;        | 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


âÂ user285259
Sep 21 at 8:30

• @user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

# 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(.*).-:21:;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 doesnt 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 theres an 'a' or 'e' in the inputÃ¢ÂÂ¦ iYeah | Ã¢ÂÂ¦output 'Yeah' | /[bdf]/ | if theres a 'b' or 'd' or 'f' in the inputÃ¢ÂÂ¦ iBut | Ã¢ÂÂ¦output 'But' | /[cg]/ | if theres 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(.*).-:21:;        | 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


âÂ user285259
Sep 21 at 8:30

• @user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

# 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(.*).-:21:;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 doesnt 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 theres an 'a' or 'e' in the inputÃ¢ÂÂ¦ iYeah | Ã¢ÂÂ¦output 'Yeah' | /[bdf]/ | if theres a 'b' or 'd' or 'f' in the inputÃ¢ÂÂ¦ iBut | Ã¢ÂÂ¦output 'But' | /[cg]/ | if theres 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(.*).-:21:;        | 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


# 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(.*).-:21:;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 doesnt 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 theres an 'a' or 'e' in the inputÃ¢ÂÂ¦ iYeah | Ã¢ÂÂ¦output 'Yeah' | /[bdf]/ | if theres a 'b' or 'd' or 'f' in the inputÃ¢ÂÂ¦ iBut | Ã¢ÂÂ¦output 'But' | /[cg]/ | if theres 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(.*).-:21:;        | 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


edited Sep 21 at 13:21

hidefromkgb

2214

2214

âÂ user285259
Sep 21 at 8:30

• @user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

âÂ user285259
Sep 21 at 8:30

• @user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

âÂ user285259
Sep 21 at 8:30

âÂ user285259
Sep 21 at 8:30

1

@user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

@user285259 Done.
âÂ hidefromkgb
Sep 21 at 13:21

# 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! # 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!

# 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! # 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

5,36311031

5,36311031

## 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.

• I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

• 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
Sep 13 at 8:36

• Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

• Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

## 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.

• I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

• 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
Sep 13 at 8:36

• Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

• Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

## 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.

## 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.

edited Sep 13 at 20:56

Ciaran_McCarthy

441118

441118

• I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

• 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
Sep 13 at 8:36

• Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

• Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

• I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

• 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
Sep 13 at 8:36

• Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

• Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

1

I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

I get some kind of build error for the TIO link, perhaps a syntax error in the testing code?
âÂ maxb
Sep 13 at 8:15

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
Sep 13 at 8:36

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
Sep 13 at 8:36

2

Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

Shave 2 bytes with i=1 to p (and adjusting moduli, naturally). Reverse ranges are empty. 🙂
âÂ user82031
Sep 13 at 18:16

Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

Nice! I’ve added that. Thanks! 🙂
âÂ Ciaran_McCarthy
Sep 13 at 20:56

# 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. • It looks good, but it produces an extra newline in the middle for n=10 âÂ maxb Sep 13 at 21:02 • @maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter. âÂ Titus Sep 13 at 23:50 # 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.

• It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

• @maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

# 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. # 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.

edited Sep 13 at 23:49

Titus

12.5k11236

12.5k11236

• It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

• @maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

• It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

• @maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

It looks good, but it produces an extra newline in the middle for n=10
âÂ maxb
Sep 13 at 21:02

@maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

@maxb Thanks for the hint. I could have fixed it with 9 extra bytes; but the other approach is shorter.
âÂ Titus
Sep 13 at 23:50

# 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=i2,"","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


• @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 :/
Sep 14 at 13:20

• Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

• @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
Sep 14 at 13:28

• One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

• VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

# 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=i2,"","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


• @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 :/
Sep 14 at 13:20

• Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

• @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
Sep 14 at 13:28

• One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

• VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

# 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=i2,"","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


# 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=i2,"","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


edited Sep 14 at 15:53

1518

1518

• @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 :/
Sep 14 at 13:20

• Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

• @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
Sep 14 at 13:28

• One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

• VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

• @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 :/
Sep 14 at 13:20

• Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

• @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
Sep 14 at 13:28

• One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

• VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

@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 :/
Sep 14 at 13:20

@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 :/
Sep 14 at 13:20

1

Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

Yeah, I saw that and tried to delete the comment. How about using i/3=i3 instead of i mod 3 = 0 (and same for mod 2 = 0). Haven’t tried it, but would it work?
âÂ Keeta
Sep 14 at 13:24

@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
Sep 14 at 13:28

@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
Sep 14 at 13:28

One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

One is integer division and one is floating point. 7/3 = 2.3333 where 73 = 2 (truncate division). 6/3 should be 2, and 63 should also be 2 so it should work whenever remainder is zero (I think).
âÂ Keeta
Sep 14 at 13:30

1

VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

VBA will automatically concatenate function outputs, so you can drop the & between eachIIf(..) for an extra 2 bytes
âÂ Chronocidal
Sep 14 at 15:40

# Jelly, 22 bytes

5RÃÂ¼7FÃ¡Â¹ÂÃ¡Â¹ÂÃ¡Â»ÂÃ¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂNÃÂÃÂ»Ã¡Â¸Â²ÃÂPÃÂ¤Ã¡ÂºÂ


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 $2times3=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]
Ã¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂ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"]


• I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

# Jelly, 22 bytes

5RÃÂ¼7FÃ¡Â¹ÂÃ¡Â¹ÂÃ¡Â»ÂÃ¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂNÃÂÃÂ»Ã¡Â¸Â²ÃÂPÃÂ¤Ã¡ÂºÂ


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 $2times3=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]
Ã¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂ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"]


• I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

# Jelly, 22 bytes

5RÃÂ¼7FÃ¡Â¹ÂÃ¡Â¹ÂÃ¡Â»ÂÃ¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂNÃÂÃÂ»Ã¡Â¸Â²ÃÂPÃÂ¤Ã¡ÂºÂ


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 $2times3=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]
Ã¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂ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"]


# Jelly, 22 bytes

5RÃÂ¼7FÃ¡Â¹ÂÃ¡Â¹ÂÃ¡Â»ÂÃ¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂNÃÂÃÂ»Ã¡Â¸Â²ÃÂPÃÂ¤Ã¡ÂºÂ


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 $2times3=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]
Ã¢ÂÂ'Ã¢ÂÂ´ÃÂÃ¡ÂºÂ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"]


edited Sep 16 at 20:52

Jonathan Allan

48.6k534160

48.6k534160

• I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

• I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

I doubt it’s going to get any shorter than this. Fantastic answer, and a great explanation, well done!
âÂ maxb
Sep 17 at 5:01

# Python 2, 9392 83 bytes

lambda i:''.join('Yeahn'*(x%3<1)+'Butn'*(x%2<1)+'Non'*(x%3==1)for x in range(i))


Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

• You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

• @JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

# Python 2, 9392 83 bytes

lambda i:''.join('Yeahn'*(x%3<1)+'Butn'*(x%2<1)+'Non'*(x%3==1)for x in range(i))


Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

• You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

• @JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

# Python 2, 9392 83 bytes

lambda i:''.join('Yeahn'*(x%3<1)+'Butn'*(x%2<1)+'Non'*(x%3==1)for x in range(i))


Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

# Python 2, 9392 83 bytes

lambda i:''.join('Yeahn'*(x%3<1)+'Butn'*(x%2<1)+'Non'*(x%3==1)for x in range(i))


Try it online!

A massive 9 bytes saved with thanks to @Jonathan Frech

edited Sep 17 at 8:20

ElPedro

3,2051023

3,2051023

• You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

• @JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

• You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

• @JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

You could use string repetition instead of tuple indexing — ('','Yeahn')[x%3<1] is equivalent to "Yeahn"*(x%3<1).
âÂ Jonathan Frech
Sep 16 at 10:34

@JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

@JonathanFrech – very cool! Similar technique can be applied to the other cases as well. Many thanks!
âÂ ElPedro
Sep 17 at 8:10

1 2
next

Â

draft saved

function () {
}
);

## Understanding fb_imageblit struct for framebuffer’s imageblits ioctl

Clash Royale CLAN TAG#URR8PPP

I have been creating a custom framebuffer driver and had to implement XXXfb_imageblit. The function takes an fb_image struct as a parameter and
I do not understand how the image is stored in fb_image.

struct fb_image {
__u32 dx;       /* Where to place image */
__u32 dy;
__u32 width;        /* Size of image */
__u32 height;
__u32 fg_color;     /* Only used when a mono bitmap */
__u32 bg_color;
__u8  depth;        /* Depth of the image */
const char *data;   /* Pointer to image data */
struct fb_cmap cmap;    /* color map info */
};


It is said in the comment (fb.h) that *data should have the pointer to the image data. How is the image data represented in this case?

## migrated from unix.stackexchange.com Sep 12 at 9:46

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

I have been creating a custom framebuffer driver and had to implement XXXfb_imageblit. The function takes an fb_image struct as a parameter and
I do not understand how the image is stored in fb_image.

struct fb_image {
__u32 dx;       /* Where to place image */
__u32 dy;
__u32 width;        /* Size of image */
__u32 height;
__u32 fg_color;     /* Only used when a mono bitmap */
__u32 bg_color;
__u8  depth;        /* Depth of the image */
const char *data;   /* Pointer to image data */
struct fb_cmap cmap;    /* color map info */
};


It is said in the comment (fb.h) that *data should have the pointer to the image data. How is the image data represented in this case?

## migrated from unix.stackexchange.com Sep 12 at 9:46

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

I have been creating a custom framebuffer driver and had to implement XXXfb_imageblit. The function takes an fb_image struct as a parameter and
I do not understand how the image is stored in fb_image.

struct fb_image {
__u32 dx;       /* Where to place image */
__u32 dy;
__u32 width;        /* Size of image */
__u32 height;
__u32 fg_color;     /* Only used when a mono bitmap */
__u32 bg_color;
__u8  depth;        /* Depth of the image */
const char *data;   /* Pointer to image data */
struct fb_cmap cmap;    /* color map info */
};


It is said in the comment (fb.h) that *data should have the pointer to the image data. How is the image data represented in this case?

I have been creating a custom framebuffer driver and had to implement XXXfb_imageblit. The function takes an fb_image struct as a parameter and
I do not understand how the image is stored in fb_image.

struct fb_image {
__u32 dx;       /* Where to place image */
__u32 dy;
__u32 width;        /* Size of image */
__u32 height;
__u32 fg_color;     /* Only used when a mono bitmap */
__u32 bg_color;
__u8  depth;        /* Depth of the image */
const char *data;   /* Pointer to image data */
struct fb_cmap cmap;    /* color map info */
};


It is said in the comment (fb.h) that *data should have the pointer to the image data. How is the image data represented in this case?

linux kernel driver framebuffer

Angelo Charl

709

709

## migrated from unix.stackexchange.com Sep 12 at 9:46

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

## migrated from unix.stackexchange.com Sep 12 at 9:46

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

active

oldest

active

oldest

active

oldest

active

oldest

active

oldest

Â

draft saved

function () {
}
);

## Removing control chars (including console codes / colours) from script output

Clash Royale CLAN TAG#URR8PPP

I can use the “script” command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) with “col -b”, but I can’t find a simple way to remove the colour codes.

Note that I want to use the command line in the normal way, so don’t want to disable colours there – I just want to remove them from the script output. Also, I know can play around and try find a regexp to fix things up, but I am hoping there is a simpler (and more reliable – what if there’s a code I don’t know about when I develop the regexp?) solution.

To show the problem:

spl62 tmp: script
Script started, file is typescript
spl62 lepl: ls
asn              build-test.sh     delete-licence.sh   src
build-doc.sh     clean             doc-src             test.ini
spl62 lepl: exit
Script done, file is typescript
spl62 tmp: cat -v typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls^M
^[[01;34masn^[[0m              ^[[00;32mbuild-test.sh^[[0m     ^[[00;32mdelete-licence.sh^[[0m   ^[[01;34msrc^[[0m^M
^[[00;32mbuild-doc.sh^[[0m     ^[[00;32mclean^[[0m             ^[[01;34mdoc-src^[[0m             ^[[00mtest.ini^[[0m^M
spl62 lepl: exit^M

Script done on Thu 09 Jun 2011 09:47:29 AM CLT
spl62 tmp: col -b < typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls
01;34masn0m              00;32mbuild-test.sh0m     00;32mdelete-licence.sh0m   01;34msrc0m
00;32mbuild-doc.sh0m     00;32mclean0m             01;34mdoc-src0m             00mtest.ini0m
spl62 lepl: exit

Script done on Thu 09 Jun 2011 09:47:29 AM CLT


I can use the “script” command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) with “col -b”, but I can’t find a simple way to remove the colour codes.

Note that I want to use the command line in the normal way, so don’t want to disable colours there – I just want to remove them from the script output. Also, I know can play around and try find a regexp to fix things up, but I am hoping there is a simpler (and more reliable – what if there’s a code I don’t know about when I develop the regexp?) solution.

To show the problem:

spl62 tmp: script
Script started, file is typescript
spl62 lepl: ls
asn              build-test.sh     delete-licence.sh   src
build-doc.sh     clean             doc-src             test.ini
spl62 lepl: exit
Script done, file is typescript
spl62 tmp: cat -v typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls^M
^[[01;34masn^[[0m              ^[[00;32mbuild-test.sh^[[0m     ^[[00;32mdelete-licence.sh^[[0m   ^[[01;34msrc^[[0m^M
^[[00;32mbuild-doc.sh^[[0m     ^[[00;32mclean^[[0m             ^[[01;34mdoc-src^[[0m             ^[[00mtest.ini^[[0m^M
spl62 lepl: exit^M

Script done on Thu 09 Jun 2011 09:47:29 AM CLT
spl62 tmp: col -b < typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls
01;34masn0m              00;32mbuild-test.sh0m     00;32mdelete-licence.sh0m   01;34msrc0m
00;32mbuild-doc.sh0m     00;32mclean0m             01;34mdoc-src0m             00mtest.ini0m
spl62 lepl: exit

Script done on Thu 09 Jun 2011 09:47:29 AM CLT


22

I can use the “script” command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) with “col -b”, but I can’t find a simple way to remove the colour codes.

Note that I want to use the command line in the normal way, so don’t want to disable colours there – I just want to remove them from the script output. Also, I know can play around and try find a regexp to fix things up, but I am hoping there is a simpler (and more reliable – what if there’s a code I don’t know about when I develop the regexp?) solution.

To show the problem:

spl62 tmp: script
Script started, file is typescript
spl62 lepl: ls
asn              build-test.sh     delete-licence.sh   src
build-doc.sh     clean             doc-src             test.ini
spl62 lepl: exit
Script done, file is typescript
spl62 tmp: cat -v typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls^M
^[[01;34masn^[[0m              ^[[00;32mbuild-test.sh^[[0m     ^[[00;32mdelete-licence.sh^[[0m   ^[[01;34msrc^[[0m^M
^[[00;32mbuild-doc.sh^[[0m     ^[[00;32mclean^[[0m             ^[[01;34mdoc-src^[[0m             ^[[00mtest.ini^[[0m^M
spl62 lepl: exit^M

Script done on Thu 09 Jun 2011 09:47:29 AM CLT
spl62 tmp: col -b < typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls
01;34masn0m              00;32mbuild-test.sh0m     00;32mdelete-licence.sh0m   01;34msrc0m
00;32mbuild-doc.sh0m     00;32mclean0m             01;34mdoc-src0m             00mtest.ini0m
spl62 lepl: exit

Script done on Thu 09 Jun 2011 09:47:29 AM CLT


I can use the “script” command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) with “col -b”, but I can’t find a simple way to remove the colour codes.

Note that I want to use the command line in the normal way, so don’t want to disable colours there – I just want to remove them from the script output. Also, I know can play around and try find a regexp to fix things up, but I am hoping there is a simpler (and more reliable – what if there’s a code I don’t know about when I develop the regexp?) solution.

To show the problem:

spl62 tmp: script
Script started, file is typescript
spl62 lepl: ls
asn              build-test.sh     delete-licence.sh   src
build-doc.sh     clean             doc-src             test.ini
spl62 lepl: exit
Script done, file is typescript
spl62 tmp: cat -v typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls^M
^[[01;34masn^[[0m              ^[[00;32mbuild-test.sh^[[0m     ^[[00;32mdelete-licence.sh^[[0m   ^[[01;34msrc^[[0m^M
^[[00;32mbuild-doc.sh^[[0m     ^[[00;32mclean^[[0m             ^[[01;34mdoc-src^[[0m             ^[[00mtest.ini^[[0m^M
spl62 lepl: exit^M

Script done on Thu 09 Jun 2011 09:47:29 AM CLT
spl62 tmp: col -b < typescript
Script started on Thu 09 Jun 2011 09:47:27 AM CLT
spl62 lepl: ls
`