Skip to content

Instantly share code, notes, and snippets.

@segomin
Last active March 15, 2024 11:36
Show Gist options
  • Save segomin/d5a603123f8cd17e61daa4c65d9ac88d to your computer and use it in GitHub Desktop.
Save segomin/d5a603123f8cd17e61daa4c65d9ac88d to your computer and use it in GitHub Desktop.
Algorithmic PS
@main def main(): Unit = {
val emptyBox = 102
val bigBox = 11
val product = 8
def emptyCount(bigBox: Int, product: Int, emptyBoxes: Int): Int = {
(emptyBoxes - bigBox) / (product - 1)
}
def totalCount(bigBox: Int, product: Int, newBoxCount: Int): Int = {
(newBoxCount * product) + bigBox
}
val newBoxes = emptyCount(bigBox, product, emptyBox)
val total = totalCount(bigBox, product, newBoxes)
println(s"Middle and small boxes: $newBoxes")
println(s"Total: $total")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment