Maximum Chocolates — Puzzle Asked In Interviews


You have 15 Rs with you. You go to a shop and shopkeeper tells you price as 1 Rs per chocolate. He also tells you that you can get a chocolate in return of 3 wrappers. How many maximum chocolates you can eat?


Answer: 22
Buy and eat 15 chocolates
Return 15 wrappers and get 5 more chocolates.
Return 3 wrappers, get 1 chocolate and eat it (keep 2 wrappers)
Now we have 3 wrappers. Return 3 and get 1 more chocolate.
So total chocolates = 15 + 5 + 1 + 1An efficient solution is to use a direct formula to find the number of chocolates.Find initial number of chocolates by
dividing the amount with per piece cost.
i.e. choc = money / price

then apply below formula
choc += (choc - 1)/(wrap - 1)


Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.




Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Quotes That Reshape Perceptions on ‘Face Mask’

Judy Garland’s Casket Handles

I Fix Amerika!: A Holiday Travel Diary from Krampus, the Bavarian Christmas Demon

The Secret Plague That Causes Limp Erections

Pandemic Phrases Updated for an Era When I Can Have Casual Sex Again

Dentitox, the nation’s leading brand in dental-care products, has some advice for you: Brushing…

Fashion diva

Don’t disturb Otherwise…………..

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Upskilling students for tech placements!

More from Medium

K Smallest Elements

Leetcode 862. Shortest Subarray with Sum at Least K

Meta / Amazon / Google / Microsoft Interview Question: Wildcard Matching Solution | LeetCode-44…

1570. Dot Product of Two Sparse Vectors