Post Reply 
RPL Mini-Challenge: All Odd Digits?
07-03-2017, 07:52 AM (This post was last modified: 07-03-2017 08:26 AM by Gilles59.)
Post: #15
RE: RPL Mini-Challenge: All Odd Digits?
(07-03-2017 01:18 AM)DavidM Wrote:  I decided to try a different tactic for this challenge, though it's still not quite as fast as Joe's. This one has a size of 45 bytes, and clocks in on my 50g at 0.1222 seconds. That gives me a score of about 5.5 on the 1000-digit numbers:

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
  ==
\>>

Very interesting David!

I dont have my 50G here, but I think there is a way to improve speed of the part :
Code:
 R\->I ALOG 1 - 9 / \->STR


I think at something like :
Code:

 1. - R\->I ALOG  \->STR "0" "1" SPREPL DROP
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-03-2017 07:52 AM



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