RPL Mini-Challenge: All Odd Digits?
|
07-02-2017, 04:25 AM
Post: #1
|
|||
|
|||
RPL Mini-Challenge: All Odd Digits?
Here's a mini-challenge for HP 49 & HP 50 programmers.
Purpose of program: Test whether a number contains only odd digits. Input: Any positive exact integer (that is, exact-mode integer-type objects only, no reals or negatives allowed). Invalid inputs need not be tested for. Output: 1 (meaning "true") if the input contains only odd digits. 0 (meaning "false") if the input contains any even digits. Examples: 1357335 --> 1 (True; all digits are odd) 1357325 --> 0 (False; there's an even digit in there) 1234567 --> 0 (False; not all digits are odd) 0 --> 0 (False; 0 is even) The winner is determined by speed * bytes (execution in seconds, times size of program without name) on 1000-digit inputs. My current best score is roughly 4.8. <0|ΙΈ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)