Programming puzzles: processing lists!
|
04-21-2017, 12:43 AM
Post: #12
|
|||
|
|||
RE: Programming puzzles: processing lists!
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.
I've played around with the first 12 of these so far, but am only including the first few here. My focus has been more on using the list commands than on performance considerations, and I suspect that most of what I've done could be sped up with a more brute-force approach. Here's what I came up with for the first few: Code: @@@ SPOILER ALERT As I mentioned above, I've intentionally coded these with the assumption that the input is exactly as described. In particular, I haven't done any kind of validation that the input contains the proper numbers. As such, the code is only functional for valid input, and will fail miserably with unexpected input. For that matter, it may fail with valid input, too. But it at least worked for the test cases I gave it. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)