[SOLVED] DSRN (dog slow roman numerals)
|
06-15-2014, 12:02 PM
(This post was last modified: 06-15-2014 02:24 PM by HP67.)
Post: #33
|
|||
|
|||
RE: DSRN (dog slow roman numerals)
(06-11-2014 08:23 PM)Dave Britten Wrote: I'm guessing it could be even faster if you get rid of the A subroutine and unroll it wherever it's used, but then the program will get even more bloated. As mentioned earlier, I didn't add the code at the end of the while until the 2nd pass, where I factored it out of each case condition. Putting the code back in both versions (not using a local subroutine) and using your modification of changing the case into a bunch of whiles runs 33% faster. Net, removing the local subroutine saves about 9 seconds on a test of 1,000 tries. So most of the time savings was in your case --> while (which I really like) and not so much in whether we use a local subroutine, put the code at the end of the while, to be executed for each pass, or whether we unroll the code and put it next to each case/while clause. As far as what was brought up about \gslist not exactly behaving nicely for edge cases, yeah. I have some code that goes the other way (from roman numerals to real values) using lists, and I bumped into this a couple of weeks ago. I don't know how much this happens with other commands, but I really prefer the way LISP handles this rather than having to deal with 3 classes of input lists (size > 1, size = 1, size = 0). It's easy to wrapper this, but annoying. As much as command and operator overloading look nice on the surface, I think this is another example of where the downside is apparent and TIINSTAFL. It ain't OVER 'till it's 2 PICK |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)