Re: Calculate Last Digits

Tech-Archive recommends: Fix windows errors by optimizing your registry



Okay, I think I get it now...you're counting each of the last digits, and checking for similarity/difference between them, so in my
original example (1 12 23 34 45 46), the last digits would be:

1 2 3 4 5 6

....which in your system is all different, so 111111. And just to be sure I'm understanding:

1 11 12 22 33 44

....would correspond to 221100 (2 one's, 2 two's, 1 three, 1 four, and the 0's for padding). Is that correct?

In terms of counting each digit, the best way I can think of is to set up an array from 0 to 9 and count each of the 6 digits, then
use a sort on the array (removing the 0's first so you're only sorting on what's left). A shell sort might work well here...I'm a
little rusty on my sorting algorithms, but it seems like that SHOULD be quick for something like this.

Another possibility that might end up working well is instead of an array, use a 10-digit string to count instead, then remove the
0's when you're done and sort the remainder. I think that would end up being slower in the long run, but might be worth a look.

Finally, you may want to consider optimizing the routine to only count each digit AS it changes. Not sure if there's a good way to
do that, but you might be able to save a considerable amount of time if you're not re-counting every last digit every time.



Rob


.



Relevant Pages

  • Re: algorithms + data structures = programs
    ... Richard Heathfield wrote: ... Yes, okay, I agree. ... And dis the digit that will be displayed at ... Wirth ex machina again - he presumes the last digit of the representation ...
    (comp.programming)
  • Re: Well Ordering the Reals
    ... > Okay, I don;t think I understood what you were saying. ... > naturals, you might as well call it something, I suppose. ... In TO's system of "whole numbers", there is a most significant digit and ... > infinite unending string of bits, even if most are generally ignored. ...
    (sci.math)
  • Re: nth root
    ... Mark Dickinson wrote: ... integer part of the result is *exactly* right, or is it okay if ... I just tested it with several hundred thousand random 100 digit numbers and it never made a mistake. ... suppose you were doing cube roots instead then you would need the first 35 digits of the 100 digit number and this is more accurate than a double. ...
    (comp.lang.python)
  • Re: An uncountable countable set
    ... conditional does not disturb the proof. ... But there are no conditions on any digit which depend on any other digit ... one can have a general rule that does eachdigit without reference to any ... counting which is a sequential act too. ...
    (sci.math)
  • Re: Human calculation record - but why does he bother?
    ... Philip wrote: ... digit numbers ranging from a little over 2e15 to something under 2.5e15. ... Counting is part of arithmetic. ... The problem that the human calculator was working on, as I made it clear that I understood it, was to calculate integral thirteenth roots of a 200 digit number. ...
    (uk.philosophy.humanism)