Skip to content

Instantly share code, notes, and snippets.

@BBischof
Created April 1, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBischof/0cd666a4086e0a7eb6da6a99fe5efab7 to your computer and use it in GitHub Desktop.
Save BBischof/0cd666a4086e0a7eb6da6a99fe5efab7 to your computer and use it in GitHub Desktop.
Computing the amount of beans for the hopper
def bean_counter(output_shots: Int) : Int = {
if (output_shots >= 0) {
return (output_shots/2)*20 + output_shots%2*16
} else {
throw new IllegalArgumentException("Not a valid number of shots.")
}
}
@colindean
Copy link

The most hilarious part of that is that I tried to simplify the math prematurely and ended up completely skipping the integer division. I couldn't figure out for the life of me why when outputShots was odd why I was off by 10. Then, duh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment