Skip to content

Instantly share code, notes, and snippets.

Created November 30, 2022 21:04
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Oh it's just FizzBuzz, right?

It's been a fun conference. You've done well to make it this far. We're proud of you!

You're probably exhausted, so for today we're treading familiar territory. We want you to implement FizzBuzz for your solution.

Just include your code in the snippet below and submit.

Here's the twist:

We'll be benchmarking winners based on number of instructions used! FizzBuzz in a nutshell: return "Fizz" if a number is divisible by 3, "Buzz" if divisible by 5, "FizzBuzz" if divisible by both!

If you have no idea how we're going to measure that, don't worry, we'll share our work! The legendary @kddnewton has provided a method for us that we'll be using to check your work here:

(Note: no cute solutions here with the tests, proper fizzbuzz! We will be checking it on the human level as well)

def count_iseq(iseq)
  iseq[12].select { _1 in [:ensure | :rescue, *] }.sum { count_iseq(_1[1]) } +
  iseq[13].sum do
    case _1
    in Integer | Symbol
    in [*, ["YARVInstructionSequence/SimpleDataFormat", *] => child_iseq, *]
      1 + count_iseq(child_iseq)
    in Array

def count(source)
def solution(number)
  # Your code here

raise unless solution(3) == "Fizz"
raise unless solution(5) == "Buzz"
raise unless solution(15) == "FizzBuzz"

puts "It works!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment