56
\$\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
  • 3
    \$\begingroup\$ By the way, there is also an anarchy golf version of this question. \$\endgroup\$ Commented Jan 31, 2021 at 1:26

93 Answers 93

103
\$\begingroup\$

Buffalo, 2711 2571 2517 2447 2279 2183 bytes

It takes 304 buffalo to produce 8 buffalo?! Yep, you herd that right.

BuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(buffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalobuffalobuffalo)buffaloBuffalobuffalobuffalobuffaloBuffaloBuffaloBuffalobuffaloBuffalobuffalobuffalobuffaloBuffalobuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalobuffalobuffalo)Buffalobuffalobuffalobuffalo)buffaloBuffalobuffaloBuffalobuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo.buffaloBuffalo.buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo..buffaloBuffalobuffalobuffalobuffalobuffalo.buffaloBuffalo.buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo.buffaloBuffalobuffalobuffalobuffalobuffalobuffalobuffalobuffalobuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffaloBuffalo.BuffalobuffaloBuffalobuffalo.buffaloBuffalo..buffaloBuffalobuffalobuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalo.buffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo(BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffaloBuffalo.BuffalobuffaloBuffalobuffalo.buffaloBuffalo..buffaloBuffalobuffalobuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalobuffalobuffalo)BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffaloBuffalobuffalo.buffaloBuffalo.buffaloBuffalo..buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.buffaloBuffalo.BuffalobuffaloBuffalobuffaloBuffalobuffaloBuffaloBuffalo.BuffalobuffaloBuffalobuffalo.buffaloBuffalo..buffaloBuffalobuffalobuffalo.buffaloBuffalo.buffaloBuffalo.

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

Buffalo is a cell-based language like brainfuck 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.

Aiming to get the ASCII codes of Bufalo into successive cells, we first do a coarse initialisation using three nested loops. A correction is then applied to each cell (outside the loops) as necessary. The selected iteration counts (3 for the outer and middle loops and 4 for the inner loop) are apparently optimal. The ASCII code for the lowercase b does not get its own cell; rather, we generate it on the fly in the a cell.

Once the ASCII codes have been generated, the output is printed character-by-character as Buffalo buffalo Buffalo (buffalo )Buffalo buffalo, where the segment in parentheses represents a loop that runs 3 times.

\$\endgroup\$
3
  • 30
    \$\begingroup\$ The right language for the job? \$\endgroup\$
    – Neil
    Commented Jan 31, 2021 at 18:18
  • 17
    \$\begingroup\$ The code-golf rule should make an exception. This one is the winner \$\endgroup\$ Commented Jan 31, 2021 at 20:45
  • 5
    \$\begingroup\$ Brings new meaning to the "thundering herd problem". \$\endgroup\$ Commented Feb 2, 2021 at 10:20
64
\$\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\$
7
  • \$\begingroup\$ How does this work? \$\endgroup\$
    – mowwwalker
    Commented Feb 1, 2021 at 5:05
  • \$\begingroup\$ @mowwwalker Added a link to the Bash Reference Manual. \$\endgroup\$ Commented Feb 1, 2021 at 6:19
  • \$\begingroup\$ Nice. Bare word in bash doesn't even require quoting. \$\endgroup\$
    – jimfan
    Commented Feb 1, 2021 at 7:14
  • 7
    \$\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\$ Commented Feb 1, 2021 at 13:47
  • 9
    \$\begingroup\$ I like the choice of language (Bash is 'GNU' software). \$\endgroup\$
    – user99151
    Commented Feb 3, 2021 at 7:06
30
\$\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
  • 7
    \$\begingroup\$ -1 for using x and c for variable names instead of b 😛 \$\endgroup\$
    – EasyasPi
    Commented Feb 8, 2021 at 13:29
22
\$\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\$
15
\$\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
  • 6
    \$\begingroup\$ +1 for winking buffalo '±ˆ \$\endgroup\$ Commented Feb 2, 2021 at 13:06
  • \$\begingroup\$ @workoverflow lol \$\endgroup\$
    – Makonede
    Commented Feb 2, 2021 at 16:52
  • \$\begingroup\$ get golfed. ¯\_( ͡~ ͜ʖ ͡°)_/¯ \$\endgroup\$
    – lyxal
    Commented Feb 24, 2021 at 1:24
  • \$\begingroup\$ @Lyxal well yes, but actually no. :P \$\endgroup\$
    – Makonede
    Commented Feb 24, 2021 at 3:08
14
\$\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\$
10
\$\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\$
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\$
9
\$\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\$ Commented Feb 1, 2021 at 21:53
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\$ Commented Apr 30, 2021 at 3:42
  • 1
    \$\begingroup\$ The lowercase characters are 2 bytes \$\endgroup\$
    – TiKevin83
    Commented May 1, 2021 at 16:46
8
\$\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\$
8
\$\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
  • 5
    \$\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\$ Commented Feb 2, 2021 at 19:09
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
    Commented Feb 1, 2021 at 10:21
  • 9
    \$\begingroup\$ @Alexbries The expected output is not Buffalo buffalo repeated 4 times. The 5th word is in lower case. \$\endgroup\$
    – Arnauld
    Commented Feb 1, 2021 at 10:24
7
\$\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
    Commented Feb 2, 2021 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
    Commented Feb 2, 2021 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
    Commented Feb 3, 2021 at 17:32
  • 1
    \$\begingroup\$ Wait, no, lies. 38 bytes... \$\endgroup\$
    – 640KB
    Commented Feb 3, 2021 at 17:55
6
\$\begingroup\$

JavaScript (V8), 43 bytes

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

Try it online!

\$\endgroup\$
6
\$\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\$
    – anotherOne
    Commented Jan 31, 2021 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
    Commented Jan 31, 2021 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
    Commented Feb 1, 2021 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\$ Commented Feb 1, 2021 at 6:38
  • 1
    \$\begingroup\$ Pardon my ignorance please. I thought the null character was literally nothing when printed. \$\endgroup\$
    – anotherOne
    Commented Feb 1, 2021 at 12:21
6
\$\begingroup\$

Haskell, 30 bytes

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

Try it online!

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

\$\endgroup\$
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\$ Commented Feb 1, 2021 at 6:54
  • \$\begingroup\$ @Samathingamajig by removing _=>, an alert(...) may be required to print it out. \$\endgroup\$
    – tsh
    Commented Feb 1, 2021 at 7:01
  • \$\begingroup\$ but shouldn't the f= be counted too? \$\endgroup\$
    – Alex bries
    Commented Feb 1, 2021 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
    Commented Feb 1, 2021 at 10:33
  • 1
    \$\begingroup\$ 43 bytes \$\endgroup\$ Commented Feb 5, 2021 at 1:48
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
    Commented Jan 31, 2021 at 15:50
  • 1
    \$\begingroup\$ OMG @mazzy you saved my 3 bytes, you are always a life saver!!!!! \$\endgroup\$
    – Wasif
    Commented Jan 31, 2021 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\$
    – anotherOne
    Commented Jan 31, 2021 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
    Commented Jan 31, 2021 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
    Commented Jan 31, 2021 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\$ Commented Feb 1, 2021 at 6:33
  • 1
    \$\begingroup\$ @PeterCordes all right, I need to make less assumptions. Anyway this 9+!n is @Arnauld's contribution \$\endgroup\$
    – anotherOne
    Commented Feb 1, 2021 at 12:18
4
\$\begingroup\$

Julia, 42 bytes

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

Very similar to what was done with Python above.

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

Python 3, 39 bytes

print('uffalo '.join('BbBbbbBb ')[:-2])

Try it online!

Potentially invalid, 35 bytes

print('uffalo '.join('BbBbbbBb\b'))

Try it online!

\$\endgroup\$
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\$
4
\$\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\$
    – rydwolf
    Commented Feb 4, 2021 at 4:27
4
\$\begingroup\$

awk, 22- or 41-bytes. basic approach is 41-bytes:

echo Buffalo | 
mawk 'NF+=sub("  ",OFS=" "tolower($2=$4=$1)" ")'       
Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo

but if we're going with the entirely hard-coded approach, that can massively cut it down to just 22-bytes (and that's already inclusive of the single quotes for OFS) :

echo BbBbbbBb | 
mawk NF++ FS= OFS='uffalo '
Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo 

Trivia tidbit - if we view "B"'s as "1"'s and "b"'s as "0"'s,

then the requirement would appear 10100010, while its decimal form can be reached via either

  2 * ( 3 ^ 4 )
                or
  3  *  6 * 9 
\$\endgroup\$
10
  • \$\begingroup\$ Nice approach, but you can't rely on your code receiving input (in this case 'BbBbbbBb'), so you need to include the echo in the byte count like this... \$\endgroup\$ Commented Nov 1, 2022 at 15:27
  • \$\begingroup\$ @DominicvanEssen : u know full well that awk entries are instantly pre-penalized with having to either (1) invoke a BEGIN { } block, (2) use echo/printf, or (3) do <<< at the shell level, and that's before any of the code logic even began, with all options being rather costly, golfing-wise. if you're willing to use the byte-count only for the logic inside the BEGIN { } block itself instead of end-to-end, then i can write it with birdies and eagles \$\endgroup\$ Commented Nov 1, 2022 at 20:33
  • 2
    \$\begingroup\$ It may seem 'unfair' that awk entries are pre-penalized with BEGIN or echo or other costly code, but that's how it's scored. Everyone should play by the same rules. Other languages have seemingly-wasteful boilerplate too. In the case of your mawk NF++ FS= OFS='uffalo ' code as it is now (which is 27 bytes, not 22), you're not even counting the 'BbBbbbBb' string, which is a fundamental part of the code logic. \$\endgroup\$ Commented Nov 2, 2022 at 10:21
  • \$\begingroup\$ @DominicvanEssen : say that "x86-16 machine code" entry below : can a file with only that and nothing else, with ".exe" extension, execute ? \$\endgroup\$ Commented Nov 3, 2022 at 13:54
  • 3
    \$\begingroup\$ Well, I think you should simply amend your answer to 'bash+AWK' and include the echo for 40 bytes. Your approach is really nice, and shorter than the pure-awk one \$\endgroup\$ Commented Nov 3, 2022 at 14:29
3
\$\begingroup\$

Mathematica, 54 bytes

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

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ -6 bytes if you can assume a notebook environment (which I don't know if you can) \$\endgroup\$
    – JSorngard
    Commented Nov 2, 2022 at 12:40
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\$

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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