The Magic Bean 🫘

Day 15 in the Bright Beacen Mosque and uncle Idris (the mosque chef) notices that the community is looking a little lethargic after iftar. The samosas and biryani were a little much.

It's suggested that he serves everyone a magic bean known for its energy boosting properties.

John from the ends is currently writing his thesis on 3 years of research in AI. He has devised a method to work out the level of tiredness & ability to remain attentive a person has using an app that he has worked on.

He uses it to grade every person in the hall.

Through his research he has learned that even when tired, the person next to you can serve as a motivational boost when tired.
This means that a combination of the caffeine from the Turkish coffee and the spiritual boost (which is 25%) from the compatriot to your left & to your right can serve as the perfect boost to get a person up on their feet tp pray tarawih.

If a person has an energy level 4, the person to his right is a level 7 and the person to his left is a level 3, they would end up with an energy level of 6.5.

Rules - The calculation

Each person receives:
- Their own energy level (the base energy level)
- A 25% boost from the person on their left
- A 25% boost from the person on their right

For example:

If a person has energy 4, their left neighbour is 3, and their right neighbour is 7:

boost = 0.25 × 3 + 0.25 × 7 = 0.75 + 1.75 = 2.5  
final_energy = 4 + 2.5 = 6.5

This means that the person would need an energy boost of 3.5 from the magic bean.

Turkish coffee rules:

  • 10g of coffee gives +5 energy
  • 1g gives +0.5 energy
  • If someone has an energy level of >= 10, they do not need a coffee boost.

    SOoooo...:
    - If final_energy = 9.9 → they need 0.1 boost
    - If final_energy = 10.1 → they need 0

❗Two extra bits of information:

  • Although base energy levels are given as integers, the returned values may be calculated as decimals.
  • It's important to point out that everyone only recieves an energy boost from their neighbour's initial energy level and not after their neighbour's new level is calculated!

Task

Your input file gives you a scan of every persons energy level.

Use it to determine how much caffeine needs to be purchased if each container of Mehmet Efendi Turkish Coffee weighs 500g.
Round up to the nearest whole container.