A string like this one:
"a, 4.25, ((true, 5), 3, (false, false, false)), abc"
Describes a tree with 13 nodes, 9 of which are leaf nodes. In C# the leaf nodes in this example would be of types string
, float
and bool
, this differs between languages and depending on your implementation. The important structure forming symbols here are ,
(
and )
with spaces being ignored.
See the diagram in David Carrahers answer for a tree of the desired shape.
var a = new cake(4, "abc")
The above contains 8 symbols, I'm counting bracket and "
pairs as a half and things like .
as 1.
The goal is to write code with the fewest symbols which given a string like the one shown above, creates the tree it represents.
For example in the form of arrays inside each other, or interconnecting node objects.
60 extra points if you don't sort of cheat by adjusting the input string slightly then executing it.
I won't count the symbols that define the input string.
daniero
100 - (10 symbols)
+40 points for understanding numbers, strings, bools
and any other basic types the language understands.
+20 points for using a reasonably general language.
150 total points
fejesjoco
100 - (est 37 symbols)
+20 points for it understanding numbers as well as strings.
+40 points for using a reasonably general language.
97 total points
tomas
100 - (10 symbols)
90 total points
David Carraher
100 - (est 19 symbols)
81 total points