HHC 2021 Programming Contests - Surprise !
|
10-06-2021, 05:24 PM
Post: #23
|
|||
|
|||
RE: HHC 2021 Programming Contests - Surprise !
Just for fun, I did a 71B BASIC implementation of the RPN problem. This should work on a stock 71B with no additional LEX files or modules.
Rather than searching upward one by one, I took the approach of simply "mirroring" the input number to create a palindrome, checking to see if the result is greater than the input, and if it's not, incrementing the value of the left half by 1 and building a palindrome from that instead. Had to do a few tricks to correctly handle cases with input of all 9. It also works correctly for an input of 0, returning 1. Roughly half of the program is a string-reverse function, and there's room to shave a few more bytes off of this by combining some lines. It's very fast, though. It may look like there's a loop at first glance, but the backward jump should only occur either 0 or 1 times. There is a FOR loop in the string reversal function, of course. Code: 0010 INPUT X |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)