• 7



Birel Bearstill is an elven enchantress. As such, she enjoys Hooch Clashing. Birel is also a grouch. As such, she loathes boredom.

If Birel were any good at mathesparkology, given the orb sizes a tavern has ready, she could infer which configurations result in fun clashes. But no elf is really any good at that. Can you help her out?

You are given a tavern's orbSizeMin and orbSizeMax bounds on orb diameters. Find out how many distinct clashes per volume group have the potential for fun.

For example, in a tavern that boasts orb diameters from 1 to 20, the following two volume groups and four clashes would be fun:

│ King orbs │ Challenger orbs │
│ 1 12 │ 9 10 │
│ 9 10 │ 1 12 │
│ 2 16 │ 9 15 │
│ 9 15 │ 2 16 │

This is a harder take on the “Hooch Clash” puzzle. You may want to solve that one first: If you did, you can skip the remainder of the statement.

Clashes work in the same way as they did then, but here's a reminder in case you're too busy with your scrolls and spellbooks:

• the current king of the hill picks two glowing orbs and places them side by side on the table
• the challenger picks two sparkling orbs and places them opposite
• the bartender empties the hooch from each contender's orbs into a cauldron

If the glowing and sparkling liquids are provided in the exact same volume, the clash is valid and the winner is determined by fair coin toss. A valid clash is deemed fun if the four orbs on the table have a different size.
Line 1: orbSizeMin and orbSizeMax, the orb diameter inclusive bounds
One line: V C
V is the number of distinct volumes that can result in a fun clash.
C is the count of specific fun clashes.
0 < orbSizeMinorbSizeMax ≤ 10⁵
orbSizeMax - orbSizeMin < 3500
Orb diameters are integral.
1 30
4 8
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants