We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Fundamentals
- Restaurant
- Discussions
Restaurant
Restaurant
Sort by
recency
|
261 Discussions
|
Please Login in order to post a comment
This reminds me of how restaurants optimize their menus for different times of the day, just like cutting bread into the perfect squares! Efficiently using resources without waste is key, whether it's bread or a digital menu system. Speaking of which, https://malaysiamenus.com/ does something similar for restaurants by letting them update their digital menus in real time—no wasted effort, just seamless updates!
I haven't seen my approach in the comments yet and figured it may help out anyone else trying to wrap their head around it.
Alternative to the GCD approach (well documented below), I mentally wanted to find the largest square that was divisible by both l and b. It's not the most efficient, but it's how I saw the solution:
Python3
def restaurant(l, b):
Can Someone Find the Error in my Function
int restaurant(int l, int b) { if(0 == b % l ) { return b/l; } else { float frac = (float)b / (float)l ; int i = 1; while( (frac != (int)(frac)) ) { frac +=(float)b / (float)l; i++; } return (int)(i)*(int)(frac); } }