Slashdot Mirror


Programming Challenge: Triangles Puzzle

Frank Buss writes "Last week was a challenge to write a program, which solves a simple geometric problem. There was nothing to win, only the solutions at the end are the win for all readers, but nevertheless the response was great (some thousands of web-hits) and there are some nice solutions."

5 of 40 comments (clear)

  1. Re:lots of Lisp people out there. by evilmousse · · Score: 4, Informative


    No, I'm pretty sure mathematica would work fine.
    It does indeed have it's own language, and plenty of permutation/combination logistics.
    I'm guessing it'd be more useful to someone seeking a mathematical proof/theorem regarding the problem, listing complex genral-case equations at each step.
    The more common programming languages are likely more productive, being concerned more with just the result than the theory at each step. tho I do know many math majors that would have an easier time programming it in mathematica, just because that's what they're used to.
    Lisp is the logical language choice for this or any other heavily-combinational/AI task, though you'll never catch me programming in it.

  2. More simple solution by eric2hill · · Score: 2, Informative

    Using any handheld calculator with an "x^y" key...

    Take the number of divisions coming from a base vertex of the triangle and raise it to the power of the number of divisions coming from the opposite vertex. In the case given, 3 divisons to the power of 3 divisons = 27.

    --
    LOAD "SIG",8,1
    LOADING...
    READY.
    RUN
    1. Re:More simple solution by blankman · · Score: 2, Informative

      What if I add a line between P8 and P9? Your solution no longer works.

      Notice that all the additional lines in the problem intersect either P0 or P1. Adding a line between P8 and P9 significantly changes the problem.

      You are correct though, in saying that x^y is not the solution. A few of the solutions did work out general formulae, the simplest I saw being (1/2)*(m*n)*(m+n)

  3. Re:Need more challenges by Anonymous Coward · · Score: 2, Informative
  4. Re:Need more challenges by meme_police · · Score: 2, Informative

    Pedant mode: it's piqued, meaning aroused, not peaked.

    --

    The meme police, They live inside of my head