51
\$\begingroup\$

Challenge

The goal is to output Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.

Context. (Maybe another interesting challenge could be printing all of the other examples? This would probably use similar logic but involve either a function or just a for loop.)

Rule(s)

  1. You cannot output anything other than the string with correct casing and spacing. Trailing new lines are allowed, trailing spaces are not.

This is , so fewest bytes win!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ By the way, there is also an anarchy golf version of this question. \$\endgroup\$ – dingledooper Jan 31 at 1:26

75 Answers 75

86
\$\begingroup\$

Buffalo, 2711 2571 2517 bytes

It takes 352 [Bb]uffalo to output 8 [Bb]uffalo?! Yep, you herd that right.

BuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalobuffalobuffalo)Buffalobuffalobuffalobuffalo)buffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffalo.buffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo.buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo..buffaloBuffaloBuffaloBuffalo.buffaloBuffalobuffalobuffalobuffalobuffalobuffalobuffalobuffalobuffalo.buffaloBuffalobuffalobuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalo.buffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalo.buffaloBuffalobuffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffalobuffaloBuffalo.buffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalobuffalobuffalo)buffaloBuffalo.buffaloBuffalobuffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalo.buffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.

Try it online! Link is to an interpreter in PHP (the header is copied from GitHub). You can also copy and paste the code into the official online interpreter.

Buffalo is a cell-based language like brainf**k or COW. It has seven instructions:

  • Buffalobuffalo and buffaloBuffalo move the pointer to the left and right, respectively,
  • BuffaloBuffalo and buffalobuffalo increment and decrement the current cell value, respectively,
  • ( and ) begin and end loops, and
  • . outputs the ASCII character corresponding to the current cell value.

The strategy is simple: get the ASCII codes of Bbufalo into successive cells and then print them. The first step is achieved by coarsely initialising the cells using nested loops, then applying a correction to each cell (outside the loops) as necessary. The selected iteration counts for the inner and outer loops (both 4) are optimal. For the second step, the string is printed as Buffalo buffalo Buffalo [buffalo ]*3 Buffalo buffalo (where square brackets indicate a loop), which is the shortest approach I've found.

\$\endgroup\$
3
  • 25
    \$\begingroup\$ The right language for the job? \$\endgroup\$ – Neil Jan 31 at 18:18
  • 15
    \$\begingroup\$ The code-golf rule should make an exception. This one is the winner \$\endgroup\$ – polfosol ఠ_ఠ Jan 31 at 20:45
  • 3
    \$\begingroup\$ Brings new meaning to the "thundering herd problem". \$\endgroup\$ – Sebastian Lenartowicz Feb 2 at 10:20
55
\$\begingroup\$

Bash, 28 bytes

echo {B,b,B,b,b,b,B,b}uffalo

Try it online!

Brace expansion (Bash Reference Manual)

Same length, slightly more interesting:

echo {B,b,B,b{,,},B,b}uffalo
\$\endgroup\$
6
  • \$\begingroup\$ How does this work? \$\endgroup\$ – mowwwalker Feb 1 at 5:05
  • \$\begingroup\$ @mowwwalker Added a link to the Bash Reference Manual. \$\endgroup\$ – GammaFunction Feb 1 at 6:19
  • \$\begingroup\$ Nice. Bare word in bash doesn't even require quoting. \$\endgroup\$ – jimfan Feb 1 at 7:14
  • 4
    \$\begingroup\$ @jimfan That's Bash's secret: everything is a word. echo foo is the same as 'echo' 'foo' is the same as "echo" "foo" is the same as x=echo y=foo; $x $y. Quoting just changes whether splitting or globbing happens. \$\endgroup\$ – GammaFunction Feb 1 at 13:47
  • 6
    \$\begingroup\$ I like the choice of language (Bash is 'GNU' software). \$\endgroup\$ – user99151 Feb 3 at 7:06
28
\$\begingroup\$

Python 2, 36 bytes

for c in'BbBbbbBb':print c+'uffalo',

Try it online!

Relies on the Python 2 print magic that automagically adds a space before a printed object if it thinks it's not at the beginning of a line.

Python 2 (anagol), 36 bytes

print'uffalo '.join('BbBbbb'*2)[:63]

Try it online!

A trivial modification of the anagol solution is the same length.

Python 3, 38 bytes

print(*[x+'uffalo'for x in'BbBbbbBb'])

Try it online!

Python 3, 41 bytes

print(*map("{}uffalo".format,'BbBbbbBb'))

Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ -1 for using x and c for variable names instead of b 😛 \$\endgroup\$ – EasyasPi Feb 8 at 13:29
20
\$\begingroup\$

Husk, 14 bytes

wM?Im_ḋ162¨Ḃ=F

Try it online!

This was a simple challenge but fun :)

Explanation

wM?Im_ḋ162¨Ḃ=F
          ¨Ḃ=F    Taking the compressed string "Buffalo" (uppercase B)
 M                For each digit in    
      ḋ162         the binary digits of 162 ([1,0,1,0,0,0,1,0]):
  ?               if the digit is 1
   I               return the string itself
                  if the digit is 0
    m_             convert each character to lowercase
w                 Join all strings with spaces
\$\endgroup\$
13
\$\begingroup\$

Perl 5, 32 bytes

@_=<{,b,B,b}uffalo>;say"B@_ b@_"

Try it online!

Beats the best anagol answer by one byte:

@_=($_=Buffalo,lc)x2,print"@_ \l@_." # Mithran
@_=<{,b,B,b}uffalo>;print"B@_ b@_."  # Sisyphus
\$\endgroup\$
12
\$\begingroup\$

05AB1E, 13 bytes

Inspired by @Leo's answer, so make sure to upvote him! and me too please ;)

Ƶzbε'±ˆsi™]ðý

Try it online!

Ƶzbε'±ˆsi™]ðý  # full program
            ý  # join...
    '±ˆ        # "buffalo"...
   ε           # for map over all digits of...
Ƶz             # 162...
  b            # in binary...
         ™     # in title case...
        i      # if...
       s       # current digit in...
   ε           # map over all digits of...
Ƶz             # 162...
  b            # in binary...
        i      # is 1...
           ð   # by spaces
          ]    # exit if statement and map
               # implicit output

Boring, trivial alternative, 64 bytes

"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo

Try it online!

"...  # full program
"...  # literal
      # implicit output

EDIT: I have stood unbeaten for three months... Brownie points to anyone who outgolfs me.* Oh, and possibly some rep if I like your answer. ;)

*Just to clarify, outgolfs in any language will be accepted. It doesn't have to be 05AB1E.

\$\endgroup\$
4
  • 3
    \$\begingroup\$ +1 for winking buffalo '±ˆ \$\endgroup\$ – workoverflow Feb 2 at 13:06
  • \$\begingroup\$ @workoverflow lol \$\endgroup\$ – Makonede Feb 2 at 16:52
  • \$\begingroup\$ get golfed. ¯\_( ͡~ ͜ʖ ͡°)_/¯ \$\endgroup\$ – lyxal Feb 24 at 1:24
  • \$\begingroup\$ @Lyxal well yes, but actually no. :P \$\endgroup\$ – Makonede Feb 24 at 3:08
9
\$\begingroup\$

Retina 0.8.2, 25 bytes


BbBbbbBb
.
$&uffalo 
 $

Try it online! Explanation:


BbBbbbBb

Insert the bs in the correct capitalisation.

.
$&uffalo 

Expand the buffalo (buffaloes?).

 $

Remove the trailing space.

\$\endgroup\$
8
\$\begingroup\$

TI-BASIC, 47 bytes

"uffalo
Ans+" b"+Ans
Ans+" B"+Ans
"B"+Ans+" b"+Ans

Builds the sentence up in chunks to eliminate the need for string variables which are two byte tokens; Ans is always a single byte even when it holds a string. The strategy also minimizes use of the lowercase letters as they are two byte tokens. The final line is automatically output and you can scroll left-right for the full sentence.

\$\endgroup\$
2
  • \$\begingroup\$ Is this actually 47 bytes? Shouldn't Ans count as 1? \$\endgroup\$ – Benjamin Wang Apr 30 at 3:42
  • 1
    \$\begingroup\$ The lowercase characters are 2 bytes \$\endgroup\$ – TiKevin83 May 1 at 16:46
8
\$\begingroup\$

V (vim), 20 bytes

8ibuffalo <esc>xbb~5b~0~

Try it online!

  • 8ibuffalo <esc>, write "buffalo " 8 times. cursor at end of line.
  • x remove current character (the space at end of line).
  • bb move to the 2nd words beginning from cursor (move left).
  • ~ toggle letter case, and also move cursor 1 char right.
  • 5b~ move to the 5th words beginning from cursor (move left). And toggle case.
  • 0~ move to line beginning. And toggle case.
\$\endgroup\$
7
\$\begingroup\$

Batch, 50 49 bytes

@set s=B_b_B_b_b_b_B_buffalo
@echo %s:_=uffalo %

Batch's string handling is so poor it's golfier to explicitly include the last "buffalo" rather than trying to trim the trailing space at the end.

\$\endgroup\$
7
\$\begingroup\$

JavaScript (ES6), 46 bytes

Builds the string recursively and in reverse order.

f=n=>(n>6?'':f(-~n)+' ')+"bB"[n&n!=3]+'uffalo'

Try it online!

Alternate version

f=n=>(n>6?'':f(-~n)+' ')+"bB"[25/n&1]+'uffalo'

Try it online!

Commented

f = n =>             // f is a recursive function taking a counter n,
                     // which is initially undefined (zero'ish)
  ( n > 6 ?          // if n is greater than 6 (last iteration):
      ''             //   append nothing
    :                // else:
      f(-~n)         //   append the result of a recursive call with n + 1
      + ' '          //   followed by a space
  )                  //
  + "bB"[n & n != 3] // append "B" if n is odd and not equal to 3,
                     // or "b" otherwise
  + 'uffalo'         // append "uffalo"
\$\endgroup\$
2
  • \$\begingroup\$ ' Buffalo buffalo'.repeat(4).slice(1) saves a few bytes \$\endgroup\$ – Alex bries Feb 1 at 10:21
  • 8
    \$\begingroup\$ @Alexbries The expected output is not Buffalo buffalo repeated 4 times. The 5th word is in lower case. \$\endgroup\$ – Arnauld Feb 1 at 10:24
7
\$\begingroup\$

R, 40 39 bytes

Edit: -1 byte thanks to Dingus

cat(c('buffalo','Buffalo')[1+!21%%1:8])

Try it online!

Chooses whether to output 'buffalo' or 'Buffalo' by indexing with the vector 2 1 2 1 1 1 2 1, which is constructed as the zero values of 21 modulo each of 1...8, plus one.

Sadly, trying to recycle the 'uffalo' is significantly longer (54 bytes) due to R's somewhat cumbersome string-manipulation functions (Edit after reading the 'Anarchy Golf' link: still longer, but can be done in 46 bytes)

\$\endgroup\$
1
  • \$\begingroup\$ @Dingus - Nice! Thanks! How did I manage to miss that? \$\endgroup\$ – Dominic van Essen Feb 1 at 21:53
6
\$\begingroup\$

LabVIEW, 20 bytes

LabVIEW code (masked to 0)

LabVIEW code (masked to nonzero)

Graphical languages are harder to count, so here's my attempt:

  • 1 byte loop termination
  • 1 byte for the loop
  • 1 byte for the integer we encode the capitalization in
  • 6 bytes for the 'uffalo' string
  • 1 byte for the mask we apply to the integer encoding
  • 1 byte for the case structure
  • 1 byte for the AND
  • 1 byte for the left shift function
  • 2 bytes for the capital and noncapital letters in the case structure
  • 1 byte for the concatenate string function
  • 2 bytes for format string spec
  • 1 byte for the delimiter (space)
  • 1 byte for the array to spreadsheet string function

And yes, how'd you know about my EE degree?

\$\endgroup\$
1
  • 4
    \$\begingroup\$ This is like asking how Python counts the literal "uffalo" as 6 bytes. Of course the underlying implementation uses more bytes, but for the purposes of counting bytes in code golf, graphical languages are counted differently. If we're talking purely memory usage, it's more like 240k bytes, but that's not how any other languages are counted. \$\endgroup\$ – ijustlovemath Feb 2 at 19:09
5
\$\begingroup\$

Charcoal, 16 bytes

F⍘¹⁶²bB«ιuffalo→

Try it online! Link is to verbose version of code. Explanation:

F⍘¹⁶²bB«

Convert 162 to base 2, but use b for 0 and B for 1, and loop over the "digits".

ι

Print the b or B.

uffalo

Print the rest of the buffalo.

Prepare to leave a space before the next b, if any.

\$\endgroup\$
5
\$\begingroup\$

Perl 5, 38 bytes

$,=$";say$_=Buffalo,lc,$_,(lc)x3,$_,lc

Try it online!

\$\endgroup\$
0
5
\$\begingroup\$

JavaScript (Node.js), 45 bytes

_=>[...'BbBbbbBb'].map(x=>x+'uffalo').join` `

Try it online!

\$\endgroup\$
5
  • \$\begingroup\$ Does JavaScript code like this even need to be in lambda function form? Python3 code doesn't have all their code in lambda: CODE. For something that requires input, it would make sense, but this challenge is to just output the Buffalo string, and an evaluation of [...'BbBbbbBb'].map(x=>x+'uffalo').join` ` works fine \$\endgroup\$ – Samathingamajig Feb 1 at 6:54
  • \$\begingroup\$ @Samathingamajig by removing _=>, an alert(...) may be required to print it out. \$\endgroup\$ – tsh Feb 1 at 7:01
  • \$\begingroup\$ but shouldn't the f= be counted too? \$\endgroup\$ – Alex bries Feb 1 at 10:26
  • 1
    \$\begingroup\$ @Alexbries Anonymous function as submission is allowed as long as you do not need to (recursively) invoke it. \$\endgroup\$ – tsh Feb 1 at 10:33
  • 1
    \$\begingroup\$ 43 bytes \$\endgroup\$ – Shieru Asakoto Feb 5 at 1:48
5
\$\begingroup\$

JavaScript (V8), 43 bytes

write(a=`B${b='uffalo'} b`+b,a,c='b'+b,c,a)

Try it online!

\$\endgroup\$
5
\$\begingroup\$

C (gcc), 62 61 bytes

Realised the 61 byte version was not compliant (outputted a space at the end). Reverted and updated it to be.

-1 byte thanks to Arnauld

f(n){for(n=8;n--;)printf("%cuffalo%s","bBbbbBbB"[n]," "+!n);}

Try it online!

\$\endgroup\$
9
  • \$\begingroup\$ I noticed that in TIO is not possible to use 0 (that is the right character to use) in place of 10, so to regain the byte lost, I checked for a substitute of 32 and found that 9 works. \$\endgroup\$ – Sheik Yerbouti Jan 31 at 3:05
  • 5
    \$\begingroup\$ @Davide Ehhh tab is not the same as space, so I disagree that 9 is a replacement for 32. Also not sure what you mean by 0 instead of 10; same thing there: Different characters. \$\endgroup\$ – gastropner Jan 31 at 18:58
  • 3
    \$\begingroup\$ @Davide No, if you order printf to print a NUL character, a NUL character will be printed. It won't magically disappear. \$\endgroup\$ – gastropner Feb 1 at 3:28
  • 3
    \$\begingroup\$ @Davide: the question says to output the string as shown. It doesn't say "so it looks the same on a terminal which ignores 0 bytes", so you're not allowed to print garbage bytes like ASCII 0 at the end. That would be noticeable piping into hexdump -C, or redirecting to a file. Tabs instead of spaces is maybe justifiable, especially since standard tab-stops are 8 spaces, and "buffalo" is 7 letters long. \$\endgroup\$ – Peter Cordes Feb 1 at 6:38
  • 1
    \$\begingroup\$ Pardon my ignorance please. I thought the null character was literally nothing when printed. \$\endgroup\$ – Sheik Yerbouti Feb 1 at 12:21
5
\$\begingroup\$

Haskell, 30 bytes

init$"BbBbbbBb">>=(:"uffalo ")

Try it online!

(Cf. Are objects in Haskell valid if there is no input?)

\$\endgroup\$
5
\$\begingroup\$

x86-16 machine code, 43 42 41 bytes

  • -1 byte thanks to @CodyGray.

  • -1 byte thanks to @640KB.

0BED:0100  BA 19 01 BE 22 01 B4 09-B1 07 CD 21 AC A2 19 01   ...."......!....
0BED:0110  E2 F8 C6 44 F7 24 CD 21-C3 42 75 66 66 61 6C 6F   ...D.$.!.Buffalo
0BED:0120  20 24 62 42 62 62 62 42-62                         $bBbbbBb

Instruction listing (nasm syntax):

    org 100h      ;           | Execution of .COM files start at CS:0100

    mov dx, msg   ; BA 1B 01  | DX = offset of "Buffalo $" (for INT 21H)
    mov si, buf   ; BE 24 01  | SI = Address of "bBbbbBb"  (for LODSB)
    mov ah, 09h   ; B4 09     | AH = Opcode code INT 21H   (Output string up to '$')
    mov cl, 7     ; B1 07     | CX = 7 (we want to iterate 7 times before the last 'Buffalo')
loop:
    int 21h       ; CD 21     | Output string at msg
    lodsb         ; AC        | AX = [SI], ++SI
    mov byte [msg], al
                  ; A2 1B 01  | Set the first character of msg as the current character at buf
    loop loop     ; E2 F8     | Jump to tag 'loop' while CX >= 0
    mov byte [si - 9], "$"
                  ; C6 44 F7 24 | (After loop) Replace the last space with a '$'
    int 21h       ; CD 21     | Print the last 'buffalo'
    ret           ; C3        | Exit to DOS

msg:    db "Buffalo $"
buf:    db "bBbbbBb"

Example run

C:\test>debug code.com
-g
Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo
Program terminated normally
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Thanks to DOS's CP/M compatibility, you can exit from a .COM executable simply by returning. That takes your 2-byte int 20h down to a 1-byte ret. (The return will return to address 0000h, which already contains an int 20h. See also: Why does MS-DOS put an int 20h at byte 0 of the COM file program segment?) \$\endgroup\$ – Cody Gray Feb 2 at 0:49
  • 1
    \$\begingroup\$ Very nice! I think you can -1 byte by replacing mov byte [msg + 7], "$" (C6 06 22 01 24) with mov byte [si - 9], "$" (C6 44 F7 24). \$\endgroup\$ – 640KB Feb 2 at 23:28
  • \$\begingroup\$ I couldn't help but take another look at this with fresh eyes and came up with a riff on your answer that's 39 bytes. Oh, and it's got more of those one-byte instructions as a bonus. Now I'm done, for sure this time! :) \$\endgroup\$ – 640KB Feb 3 at 17:32
  • \$\begingroup\$ Wait, no, lies. 38 bytes... \$\endgroup\$ – 640KB Feb 3 at 17:55
4
\$\begingroup\$

PowerShell, 39 36 bytes

''+('BbBbbbBb'|% t*y|%{$_+'uffalo'})

Try it online!

-3 bytes thanks to @mazzy!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Try it online! ¯\_(ツ)_/¯ \$\endgroup\$ – mazzy Jan 31 at 15:50
  • 1
    \$\begingroup\$ OMG @mazzy you saved my 3 bytes, you are always a life saver!!!!! \$\endgroup\$ – Wasif Jan 31 at 16:30
4
\$\begingroup\$

C (gcc), 63 bytes

-2 bytes thanks to @Arnauld

n=7;f(){printf("%cuffalo%c","bBbbbBbB"[n],9+!n),n--?f():(n=7);}

Try it online!

Could have been shorter if it wasn't for the reusability rule killing recursive functions.

\$\endgroup\$
6
  • \$\begingroup\$ @Arnauld i couldn't see it. Thank you so much! \$\endgroup\$ – Sheik Yerbouti Jan 31 at 11:26
  • \$\begingroup\$ This is invalid, you init n=7 by calling this as f(7). It has to be called as f(7) or it doesn't work. \$\endgroup\$ – Noodle9 Jan 31 at 18:33
  • \$\begingroup\$ Why don't you just write it as f(char*s){printf(s);} and pass in the output string? T_T \$\endgroup\$ – Noodle9 Jan 31 at 18:47
  • 3
    \$\begingroup\$ Regardless of a [Kolmogorov-complexity] tag, requiring the caller to hard-code a 7 based on the internal implementation details is not ok. Generalizing the task to print some pattern of buffalos and requiring the caller to pass a 7 is solving a different question (and very hard to justify when only numbers <=7 work because you hard-coded a lookup table of that length.) TL:DR: I would have downvoted the first version of this answer regardless of tags, but this is good. I'm not sure tabs are allowed instead of spaces, but I like that 9+!n enough to upvote anyway :P \$\endgroup\$ – Peter Cordes Feb 1 at 6:33
  • 1
    \$\begingroup\$ @PeterCordes all right, I need to make less assumptions. Anyway this 9+!n is @Arnauld's contribution \$\endgroup\$ – Sheik Yerbouti Feb 1 at 12:18
4
+50
\$\begingroup\$

Whispers v2, 86 79 bytes

> "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo"
>> Output 1

Try it online!

Well, this is embarrassing...

The first line alone could even be enough, as a function returning the string

For something a bit more interesting, here's my previous solution:

Whispers v2, 86 bytes

> "Buffalo "
> "buffalo "
>> 1+2
>> 3+3
>> 2+2
>> 5+3
>> 4+6
> 63
>> 7ᶠ8
>> Output 9

Try it online!

First approach to the language of the month for me :) It looks like building the string by manually concatenating pieces is the best approach in Whispers.

Explanation

Whispers starts the execution from the last line of the program, and then follows references from there. Any number in a line starting with >> refers to the result of the corresponding line, while numbers in lines starting with > have their normal value. We can only have a single operation per line (hence why so many lines).

Most lines here simply concatenate two strings, while line 9 takes the first 63 characters from the string in line 7, which is all except for the trailing space. It should be pretty easy to read, but here's the value computed by each line:

> "Buffalo "        1:"Buffalo "
> "buffalo "        2:"buffalo "
>> 1+2              3:"Buffalo buffalo "
>> 3+3              4:"Buffalo buffalo Buffalo buffalo "
>> 2+2              5:"buffalo buffalo "
>> 5+3              6:"buffalo buffalo Buffalo buffalo "
>> 4+6              7:"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo "
> 63                8:63
>> 7ᶠ8              9:"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo"
>> Output 9         10:prints out line 9
\$\endgroup\$
3
\$\begingroup\$

Mathematica, 54 bytes

Print@@Riffle[#<>"uffalo"&/@Characters@"BbBbbbBb"," "]

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Jelly, 15 bytes

162Bị“¢OỊ“¦ȯø»K

Try it online!

(Alternatively, 162Bị“¢OỊ»,Œl¤K)

I might be doing something wrong if this comes out two bytes shorter than title-casing dynamically...:

Jelly, 17 bytes

Œt⁹¡
162B“¦ȯø»çⱮK

Try it online!

\$\endgroup\$
3
\$\begingroup\$

APL+WIN, 21 bytes

'BbBbbbBb',¨⊂'uffalo'

Try it online! Thanks to Dyalog Classic

This could be shortened to 5 bytes if the two strings were given as input rather than being hard coded.

\$\endgroup\$
3
\$\begingroup\$

Julia, 42 bytes

join(collect("BbBbbbBb").*"uffalo ")[1:63]

Very similar to what was done with Python above.

\$\endgroup\$
3
3
\$\begingroup\$

Whispers v2, 98 bytes

> 81
> 2
>> 1⊥2
> "Buffalo "
> "buffalo "
> "buffalo"
>> If L 4 5
>> Each 7 3
>> 8+6
>> Output 9

Try it online!

\$\endgroup\$
1
3
\$\begingroup\$

TeX, 34 bytes

\def~{uffalo }B~b~B~b~b~b~B~b~\bye

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to Code Golf, nice first answer! \$\endgroup\$ – Redwolf Programs Feb 4 at 4:27
3
\$\begingroup\$

Java (JDK), 49 bytes

v->"B b B b b b B b".replaceAll("\\w","$0uffalo")

Try it online!

Credits

\$\endgroup\$
7
  • 1
    \$\begingroup\$ 50 bytes \$\endgroup\$ – Kevin Cruijssen Feb 1 at 10:31
  • \$\begingroup\$ Nice find, @KevinCruijssen I was golfing byte by byte and you with a totally different approach, thanks :) \$\endgroup\$ – Olivier Grégoire Feb 1 at 10:41
  • \$\begingroup\$ You can save another byte by moving the spaces to the string. Try it online! \$\endgroup\$ – Jo King Feb 4 at 5:36
  • \$\begingroup\$ 41 bytes \$\endgroup\$ – branboyer Mar 7 at 5:25
  • \$\begingroup\$ @branboyer actually, trailing spaces are explicitly disallowed, but thanks! \$\endgroup\$ – Olivier Grégoire Mar 7 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.