Just for fun! needles on Christmas Tree

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Just for fun! needles on Christmas Tree

Post by AndyP » Fri Dec 30, 2022 6:04 pm

A silly script to calculate the number of needles on your Christmas Tree

Code: Select all

on mouseUp
   -- calculate radius of cone in feet
   put 6 into treeHeight
   put 4 into treeBase
   put treeBase / 2 into radius

   -- calculate cone volume in cubic feet
   put radius * radius * pi * treeHeight / 3 into coneVolume

   -- calculate surface area of cone in square feet
   put radius * radius * pi + radius * pi * sqrt(radius^2 + treeHeight^2) into coneSurfaceArea

   -- calculate number of needles using surface area and needles per square foot
   put coneSurfaceArea * 1000 into needleCount
   answer "There are approximately " & round(needleCount) & " needles on your Christmas tree."
end mouseUp
Who's going to be the first to verify against their own tree? :D
Andy .... LC CLASSIC ROCKS!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: Just for fun! needles on Christmas Tree

Post by richmond62 » Fri Dec 30, 2022 6:21 pm

Our Christmas tree is plastic, and we've had it for 25 years.

Sorry if that needles you. 8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Just for fun! needles on Christmas Tree

Post by dunbarx » Fri Dec 30, 2022 8:18 pm

I just made a physical count, and you are off by 42.

Craig

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Just for fun! needles on Christmas Tree

Post by Klaus » Fri Dec 30, 2022 8:27 pm

dunbarx wrote:
Fri Dec 30, 2022 8:18 pm
I just made a physical count, and you are off by 42.

Craig
LOL! :D :D :D

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: Just for fun! needles on Christmas Tree

Post by SparkOut » Fri Dec 30, 2022 8:27 pm

I demand a recount!

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Just for fun! needles on Christmas Tree

Post by AndyP » Fri Dec 30, 2022 11:10 pm

dunbarx wrote:
Fri Dec 30, 2022 8:18 pm
I just made a physical count, and you are off by 42.

Craig
That's the answer to everything... Isn't it?
Andy .... LC CLASSIC ROCKS!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Just for fun! needles on Christmas Tree

Post by dunbarx » Sat Dec 31, 2022 1:11 am

Not everything, jut the product of six and nine.

Craig

Post Reply