Challenge: Decorate The Tree

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 15863 Views - Last Post: 01 December 2012 - 12:39 PM

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Challenge: Decorate The Tree

Post icon  Posted 28 November 2012 - 02:46 AM

Challenge: Decorate The Tree

Since it is nearing that time of Year again and the festivities are starting.

We should put a tree!

Challenge idea submission from lucky3.I've modified it a little to make it a fun for all levels of coder.

Challenge

Produce a Christmas tree.

Easy
Create the basic tree (without decorations except for the star on top)
        *
       ^^^
      ^^^^^
     ^^^^^^^
    ^^^^^^^^^
      ^^^^^
     ^^^^^^^
    ^^^^^^^^^
   ^^^^^^^^^^^
  ^^^^^^^^^^^^^
    ^^^^^^^^^
   ^^^^^^^^^^^
  ^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^







Intermediate
Same a the Easy challenge but requires a tree with different decorations on it (random color and style).
  • A White Star on top must be White though.
  • Dark Green Tree


        *
       *^@
      O^O^*
     O^%^^^^
    %^^^^^^^^
      ^^^^^
     %^^^^^^
    o^o^^^o^^
   %^%^@^O^O^^
  ^^^^%^^^^^*^^
    ^^^^^^^^^
   ^^^^^^O^^^^
  ^^o^^^^^^^^^^
 ^^*^^^^^@^O^*^o
*^%^%^^^^^o^@^O^O




Attached Image




Advanced

Same a the Intermediate Challenge but with the added requirements
  • place a random (at least one though) number of strands of Tinsel to the tree.

Example # is the tinsel
        *
       #^@
      O^##*
     O^%^^#^
    %^^^^^^#^
      #^^^^
     %^###^^
    o^o^^^#o^
   %^%^@^*#O^^
  ^^^^%^^$^#*^^
    ^^^^^^^^#
   ##^^^^O^^^^
  ^^o#^^^^^^^^^
 ^^*^^##^@^O^*^o
*^%^%^^^#^o^@^O^O


A strand of Tinsel as the met the requirements.
  • Tinsel is below decorations.
  • Of a single color throughout it length.
  • The next section must be one of the follow neighbors of current section.
    [ ][#][ ]
    [ ][ ][ ]
    
    

  • Can't fall outside the boundary of the tree, if it does it wraps around drops a level.





Ninja
Spoiler






To all undertakers of this Challenge.
Have a fun time coding the challenge and have safe Merry Christmas and Happy New Years.
- VB.net forum leaders and team

This post has been edited by AdamSpeight2008: 28 November 2012 - 02:58 AM


Is This A Good Question/Topic? 4
  • +

Replies To: Challenge: Decorate The Tree

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Decorate The Tree

Posted 28 November 2012 - 05:18 AM

It's worth mentioning that submissions are expected to be in a Console project (so no forms and richtextboxes).

Edit:
I got some time to start with it, and need to debug it a bit, then to the flashing lights and refactoring spaghetti code... tomorrow perhaps. In the mean time:
Attached Image
(yeah, I know... the tinsel :whistling:)

Edit2:
Fixed the tinsel bug. I'll take a look at flashing lights problem in the evening. For now:
Attached Image

Edit 3:
Is this valid blinking? http://dl.dropbox.co...tmas%20Tree.exe

This post has been edited by lucky3: 29 November 2012 - 03:48 AM

Was This Post Helpful? 2
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 05:20 AM

First Ninja Level entry.
- Nice effect, just (to me the refresh flickers a little to much).

Could you do one with fewer flashing lights? I don't think every decoration should flash, just the lights.
Was This Post Helpful? 0
  • +
  • -

#4 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 07:26 AM

Sheeesh... I posted reply, and it's not here (it's happening again). What are the lights? The strand, or O's, *'s...? Any decoration of my choice?

Edit:
Fixed blinking flicker, and choose my lights as "@" and "c" characters.
BTW, I added some sugar to it: http://dl.dropbox.co...tmas%20Tree.exe

This post has been edited by lucky3: 29 November 2012 - 10:05 AM

Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 04:34 PM

lucky3 A lot of is artist licence in terms of what the actual characters are used.


Just got the tinsel requirement to do and I'll have a ninja entry. (currently ~200 IDE LoC )

This post has been edited by AdamSpeight2008: 29 November 2012 - 05:02 PM

Was This Post Helpful? 0
  • +
  • -

#6 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1105
  • View blog
  • Posts: 6,918
  • Joined: 07-September 06

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 08:21 PM

For anyone wanting to use Javascript on this, I have put together a quicky "terminal" which emulates some (all?) of the functionality of the Console from VB.net. I believe it has all the functionality you will need for this challenge.

I will submit an actual entry here in a bit, but for the moment here is the Terminal code:
Spoiler

Was This Post Helpful? 1
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 09:21 PM

I've managed to get some strips of tinsel on my tree. needs some tweaking to get to do the wrapping correctly.

Here is a GIF to see what it looks like so far.
Attached Image
Was This Post Helpful? 2
  • +
  • -

#8 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1105
  • View blog
  • Posts: 6,918
  • Joined: 07-September 06

Re: Challenge: Decorate The Tree

Posted 29 November 2012 - 09:40 PM

And here is my code so far. The random function kinda sucks in JS, so it may take a few refreshes before you get any ornaments (since they have a fairly low spawn rate). The lights are animated and all that jazz (animated as in a 1 second interval for redrawing the tree; at which point the lights are given a new random color from the array, the rest of the tree remains the same). Just need to work on some tinsel.

Spoiler

Was This Post Helpful? 1
  • +
  • -

#9 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 01:01 AM

Looking great from both of you!

Edit:
can't decide on lights (bigger, mixed, minimalistic) ;)
Attached ImageAttached ImageAttached Image

This post has been edited by lucky3: 30 November 2012 - 01:52 AM

Was This Post Helpful? 1
  • +
  • -

#10 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 01:13 AM

BetaWar only the lights flash, rest of decorations and tree should not be affected.

~ 260 IdeLoC Ninja Entry. (Note: Requires .net 4.5)
Uses about 12Mb of and 2-3% CPU utilization.
Attached File  XmasTree_01.zip (16.97K)
Number of downloads: 80

Press "SpaceBar" to generate another set.

This post has been edited by AdamSpeight2008: 30 November 2012 - 01:23 AM

Was This Post Helpful? 1
  • +
  • -

#11 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 02:06 AM

Excellent AdamSpeight2008! In theory your strand of tinsel could cover the whole tree, right? I have it going only to right, down, down-right. I'll do the same for the left option, and let it decide randomly which way to place it. I like your app's icon ;)

Edit: actually, in theory, if mine solution "decides" to always go just right, and never down or down-right, it would cover the tree also... :surrender:

This post has been edited by lucky3: 30 November 2012 - 02:35 AM

Was This Post Helpful? 0
  • +
  • -

#12 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1105
  • View blog
  • Posts: 6,918
  • Joined: 07-September 06

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 09:07 AM

View PostAdamSpeight2008, on 30 November 2012 - 08:13 AM, said:

BetaWar only the lights flash, rest of decorations and tree should not be affected.


Which browser are you seeing the ornaments change colors in? I have run my code in IE9, Opera, and Chromium and it all only has the lights (') changing colors, the ornaments are randomly colored when first drawn but remember that color from then on.
Was This Post Helpful? 0
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 09:18 AM

It was the way I read what you wrote, suggest to me that on refresh was drawn a new random tree. I was just re-clarifying the requirements.

This post has been edited by AdamSpeight2008: 30 November 2012 - 09:18 AM

Was This Post Helpful? 0
  • +
  • -

#14 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 09:27 AM

lucky3 I theory the tinsel could cover the tree, but in practice I find it does reasonably well. (I didn't say it had to start at the top, or on any edge. Did I? :sly: )
Was This Post Helpful? 0
  • +
  • -

#15 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1105
  • View blog
  • Posts: 6,918
  • Joined: 07-September 06

Re: Challenge: Decorate The Tree

Posted 30 November 2012 - 09:56 AM

@AdamSpeight2008 - Ah, alright. I was just confused with the statement above as well. Probably a lack of sleep helping with that :) I am working towards getting it to run more efficiently (instead of having the large, multi-dimensional loop through each time I am planning on setting up a jagged 2-d array of objects to store information and just run through that to redraw the tree). That will also make the tinsel easier to accomplish :D
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2