I am an undergraduate student studying mechanical engineering. We are doing a project called the labyrinth cutter, we're constructing a piece of artwork consisting of a a gantry connected to a cutter head. The cutter is supposed to cut out a labyrinth to a piece of music. I decided to use the midi file of the music piece to create straight parts with certain lengths. At various beats the labyrinths changes direction. I used Java with J-music to do this and came out with 400 pieces that now have to be placed in a certain order to create a labyrinth. The lenghts of the pieces depend on the frequency of the note being played and the time between pieces. I wrote a program in c++ that uses recursive backtracking, simply trying to place piece after piece and see if it fits. Currently up to about 150 pieces is doable but after this the computation time gets way to heavy. I am wondering if anybody has an idea of a certain algorithm that could be used to solve this or point me in the right direction a bit as I'm not quite sure what I can do right now except for reducing the amount of pieces. Picture shows a solution with 150 pieces, obviously this won't fill the area. http://img89.imageshack.us/my.php?image=labyyc7.jpg Also if you have another idea of how to represent the labyrinths creation as being done to the piece of music please state your idea.