HHC 2015 RPN programming Contest is now open
|
10-04-2015, 08:50 PM
Post: #93
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
Here's another solution. It's 25 steps, 40 bytes and uses 2 registers.
The idea is to sort the numbers and then count the number of times that the difference between adjacent numbers is 1. If the difference is ever greater than 1, then reset the counter. In pseudo-code: Code: SORT Notice that because last_die is initialized to zero, the first time through teh loop diff is always greater than 1 so sum gets reset to 0. Here is the code with byte counts and comments. R06 is the index register R07 is the value of the last die Code: 01 LBL 'RR' 6 bytes |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 8 Guest(s)