14
3
Because of this, families from all over the world are building Christmas trees.
But this normal tree can get boring after a while, so let's make an ASCII tree!
Leafs are represented by #
and must be arranged as shown in the example output. We have 5 balls (O
) and 5 candy canes (J
), which we place randomly around the tree. We also have a candle on top.
Input: none
Output:
^
|
###
##O##
#######
#####
####J##
#########
####O######
#############
###J###
#########
####O###J##
#######O#####
###J########O##
###########J#####
###
###
Rules (if it's not in the rules, assume you can)
Balls and candy canes must be randomly placed on the tree and must have at least one leaf between them, not counting diagonals.
Each leaf must have a non-zero chance of getting a ball or a candy cane.
There may be leading or trailing spaces on each line, as long as the tree has the proper shape.
This is code-golf, so shortest code in characters wins.
related – Billywob – 2016-12-16T10:04:18.767
2@Billywob it's a close one, this one has a randomised factor and a candle tho :P – Grey – 2016-12-16T10:06:08.320
1Yeah, this is most certainly more difficult imo. – Billywob – 2016-12-16T10:06:52.853
related: http://codegolf.stackexchange.com/q/15860/7209
– John Dvorak – 2016-12-16T10:37:21.4333
“But this normal tree can get boring after a while.” Then why the old school candle and not something creative?
– manatwork – 2016-12-16T10:56:55.827@manatwork ohwow, that's a nice deco, I was actually reffering to a physical tree – Grey – 2016-12-16T10:58:39.873
Related. – user2428118 – 2016-12-16T11:15:29.123
1
Since no one else has mentioned, I'll recommend that you post future challenges to the Sandbox where you can get meaningful feedback and tweak challenges before you post them to Main.
– AdmBorkBork – 2016-12-16T14:35:51.1931
If you don't answers that look like this, I suggest scoring by bytes rather than characters.
– Dennis – 2016-12-16T17:13:37.507Is it legal to usually place all of the balls? For example, if you flip a coin for every leaf to see if it gets an ornament, then every leaf has a non-zero chance of getting an ornament, but there's also a remote (but non-zero) chance that you don't place all of the ornaments. Supposing there was a 99% chance that you place them correctly, is that a fair answer? – rexroni – 2016-12-18T16:55:56.183
Should the trunk be considered leafs as well or not? – Titus – 2018-12-22T12:07:50.187