Post Reply 
RPL Mini-Challenge: All Odd Digits?
07-09-2017, 10:49 AM (This post was last modified: 07-09-2017 04:04 PM by Gilles59.)
Post: #29
RE: RPL Mini-Challenge: All Odd Digits?
(07-03-2017 01:18 AM)DavidM Wrote:  (...)My submission:
Code:
 @ convert integer to string
  \->STR

  @ obtain number of digits
  DUP SIZE

  @ create a mask of 1s for the given length
  R\->I ALOG 1 - 9 / \->STR

  @ save a copy of the mask, then apply it to mark all odd digit positions
  DUP UNROT AND

  @ if the result is the same as the mask, all digits were odd
  ==
\>>

David, I like very much your approach. You can easily save 2.5 Bytes at the end with :
Code:
OVER 
instead of
DUP UNROT

EDIT : Bad idea... This dont work, sorry
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL Mini-Challenge: All Odd Digits? - Gilles59 - 07-09-2017 10:49 AM



User(s) browsing this thread: 2 Guest(s)