x86-16 machine code, IBM PC DOS, 35 33 32 bytes
00000000: b820 09b1 e7ba 1801 cd21 d0e9 7409 7303 . .......!..t.s.
00000010: 3044 19cd 29eb f1c3 4275 6666 616c 6f24 0D..)...Buffalo$
Listing:
B8 0920 MOV AX, 0920H ; AH = 9 DOS string function, AL = ' '
B1 E7 MOV CL, 11100111b ; magic buffalo number 11100111
BA 0118 MOV DX, OFFSET BUF ; 'Buffalo' pointer for display
STAMPEDE:
CD 21 INT 21H ; write our *uffalo to screen
D0 E9 SHR CL, 1 ; LSB of magic buffalo number into CF
74 09 JZ BYE_BUFFALO ; loop until CL is 0
73 03 JNC HI_BUFFALO ; if LSB bit is a 0, don't change case
30 44 19 XOR [SI+BUF-100H], AL ; swap case on first letter
HI_BUFFALO:
CD 29 INT 29H ; if not last of the buffalo, display a space
EB F1 JMP STAMPEDE ; keep 'em coming
BYE_BUFFALO:
C3 RET ; return to DOS
BUF:
DB 'Buffalo$' ; the real Buffalo
Try it online!
Explanation:
Uses the byte 0xe7
(1110 0111
binary) to determine if the case should be swapped. Each [Bb]uffalo
corresponds to the next least significant bit of the byte where a 1
means to change the case and a 0
means don't change.
The case of the first character can be alternated by doing an xor 0x20
on the ASCII value. Now 0x20
just happens to be the ASCII value for a space character, so we can put that in al
and use for both the xor
and to write the space character.
Props:
- -1 byte thx to @peter ferrie!