HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits
08-31-2017, 09:32 PM (This post was last modified: 08-31-2017 09:37 PM by pier4r.)
Post: #29
 pier4r Senior Member Posts: 2,248 Joined: Nov 2014
RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits
So finally I was able to implement an idea similar to what I wanted to do.

I am happy because (a) I implemented my idea and (b) I heavily used community libraries that are awesome. The drawback is that the idea is very inefficient. It is also true that I wouldn't be able to get to the same level of some solutions already posted. Those are relatively refined compared to my skills.

In particular with DOPERM I did not identify a way to create "ordered permutations" through which I could halt the execution earlier.

Well does not matter, the first objective is to get the answer correct, if possible with a nice way. Then optimizations may be applied.

Ah, 50th number asked (179), 190 seconds.
Also I am not sure it can process some large number, like 8000.

Code:
 OEISA014261   @see www.hpmuseum.org/forum/thread-8928.html   @in practice we should generate all the positive integers not containing   @even digits.   @Those small challenegs are nice because are not overwhelming and still can be   @approached in many ways.      @listExt of DavidM   @LSORT from hpcalc   \<<     @Input: N     @Output: Nth number in the sequence.        @Plan     @ combining digits 1 3 5 7 9 in increasing way.          @so making heavy use of the awesome list library of david.     @I can just generate tuples and sort them.          { 1 3 5 7 9 } "baseList" DROP     { } "currentIterBaseList" DROP     {} "currentIterationList" DROP     1 "digitsInIteration" DROP     0 "mthGeneratedNumber" DROP     0 "skippedNumbers" DROP          \->     @input     valueN          @local var     baseList     currentIterBaseList     currentIterationList     digitsInIteration     mthGeneratedNumber     skippedNumbers     \<<       IF         valueN 1 > NOT       THEN         0       ELSE         WHILE           valueN 5 digitsInIteration ^           >         REPEAT           'skippedNumbers' 5 digitsInIteration ^ STO+           'digitsInIteration' 1 STO+         END         @generate a source list with enough digits          @(small limits of the current version of the list library of davidM)         @in general to generate 111 we need 3 "1" in the list, so         baseList digitsInIteration LMRPT 'currentIterBaseList' STO           @can we use sorted? so we have the numbers generated in order?           @nu. Generating a list from sorted input list and then removing duplicates           @does not help. This may be a request for another command similar to DOPERM                  @generate all the permutations of the elements, turn them in numbers         @clear the equal ones         currentIterBaseList digitsInIteration          \<< NL\->I \>>          DOPERM         LDDUP         :2:LSORT EVAL                  @then we pick the right element         valueN skippedNumbers -         GET       END     \>>   \>>

Wikis are great, Contribute :)
 « Next Oldest | Next Newest »

 Messages In This Thread HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-28-2017, 02:21 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-28-2017, 04:21 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Claudio L. - 08-28-2017, 10:07 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-29-2017, 05:44 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-29-2017, 07:36 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Tugdual - 08-29-2017, 08:06 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-29-2017, 10:48 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-29-2017, 09:23 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - John Keith - 08-29-2017, 01:07 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-29-2017, 07:08 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Didier Lachieze - 08-29-2017, 04:02 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-29-2017, 04:29 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gilles59 - 08-29-2017, 09:14 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Joe Horn - 08-30-2017, 01:19 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Brad Barton - 08-31-2017, 12:49 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Didier Lachieze - 09-01-2017, 07:48 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 09-01-2017, 08:11 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Brad Barton - 09-01-2017, 02:55 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Didier Lachieze - 09-02-2017, 06:51 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-29-2017, 05:55 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Claudio L. - 08-29-2017, 08:28 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Claudio L. - 08-29-2017, 09:56 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-30-2017, 09:06 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Didier Lachieze - 08-30-2017, 10:53 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-30-2017, 10:59 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Werner - 08-30-2017, 12:20 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-30-2017, 01:02 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Claudio L. - 08-30-2017, 02:08 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-31-2017, 10:57 AM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Claudio L. - 08-30-2017, 01:39 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Werner - 08-30-2017, 02:06 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - Gerald H - 08-30-2017, 03:30 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - pier4r - 08-31-2017 09:32 PM RE: HP 49G Programming Challenge: OEIS A014261, Integers with exclusively Odd Digits - David Hayden - 09-01-2017, 09:12 PM

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