Lemonade Stand - The Results Are In

This post is more than 2 years old.

It's been a week since I announced the Lemonade Stand contest, and I hope folks weren't too disappointed when I delayed the results last Friday. Thankfully that whole mess is done with now. Last night I worked a bit more on my simulator, trying to clean up the results a bit, but the code itself is still a bit ugly. But who cares. What folks want to know is who won this little contest.

First, thanks to everyone who sent in an entry. There were 16 entries total. (In the results you will see 17, since I included one of my test functions.) Some of the functions were pretty darn intense. I was also surprised to see that folks put a bit more logic into their code then my simulator even considered. So for example, Mat Evans' code actually reduced his cup price if it was too hot. That makes sense. If it's a 100+ degrees outside folks won't be strolling around looking for lemonade. My code didn't actually take that into consideration but it's a good idea.

I was also surprised to find folks writing good error management into their code. What I mean is, their code would throw an error if I sent an invalid weather type. That would imply that the entire simulator was broken and seems a bit overkill, but you know what - you can't be too safe. So props to them. (Although I automatically dinged your results for implying I'm less than perfect.)

There were also some real gems in the comments. Matt Osbun had this to say:

I'm pretty sure that if the temp gets hot enough to drive the offset high enough to produce a greater-than-50-cent cup of lemonaid, the Earth has greater worries than this, but if it does, consider the 50 cents to be an End Of Days Sale. 136 degrees, if you did the math- Highest recorded temperature in the world (El Azizia, Libya) and two degrees hotter than the highest recorded temperature in the United States (Death Valley)

Nice. So in the end, there was one clear winner. This guy's code was always #1, or #2, right after my entry. (And it beat mine about 90% of the time it seems.) His entry worked so well it really became a fight for second place (again, ignoring my entry). The winner is...

Geoffrey K. Bentz

Congrats to him! In second place it was a fight between Mat Evans, Brian Kotek, and sometimes Coyne. For a representative example of the results, click the chart below to see the full screen version.

The numerical results for this run were:

FINAL FOR BENTZ: $866.89
FINAL FOR SMARTERSELLER: $818.55 (Ray's test)
FINAL FOR MATEVANS: $573.15
FINAL FOR PADDYROHR: $345.32
FINAL FOR BRIANKOTEK: $324.20
FINAL FOR COYNE: $246.67
FINAL FOR STEPHENWITHINGTON: $165.91
FINAL FOR CFSILENCE: $147.51
FINAL FOR MATTOSBUN: $129.33
FINAL FOR JOHNERIC: $112.15
FINAL FOR TUTTLE: $57.00
FINAL FOR GENTRYD: $37.75
FINAL FOR MATTJONES: $20.90
FINAL FOR BRADWOOD: $6.13
FINAL FOR CISKE: $0.40
FINAL FOR CURTGRATZ: $0.07
FINAL FOR JOELSTOBART: $0.06

And finally, I've included all the UDFs and the test code (again, a bit ugly, forgive me) as an attachment to this entry. Thank you everyone for participating! If folks would like to see more contests like these (small, one week type things) then let me know.

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Curt Gratz posted on 7/14/2008 at 6:35 PM

Wow,

Congrats Geoffrey. Nice Job. I must say for the record I am a putz. I sent Ray my copy that did the code in dollars and not cents. Stupid Stupid Stupid. I ran it unofficially here a bunch of times and did much better after changing line 598 in the funcs.cfm is Rays download of this from .1 to 10 like it should have been. So please all change <cfset var minprice = .1> to <cfset var minprice = 10> in your simulators. DUH!!! Oh well, such is life from time to time.

Comment 2 by Phillip Ciske posted on 7/14/2008 at 6:43 PM

Nice job Geoffrey! It was eye-opening to read through everyone else's code. I'm glad I'm a programmer and not an investment banker. :-)

Comment 3 by Mat Evans posted on 7/14/2008 at 7:25 PM

congrats everyone!

I had lots of fun doing that - might go into lemonade stand management :)

cheers Ray, and yes if you have time, more comps like this would be awesome.

Cheers!

Comment 4 by Geoffrey Bentz posted on 7/14/2008 at 7:33 PM

Thank you, thank you. I would like to express my appreciation to my Introduction to Microeconomics professor. Without her thorough explanation of supply and demand curves, I would not be here tonight. :)

This was a fun contest. It is quite a learning experience to see the different programming techniques people used in solving the challenge. I am looking forward to spending more time learning from the various entries...while having a nice glass of lemonade.

Comment 5 by Dan Sorensen posted on 7/14/2008 at 8:26 PM

I think it would be interesting to see how people would approach the genWeather or simSales functions differently. But it would be much harder to determine which one was 'the winner'.

For example, if I were to write genWeather, I may allow for some 'atmospheric inertia', meaning that if it's 95 today, it's probably not going to be 75 tomorrow. That would have also allowed for smarter selling functions based on trends without storing to a global scope. Additionally, I may use a web service to get actual historical weather for use in the simulator just for fun.

Very interesting project overall. It was good to read through the different solutions! Some interesting thought put into it. :-)

Comment 6 by Raymond Camden posted on 7/14/2008 at 8:33 PM

Good ideas Dan. To be clear, I definitely wrote up the sim code a bit too quickly. I probably forgot to var scope a few items too. ;)

Comment 7 by Dan Sorensen posted on 7/14/2008 at 8:47 PM

I like how Brian Kotek quickly solved the var scoping issue by starting his function with:

var local = {};

Then he added all other variables to this scoped local structure. It's easier to see if a variable is scoped when it has a local.var prefix than it is to check the top of the function to see if it had been declared with a var prefix.

I wish I would have had the time to join in on this contest last week. :-)

Comment 8 by Steve Withington posted on 7/14/2008 at 9:30 PM

Sooo ... when can we expect our check?

Just kidding. Thanks Ray, it was fun to participate and I vote for having more of these!

Comment 9 by Brad Wood posted on 7/14/2008 at 11:08 PM

Definitely fun—too bad I lost money though… :)

Comment 10 by Raymond Camden posted on 7/15/2008 at 4:32 AM

Some good comments by Coder's Revolution:

http://www.codersrevolution...

He points out something I forgot to mention in my blog post. One of the 'secret' rules I didn't tell you guys about was the "By 5" rule. If you sold your lemonade with a price that was divisible by 5, you got a bonus. My thinking was - folks don't like to look for pennies, and you could sell more if you weren't making a lot of change.

Comment 11 by Raymond Camden posted on 7/16/2008 at 3:36 PM

Please see a cool followup by Brian Kotek:

http://www.briankotek.com/b...