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: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
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 Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

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: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

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: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
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: 2852
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: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
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 Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

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

Return to “Getting Started with LiveCode - Complete Beginners”