| Bytes | Lang | Time | Link |
|---|---|---|---|
| 081 | AWK | 241029T195143Z | xrs |
| 198 | Charcoal | 240724T132004Z | Neil |
| 018 | JCram | 240724T094205Z | Kamila S |
| nan | Nibbles | 240724T090030Z | Dominic |
| 1275 | Vyxal | 240723T104002Z | lyxal |
AWK, 81 bytes
{for(;++i<500;)s=s (i%3?i%5?i:y="Buzz":i%5?x="Fizz":x y);$0=s~$1?"true":"false"}1
{for(;++i<500;) # craft the test string
s=s (i%3?i%5?i # number if not divisible
:y="Buzz": # divisible by 5
i%5?x="Fizz" # divisible by 3 (from above)
:x y); # concat string
$0=s~$1?"true":"false"}1 # compare input and set output
Charcoal, 198 bytes
≔E01124⪪…FizzBuzzBuzz×⁴Iι⁸υ≔⭆θ›ι9η¿⬤⌕Aη10I§θ⊕ι¿№η01¿№η10¿‹⌕η10⌈⌕Aη01«≔⌈Φ⮌Φ⪪η1κκζ≔⊕⌕η⪫11ζε≔✂θε⁺εLζ¹ζF¬﹪Iζ³≔∕ζ²ζ№⭆ΦEθ⁺κ⁻Iζε›ι⁰∨⭆⌈υ×…λ⁴¬﹪ι⁺³⊗μιθ»№§υI§θ⊖⌕η1Φθ›ι9⊙§υΣθ¬⌕ιΦθ›λ9¿№η10⊙⌈υ¬⌕⮌ι⮌Φθ›λ9⊙⌈υ№ιΦθ›λ9
Try it online! Link is to verbose version of code. Explanation: Deliberately not brute force.
≔E01124⪪…FizzBuzzBuzz×⁴Iι⁸υ
Each digit has a limited number of alphabetic strings that can appear between it and the next digit. For 0 and 5, this is no strings at all, since those should be Buzz in the first place. For 1, 2, 6 and 7 this can only be Fizz. For 3 and 8 this can only be FizzBuzz (e.g. between 23 and 26). For 4 and 9 this can be either FizzBuzz (e.g. between 14 and 16) or BuzzFizz (e.g. between 4 and 7). The list of acceptable strings for each digit is computed here.
≔⭆θ›ι9η
Identify which of the characters are letters and which are digits.
¿⬤⌕Aη10I§θ⊕ι
Check that no digit that follows a letter is a 0.
¿№η01
If there is at least one letter following a digit:
¿№η10
If there is at least one digit following a letter:
¿‹⌕η10⌈⌕Aη01«
If the digit is surrounded by letters:
≔⌈Φ⮌Φ⪪η1κκζ≔⊕⌕η⪫11ζε≔✂θε⁺εLζ¹ζ
Find the longest number in the input (excluding any leading and trailing digits) and its position.
F¬﹪Iζ³≔∕ζ²ζ
If it's a multiple of 3 then take the first half.
№⭆ΦEθ⁺κ⁻Iζε›ι⁰∨⭆⌈υ×…λ⁴¬﹪ι⁺³⊗μιθ
Generate FizzBuzz in the vicinity of that number and see whether that contains the input.
»№§υI§θ⊖⌕η1Φθ›ι9
Otherwise, we have leading and trailing digits with letters in between. Look at the last leading digit and check that the intervening letters match any of the permitted strings.
⊙§υΣθ¬⌕ιΦθ›λ9
Otherwise we have leading digits and trailing letters. Look at the last leading digit again and check that the following letters are a prefix of any of the permitted strings.
¿№η10
Otherwise if there are letters followed by digits:
⊙⌈υ¬⌕⮌ι⮌Φθ›λ9
Check that the letters are a suffix of FizzBuzz or BuzzFizz.
⊙⌈υ№ιΦθ›λ9
Otherwise if there are letters then they must be a substring of FizzBuzz or BuzzFizz.
JCram, 18 bytes (SBCS).
-2 thanks to @emanresu A
⍄πx②≠A⌿⍆P⍠⊔③H≥Ⓐ⍁⍚⍨
Encodes the following ES6 program:
n=>{s='';for(i=0;i++<1000**n.length;s+=((i%3?'':'Fizz')+(i%5?'':'Buzz')||i));return s.includes(n)}
Uses a similar idea to Dominic van Essen's answer.
Nibbles, 49 48 47 nibbles (23.5 bytes)
Edit: -1 nibble and bug-fix thanks to I4m2
<<% +.,^;@,$ or:^-~%$3"Fizz"^-~%$5"Buzz"@
Attempt a version of this Online!
Outputs a non-empty list (truthy by if/else) if the input is a substring of FizzBuzz, or an empty list (falsy by if/else) if it is not. Two nibbles longer to output nonzero or zero (also truthy & falsy).
Searches the first 1000^length elements of the FizzBuzz sequence for the input string. The link above exchanges this for 10^4 elements in order to run more quickly for longer input strings.
The double string "Fizz""Buzz" alone uses up 9.5 bytes here, so languages with a "FizzBuzz" built-in have a definite advantage!
We start by generating the FizzBuzz sequence. The shortest Nibbles program for this (probably), by Nibbles creator Darren Smith, is presented on the Nibbles home page:
$?,:^-~%$3"Fizz"^-~%$5"Buzz" = 36 nibbles (18 bytes)
However, this uses several tricks - implicit map, implicit range, 2 implicit variables - that need to be explicitly specified as part of a longer program, which would add to the program's length.
So here we use a (1-nibble) longer version :
$or:^-~%$3"Fizz"^-~%$5"Buzz"@ = 37 nibbles (18.5 bytes)
This doesn't use implicit variables, so can end-up 1-nibble shorter as part of a longer program, if this is carefully constructed.
The rest of the program works as follows:
<< % +.,^;@,$ or:^-~%$3"Fizz"^-~%$5"Buzz"@ # full program
<< % +.,^;@,$ or:^-~%$3"Fizz"^-~%$5"Buzz"@$ # with implicit variable shown
,$ # length of input
^;@ # 1000 to the power of that
, # range from 1..that
. # map over numbers i in range:
or # first arg if non-empty, otherwise second:
# 1st arg:
: # join
^ # replicate
"Fizz" # "Fizz"
-~ # 1 minus
%$3 # i modulo 3 times
^-~%$5"Buzz" # to the same for "Buzz"
# 2nd arg:
@ # i
+ # now, flatten it all into one string,
% $ # split it on the input,
<< # and discard the last element.
Vyxal, 102 bitsv2, 12.75 bytes
L↵↵ƛ₍₃₅kF½*∑∴;ṅ$c
Bitstring:
011000100011101111110100001110110100100110110110001000111101010000010001110110000011101111010010010111
Times out for everything. Quite possibly because it's generating \$10^{10^{\text{length}(input)}}\$ items of fizzbuzz. Someone has to try the brute force method, right?
Explained (old)
L↵↵↵ƛ₍₃₅kF½*∑∴;ṅ$c
L↵↵↵ # Push 10 ** 10 ** 10 ** len(input)
ƛ₍₃₅kF½*∑∴; # Average vyxal fizzbuzz moment: https://codegolf.stackexchange.com/questions/58615/1-2-fizz-4-buzz/210307#210307
ṅ # Join into a single string
$c # Is the input in that?
💎
Created with the help of Luminespire.