Programming puzzles: processing lists!
|
04-21-2017, 05:37 AM
(This post was last modified: 04-21-2017 05:43 AM by pier4r.)
Post: #13
|
|||
|
|||
RE: Programming puzzles: processing lists!
(04-20-2017 09:35 PM)pier4r Wrote: Challenge #1a userRPL, 50g. So after 2048 tests with a list of size 10 (output equal to 11 when valid). 1st: a lot of memory used, especially to save the results instead of deleting it accidentally. 2nd: the smaller the list, the faster the stack operations. 3rd: I got 2 elevens (list passed completely) and 7 tens (list failed at the last element) The theory should have been 4 elevens and 8 tens, so I would assume that my code is not failing. To be sure as soon as possible I will code a function that instead of producing randomly a list of two values, will produce with a certain proportion random lists and valid lists. 4th: the average execution time per list of 10 elements was 0.26 seconds, per list of 100 elements was 1.9 seconds. (04-21-2017 12:43 AM)DavidM Wrote: Many of the list processing shortcuts tend to misbehave if you provide them with lists containing no elements, 1 element, or invalid elements. For these challenges, I'm taking you at your word that the input won't include any of those situations. Yes, I wanted to avoid annoying corner cases. Just a straight processing. I will have to compare your code with mine, your is way more compact. If you want to contribute in the comparison you are welcomed. Oh, I just understood what your first challenge is doing (compare the nth element with the nth-1 element , I'm not sure about the last element ). That's a beauty! Asap I will compare speed (and results). Instead someone with a prime may compare the code between han and didier, they do not look the same. Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)