# Comparing Digits!!!

Printable View

• 03-14-2004
KneeGrow
Comparing Digits!!!
Ok, lets say i have the number 13112. How do i compare the digits of this number to see if one number (in this case the number "1") appears in over 50% of the number. In this case the number "1" appears 3/5 digits so it appears over 50%. Anyone know how to do this tastk thanks
• 03-14-2004
Magos
I'd transform it into a string and check the digit occurance 1 by 1.
Code:

```char TempChar; int Number = 13112 std::stringstream Stream(Number); int Occurance[10] = {0}; while(!Stream.eof()) {   Stream >> TempChar;   Occurance[TempChar - '0']++; }```
Note: Code has not been tested.
• 03-14-2004
WaltP
Quote:

Originally posted by Magos
I'd transform it into a string and check the digit occurance 1 by 1.
Or leave it as an int and check each digit:
Code:

```int TempChar; int Number = 13112 int Occurance[10] = {0}; while(Number > 0) {     TempChar = Number % 10;     Number /= 10;     Occurance[TempChar]++; }```
Note: Code has not been tested, but I've done it before. It should be fine.
• 03-14-2004
Prelude
>How do i compare the digits of this number to see if one number (in this case the number "1") appears in over 50% of the number.
Numeric profiling can result in riots if you aren't tactful. I suggest starting a fight between the 1's and the other digits. If there are any 1's at the end then they probably had superior numbers.

>In this case the number "1" appears 3/5 digits so it appears over 50%.
Be careful though. 7's can hide pretty well behind 2's. A cursory glance isn't always enough.
• 03-14-2004
skorman00
Quote:

Originally posted by Prelude
suggest starting a fight between the 1's and the other digits. If there are any 1's at the end then they probably had superior numbers.

That's abserd! This gives a huge disadvantage to the slow and sluggish 8's. And we all know that 6's and 9's tend to team up.
• 03-15-2004
WaltP
Quote:

Originally posted by Prelude
>How do i compare the digits of this number to see if one number (in this case the number "1") appears in over 50% of the number.
Numeric profiling can result in riots if you aren't tactful. I suggest starting a fight between the 1's and the other digits. If there are any 1's at the end then they probably had superior numbers.

I don't know about that. Every fight between the "others" and either Hercules, Xena, or Arnold resulted in the superior numbers being soundly trounced. You need to keep track of the realities of the world, Prelude.
• 03-15-2004
Prelude
>Every fight between the "others" and either Hercules, Xena, or Arnold resulted in the superior numbers being soundly trounced.
Well, I didn't mention digit placement because it adds quite a bit of complexity. You see, 10110 is considerably more powerful than 3002. By assuming that greater numbers means greater power you can save yourself the trouble of measuring total value of the hoards. Besides, 2 and 3 aren't heroic at all, unlike 5, who has some m4d l33t sk1llz. And of course 9 is god-like; the Hercules of the decimal system. But don't forget 1 and 0 when they join forces, whooo.

>You need to keep track of the realities of the world, Prelude.
That's something I don't hear much. :D
• 03-15-2004
WaltP
Quote:

Originally posted by Prelude
And of course 9 is god-like; the Hercules of the decimal system.
But don't forget it's omnipotence over the octal system, where he's unimaginably powerful! God-like isn't even close!
• 03-15-2004
Prelude
>But don't forget it's omnipotence over the octal system, where he's unimaginably powerful!
Unfortunately, 9 causes spacial anomalies with his very existence in the octal system, so any estimates of his power are mere speculation.
• 03-16-2004
major_small
Quote:

Originally posted by Prelude
And of course 9 is god-like; the Hercules of the decimal system. But don't forget 1 and 0 when they join forces, whooo.
bah, you're so wrong... when 1 and 0 join forces, they're weaker than 1 alone... the 1 tries to fight, but the 0 does absolutely nothing... and the 9 just comes along and only destroys the 1 because the 0 couldn't be any worse off...

-and-

Quote:

Originally posted by WaltP
You need to keep track of the realities of the world, Prelude.
• 03-16-2004
Magos
Bah, if I were a mod I would've closed this thread for off-topic spam :)
• 03-16-2004
heat511
lol!
i dunno, personally i think 6 is the strongest, with all that arm training and weight training. i mean he's been walking on his hands for ages...
• 03-16-2004
major_small
Quote:

Originally posted by Magos
Bah, if I were a mod I would've closed this thread for off-topic spam :)
you must not mod many forums... it's hard to stop threads when they get offtopic, because most threads would be closed within a few posts...
• 03-16-2004
grib
Re: lol!
Quote:

Originally posted by heat511
i dunno, personally i think 6 is the strongest, with all that arm training and weight training. i mean he's been walking on his hands for ages...
sure 6 usually teems up with 9 but now 6 is upset with seven because 7 8 9.
• 03-16-2004
WaltP
Re: Re: lol!
Quote:

Originally posted by grib
sure 6 usually teems up with 9 but now 6 is upset with seven because 7 8 9.
That cannibal!! This wouldn't happen in binary!! A much more civilized system.