Friday, September 26, 2014

Folding Problem

Got it. The problem I had before had to deal with an index error I would get on folds larger than 3. The problem seemed to be that when I was reversing the folds on the left side of the down fold, the list I was multiplying it by was not of the same length.

For my purposes, I used [-1] to represent a single down fold and [1] to represent a single up fold. When I had the list [1, -1, -1], which was the result from two folds, I originally tried to multiply it just by [-1]. Instead, I had to multiply it by [-1, -1, -1] to prevent the indexing error. So, I needed to figure out what size the list would be based on its number of folds. Then, I would multiply this number by [-1] in order to get a list of several -1's. This stopped the indexing error from occurring. Technically, my function now works for any number of folds. Practically, any more than 5 folds seems to take to long to compute. Maybe I'll figure out a way to optimize such functions one day so that I won't run into the same issue.

No comments:

Post a Comment