Talk:Palindromic gapful numbers: Difference between revisions
(added a new talk section.) |
(Nice Recursive Solution/Definition) |
||
Line 1: | Line 1: | ||
==Nice Recursive Solution/Definition== |
|||
If I let f<sub>1</sub> = 0..1..9 and f<sub>2</sub> = 0..11..99 then f<sub>3</sub> is xyx where x is 0..1..9 and y is 10*f<sub>1</sub>. In general f<sub>n</sub> is (x<sup>n-1</sup>+x)+n*f<sub>n-2</sub>. For all palindromic numbers x=0 is invalid for outermost pair. Not a problem for this task as you will wish to choose x to be the ending for each set. F# can implement this and execute the entire task in less than 35 thousandths of a sec so sufficiently optimal. |
|||
--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 15:07, 3 December 2020 (UTC) |
|||
==Please clarify== |
==Please clarify== |
||
I don't understand the second and third part of the requirements. |
I don't understand the second and third part of the requirements. |
Revision as of 15:07, 3 December 2020
Nice Recursive Solution/Definition
If I let f1 = 0..1..9 and f2 = 0..11..99 then f3 is xyx where x is 0..1..9 and y is 10*f1. In general fn is (xn-1+x)+n*fn-2. For all palindromic numbers x=0 is invalid for outermost pair. Not a problem for this task as you will wish to choose x to be the ending for each set. F# can implement this and execute the entire task in less than 35 thousandths of a sec so sufficiently optimal. --Nigel Galloway (talk) 15:07, 3 December 2020 (UTC)
Please clarify
I don't understand the second and third part of the requirements. What does this mean?
- Show (nine sets, like above) of palindromic gapful numbers:
- the last 15 palindromic gapful numbers (out of 100)
- the last 10 palindromic gapful numbers (out of 1,000) {optional}
Thanks. --Paddy3118 (talk) 19:54, 12 November 2019 (UTC)
- Is it:
- The last fifteen of the first 100 binned-by-last digit gapful numbers >= 100
- --Paddy3118 (talk) 19:59, 12 November 2019 (UTC)
Starting at 100 (which is the minimum that gapful numbers start at, as per the note on the task page that all positive integers below 100 are trivially gapful numbers), then ...
- generate 100 palindromic gapful numbers, and then take (pick) the last 15 of those 100 numbers.
- generate 1000 palindromic gapful numbers, and then take (pick) the last 10 of those 1000 numbers.
There is probably a better and cleaner (or more concise) way of expressing the above (two) sentences, but the (bottom/lower) limit of 100 kinda throws a monkey wrench into the works, er ... wording of the expression.
Another way of expressing the above would be:
- generate the 86th ──► 100th palindromic gapful numbers, ignoring those below 100.
- generate the 991st ──► 1000th palindromic gapful numbers, ignoring those below 100.
I had assumed that programmers would take/pick those (above) palindromic gapful numbers in increasing order, and it seemed unnecessary to state that.
I must admit, I never heard of that phrase binned by last, but once reading it, I knew what it meant.
I hope the parenthetic phrase (nine sets) was clear enough; If it wasn't for the output, I don't know how I would've expressed it. I assumed the output from the REXX example would make that clear enough. I had toyed with expanding that parenthesized expression, but it just got too overly wordy and inelegant, and even somewhat ugly. -- Gerard Schildberger (talk) 00:12, 13 November 2019 (UTC)
- Hi Gerard, as you saw above, I did eventually work it out.
- Having looked again at my wording I think it might be better with an extra hyphen tieing in the word "digit"?
- The last fifteen of the first 100 binned-by-last-digit gapful numbers >= 100
- --Paddy3118 (talk) 20:16, 13 November 2019 (UTC)
- P.S. I enjoyed the task.
optimizations
(Referencing Paddy3118's comment above.)
I thought it was a pretty simple task, nothing much complicated, but enough computation so that it required just a hint of heavy lifting (at least, for the solution I entered). I thought I hit on a clever method to limit the calculation (to ten) entries per ending decimal digit without computing extra entries or excessive limit checking.
It was interesting to note some of the optimizations for this task, ... which to do first ... create palindromes and then filter the gapful numbers, or vice-versa. -- Gerard Schildberger (talk) 20:52, 13 November 2019 (UTC)