On Thu, 8 Aug 2002, Stephen Turner wrote:

> I thought when I first read the problems that the factorial would be much
> shorter than the postorder

i thought that, too...

> (like 35 vs 70 or something), and that it would
> be the postorder that sorted people out. As it turned out, the factorial was
> only just shorter, and it was the factorial that sorted people out. (In
> fact, I was one of two players with postorder shorter than factorial. When
> I told Ton this he said "That's because your factorial is so long". Ouch!)

my problem was the 10**6 instead of 1e6. then my factorial and
postorder would have been the same length.
now it's so obvious...
i still don't really get that thing with ~4, but i'll sleep over it...

i like the postorder solutions, because there are quite efficient.
the normal approach would be (what i did first, too) to
write a recursive function, because trees somehow belong to
"recursive". function(root) = root . function(child) . function(child2).
but then i realized that the declaration of a sub
just takes away too many space, and i remembered that a) every
algorithm can be done non-recursive and b) perl regexes are
more powerful than one might think.
the regex solution might be a little bit slower than recursive
but it needs less memory.

anyway, glad that i made it to place 8, never expected that... =)
looking forward to the next golf,
tina

-- 
http://www.tinita.de/      \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/    \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \    \ _,_\ __/\ __/_| /__/ perception

Reply via email to