
Comments and Discussions



<<>><<>>
Hi
Its an interesting trick that deserves score 5 .
I want to compile own exe with VS9
but it would throw error from the file
'Digistatic.cpp' The error is related to integer 'iChar'
as undeclared identifier and similarly the
'.Draw' and '.GetNormWidth' in the same file.
Can someone please resolve issue with code if applicable.
Thanx.
<<>><<>>





alrsds wrote: I want to compile own exe with VS9
but it would throw error from the file
'Digistatic.cpp' The error is related to integer 'iChar'
as undeclared identifier
Line 1035 of Digistatic.cpp?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way."  Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it."  Michael Simmons





Thanks for response & sorry that I skipped detail i.e as follows:
_____________
file name > Digistatic.cpp
iChar > undeclared identifier> lines 1035,1039,1042,1044
left of '.GetNormWidth' must have class/struct/union > lines 1039,1044
left of '.Draw' must have class/struct/union > line 1042
_____________
I hope above hints help resolve this... Thanx again
modified on Tuesday, September 8, 2009 8:28 PM





alrsds wrote: iChar > undeclared identifier> lines 1035,1039,1042,1044
So have you declared it? VS6 was lenient in regards to variables going out of scope when the for() loop ends.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way."  Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it."  Michael Simmons





Thanks!
Thats right, tho I tried again but finally installed old version
that made old dog old trick work. 5 credit is yours with the hope that you update it or rewrite in C#.
Thanks & Regards





it didn't work. My number was 1111





donperry wrote: My number was 1111
Which goes against the "lots of different digits" constraint.
"Approved Workmen Are Not Ashamed"  2 Timothy 2:15
"Judge not by the eye but by the heart."  Native American Proverb





I took the liberty of modifying your codes so that users can use longer numbers up to 20 digits long. I simply changed the text limit for the edit box from 3 to 20.
Then I DELETED this code:
if (pSheet>m_strNumber.GetLength() == 3)
{
int a = pSheet>m_strNumber[0]  '0',
b = pSheet>m_strNumber[1]  '0',
c = pSheet>m_strNumber[2]  '0',
d;
d = 9  ((a + b + c) % 9);
ASSERT(1 <= d && d <= 9);
strText.Format("%d", d);
}
else {
int a = pSheet>m_strNumber[0]  '0',
b = pSheet>m_strNumber[1]  '0',
c;
c = 9  ((a + b) % 9);
ASSERT(1 <= c && c <= 9);
strText.Format("%d", c);
}
and ADDED this code:
int i = pSheet>m_szNumbers.GetLength();
int subt=0;
int d;
for(int x = 0; x < i; x++)
{
subt += pSheet>m_szNumbers[x]  '0';
}
d = 9  (subt % 9);
strText.Format("%d", d);
Also, on step 4, I added a CString member variable to the edit box, then in the OnChangeNumbers() I added the following code:
UpdateData();
int len = m_szNum.GetLength();
for(int i = 0; i < len; i++)
{
CString ch = m_szNum.GetAt(i);
if(ch < "1"  ch > "9")
{
m_szNum.Replace(ch, "");
UpdateData(FALSE);
}
}
This prevents the user from entering anything excepts digits 19 into the edit box (before they could actually enter "abc" and get a result).
To disguise the "zero" problem, I added a step in the middle. After the subtraction step, I have them multiply their answer by any number it contains (eg. 4572 x 4, 5, 7, or 2). Because a multiple of 9 multiplied by ANYTHING will still be a multiple of 9. Then I have them cross out all the zeroes and rearrange the number again. Now when they click to the circle step, there are no zeroes to worry about.
That's it... now they can use up to 20digit numbers (hope they have a calculator handy)... and it will always be 100% right, so long as they perform each step correctly.
I also took the liberty of adding a graphical "splash" page look to page one. Thanks for sharing the code.. I enjoyed it.
In business, if two people always agree, one of them is unnecessary.





This is just a "bitshift" in base 10. So if you move 01 to 10 in base 10 you just did a 101 (difference of 9). A "bitshift" on any scale always increments or decrements the value in a multiple of BASE1 (in this case 9). So if you change 030 to 120 you just performed +100 10 (difference of 90). Think of the '3' not as an individual number, but rather 3 separate placeholders, which you can slide around on the place scale as you wish. Example: 030, 102, 111, 300  any combination of numbers with a total of 3 placeholders will always have a difference in value which is an increment of 9. So it doesn't matter whether we calculate 2112 or 123 or 300111, either way will result in a multiple of 9. So we're just forcing the player to give us a number which is a multiple of nine.
Of course, the bottom line "magic" of this trick is that any number which is a multiple of 9, it's individual digits will also add up to a multiple of 9 (27, 99, 180, 819, etc..) At this point, all digits become 1's place holders, so order is irrelevant. You add up the sum, divide by 9, if the remainder is zero they are either holding a ZERO or NINE (which is why you eliminate the zero), otherwise they are holding whatever your remainder is short of making an even 9 (eg. 9remainder).
Anyway, thanks for sharing the code. Nice little brainteaser.
In business, if two people always agree, one of them is unnecessary.





Thanks for contribution.
Best regards.
Always look on the bright side of life.





I am the Great Graduate Student who can read your mind.
1. Pick a number between 1 and 9. Any number! Let's say you
choose 5.
2. Multiply that number by 9. So 5 x 9 = 45.
3. Add the two numbers from the result together. So 45 has two numbers,
namely 4 and 5, and added together we get 9, for this example.
4. Subtract 5 from the previous result. So 9  5 = 4.
5. Now think of a Country in Europe that starts with the letter D.
Don't tell me; just think of a Country.
6. Now think of an animal that starts with the last letter of the
Country you thought of.
7. Now think of a color that starts with the last letter of the animal
that you thought of.
Now, I want you to email me what you thought of but before you answer
......
......
......
.....
....
...
..
.
I want you to know that there are no Orange Kangaroo's in Denmark!
Get it?
Sincerely,
Danielle (an overworked graduate student)





Nor are there any Alabaster Koalas in Denmark.





int a = 3;
int b = 7;
a^=b^=a^=b; // The great swap
printf("a=%d b=%d", a, b);





This is a highly debatable and controversial topic.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?





This is plain old logic, because if I type in two numbers, you will know that the difference was a three digit number. While if I were to type in three numbers, you will know that the difference was a four digit number.
It doesn't matter if the numbers I typed in were in jumbled order or not; that I typed in numbers is what matters, because from there you can 'interpolate' (by way of assigning 'x' to the unknown number), what number it was that I missed (meaning, the one I didn't type in). Then by sheer running the set of numbers (using one of several common math tricks, narrow the assortment of possible orders it might be in), which in due time (through the process of elimination) be able to infer which number I omitted. This you will know because only ONE number will eventually yield the correct combination of digits. You will verify that combination by doing the subtraction (using the numbers I typed in) against the likely possibilities of the eventual original number through placement insertion.
IOW, the entire process basically uses reverse engineering.
As a math student, when I was in school, I use to come up with all sort of numbers game like this to show my fellow students that numbers CANNOT be faked, and that Numbers Theory is real. (One of my favorite was telling them that I could prove that 1 + 1 = 3. Then I'd proceed, using algebra and "the difference of two squares", walked them through the entire process. It was fun to see the disbelief on their faces when I reached the end and wrote down the last line of the proof. I don't know if they ever caught on to the trick I used.)
I, nonetheless, enjoyed the revelry your sample provided, and gave it a '5'.
William
Fortes in fide et opere!






Nope! I did not divide by zero. That would have been too easy, and too readily seen by any keen person with a sharp eye. Dividing by zero is a big "NO NO".
The only branch of mathematic where dividing by zero is legal, is in the use of the Abelian Principle, specifically, Abelian 3.1.
William
Fortes in fide et opere!





WREY wrote:
It doesn't matter if the numbers I typed in were in jumbled order or not;
You're right. It's simply used to add to the illusion.
WREY wrote:
IOW, the entire process basically uses reverse engineering.
Actually what you've described sounds an awful lot like a bruteforce attack algorithm!
WREY wrote:
I could prove that 1 + 1 = 3.
This is the old dividebyzero trick.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?





NO! NO! NO! The illusion used to show that 1 + 1 = 3 DOES NOT USE "The divide by zero" trick you mentioned. ABSOLUTELY NOT!!!
With regards to your sample, (like the '1 + 1 = 3' suggestion you made that it must be using the 'divide by zero' trick), you are WRONG. I am NOT using a brute force approach. It has some AI in it (sort of) that determines the most promising route to take in finding an answer.
Specifically, I am suggesting taking a "Graphtraversal tree" approach (in which you set up a tree graph structure) then do a "depthfirst" search on the graph, followed by a "breathfirst" search on a particular node that seems to hold promises of a good lead. (Sort of similar to deciphering the numbers of a combination lock, where whenever you obtain one of the correct numbers, you resume the search from one qualifying node to the next qualifying node that I referred to as the "breathfirst" search.)
Think of the problem as a friend challenging you to find the house where he/she lives, by giving you only the number of the house (less one digit), and although you were NOT given the street name, presume other particulars as the name of the city, etc., were also given, plus one more important clue: the correct number does not have a 'zero' in it.
If the friend gave you two numbers, you will immediately know that their house number is comprised of three digits (and four digits if he/she gave you three numbers). The brute force way would be to go down every street and look at every house number that has every digits given to you included in them, plus one unknown digit (which by trial and error you will include in the number for which you're searching). Eventually (like a very long time later), you are bound to find the house. That's using the brute force method!!
If you're a math person, you'll immediately know that to use brute force will inversely vary your chance of finding the correct house, with the size of the city, and you'll immediately abandon that approach as hopeless. IOW, brute force is OUT!!
The graph approach says, "find all the streets that are long enough to have these many houses, using these possible combination of numbers." That would immediately eliminate a bunch of streets (such as those with less than a hundred houses on them). To then relapse to using brute force, would be that you'd start checking every house (on streets with more than 100 houses) to see which ones have digits (minus one) that were given to you. Again, plain common sense should tell you that using such an approach is less than optimal; try a smarter way.
To further eliminate bad leads, a more optimal approach would be for you to set up a kind of graph with positions on the street (represented by nodes) where by extrapolating the numbers, you'd have a good idea where the possibilty of a certain house ought to be with a candidate number. For example, if you're working with just these two numbers, '2' and '9', the third missing number will be any from 1 through 9. Therefore, you set up the graph to show where the possibility might be, that a house (beginning with the lowest possible number) would most likely be situated. This means you'll begin with 129, followed by 192, then 219 followed by 291 (etc.). That's the permutation to which I referred earlier. This means you'll figure out, most likely where on a particular street would house #129 would be, followed by where house #192 would be (etc.). This means you're discretely checking only certain houses and skipping a lot others. This is NOT a door to door search you're using!!! and no brute force is being applied in your method; just maths, common sense and the Law of Probability.
William
Fortes in fide et opere!





Umm, correct me if I'm wrong, but the over complicated if()...else if()... "math" in the source could simply be expressed as d=9((a+b+c)%9);.
For a three digit response ... works a treat for me.





A discussion on the Fido puzzle took place in the lounge last week[^]
Steve





Doh! I guess I need to frequent the Lounge more often. Thanks.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?





"Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?"
Well ... two ARE left!
but if you ask "How many left?" then the answer is a little trickier





This is really neat. Good job.





Now, I'm no physycist/mathematical programmer, but see my thread "Overly Complex Math", to see why this particular implementation, at least the "mathematical programming" part, is untidy as opposed to "really neat".





www.eugigames.tk








General News Suggestion Question Bug Answer Joke Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

