dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.6 KiB
2.6 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69b58ce40693f140c84c855a | Challenge 241: FizzBuzz Validator | 29 | challenge-241 |
--description--
Given an array of sequential integers, with multiples of 3 and 5 replaced, determine if it's a valid FizzBuzz sequence.
In a valid FizzBuzz sequence:
- Multiples of 3 are replaced with "Fizz".
- Multiples of 5 are replaced with "Buzz".
- Multiples of both 3 and 5 are replaced with "FizzBuzz".
- All other numbers remain as integers.
--hints--
is_fizz_buzz([1, 2, "Fizz", 4, "Buzz"]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz([1, 2, "Fizz", 4, "Buzz"]), True)`)
}})
is_fizz_buzz([13, 14, "FizzBuzz", 16, 17]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz([13, 14, "FizzBuzz", 16, 17]), True)`)
}})
is_fizz_buzz([1, 2, "Fizz", 4, 5]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz([1, 2, "Fizz", 4, 5]), False)`)
}})
is_fizz_buzz(["FizzBuzz", 16, 17, "Fizz", 19, "Buzz"]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz(["FizzBuzz", 16, 17, "Fizz", 19, "Buzz"]), True)`)
}})
is_fizz_buzz([1, 2, "Fizz", "Buzz", 5]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz([1, 2, "Fizz", "Buzz", 5]), False)`)
}})
is_fizz_buzz([97, 98, "Buzz", "Fizz", 101, "Fizz", 103]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz([97, 98, "Buzz", "Fizz", 101, "Fizz", 103]), False)`)
}})
is_fizz_buzz(["Fizz", "Buzz", 101, "Fizz", 103, 104, "FizzBuzz"]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_fizz_buzz(["Fizz", "Buzz", 101, "Fizz", 103, 104, "FizzBuzz"]), True)`)
}})
--seed--
--seed-contents--
def is_fizz_buzz(arr):
return arr
--solutions--
def is_fizz_buzz(arr):
start = None
for i, val in enumerate(arr):
if isinstance(val, int):
start = val - i
break
if start is None:
return False
for i in range(len(arr)):
n = start + i
if n % 15 == 0:
expected = "FizzBuzz"
elif n % 3 == 0:
expected = "Fizz"
elif n % 5 == 0:
expected = "Buzz"
else:
expected = n
if arr[i] != expected:
return False
return True