Q Basic 
Author Message
 Q Basic

I have a question.  I'm not sure if you guys have heard of Alphametic
puzzles.  But if you haven't it's like America = Fifty + States    There is
a number that corresponds to each letter (like a cryptogram puzzle).  Now, i
was trying to write a program in QBasic (1.1) and i'm not getting very far.
Can someone help me write the code to find the numbers in these puzzles?

-Graham



Tue, 29 Jun 2004 04:30:04 GMT  
 Q Basic
Perhaps if you provided more details.  You haven't given much to go
on.

john thrum


Quote:
> I have a question.  I'm not sure if you guys have heard of
Alphametic
> puzzles.  But if you haven't it's like America = Fifty + States
There is
> a number that corresponds to each letter (like a cryptogram puzzle).
Now, i
> was trying to write a program in QBasic (1.1) and i'm not getting
very far.
> Can someone help me write the code to find the numbers in these
puzzles?

> -Graham



Tue, 29 Jun 2004 10:01:26 GMT  
 Q Basic

Quote:

>I have a question.  I'm not sure if you guys have heard of Alphametic
>puzzles.  But if you haven't it's like America = Fifty + States    There is
>a number that corresponds to each letter (like a cryptogram puzzle).  Now, i
>was trying to write a program in QBasic (1.1) and i'm not getting very far.
>Can someone help me write the code to find the numbers in these puzzles?
>-Graham

Graham

What you can do, in a brute force solution, is write a program that
contains 10 or so nested loops - probably FOR loops.

You have ten letters, and I assume the puzzle is to assign a single
decimal digit from 0 to 9 to each letter such that the equality is met
by the numbers composed using this substitution .

In puzzles like this, usually the digits can only be assigned once
only, but sometimes they can be assigned multiple times, ie. maybe
both a and m represent the digit 0.  If it is not specified, try for a
solution with unique assignments. If that does not work, try for a
non-unique-assignment result, but that is flakey - one should make a
puzzle like this!

Each time you cycle thru the 10 letter assignments, you must test to
see if the resulting numbers produce the equality.

Do this by composing the required numbers from the current pattern of
letter assignments for this iteration:

america = 1000000*a + 100000*m + 10000*e + . . . etc

fifty = 10000*f + 1000*i + . . . etc

states = 100000*s + . . . etc

Your test will be if fifty + states equals america, then you have
found the correct letter assignment.  If not, then do the next cycle
thru the digit to letter assignments and test again.

Run the sucker till it finds the answer.

Go make some coffee.

Hint:

So you can tell its actually working, optionally display the
assignements and results on screen while it's running, so you can get
an idea if you've got your assignments procedure correct, and to see
how long it is taking.  When you are convinced your method is
flawless, bypass the display if it making the whole thing run too
slowly.

Have fun.

For an PhD, you could reverse the testing and find new puzzles.

Hook into a dictionary lookup to test your results so you don't have
to eyeball every one to see if it's composed of real words.

 - Tom



Wed, 30 Jun 2004 01:39:46 GMT  
 Q Basic
Fifty + States = ? (find the answer which happens to be "America"), or
Fifty + States = America, find the base 10 numbers?

The first is Symbolic math!  No?  Presumably, the base may change for each
puzzle, or what would be the fun of the game, eh?  If it was always base 10,
the answers would be too easy to figure out.  If it was always base 26 (or
52), then I'd assume the letter values at least are changed for each puzzle
or simplicity would reign once again.

I'd suggest writing a program that will solve a known set of rules for
yourself, let's say Octal math (0-7).  Make that work, then add the ability
to do Hex math (0-F).  That may help you understand the verifiable rules
while learning to deal with symbols.  By the way, it wouldn't hurt to throw
in Decimal while you're at it, a set of symbols not divisible by 8.

In short order you should have yourself a program that will add OR subtract
symbols so that America - fifty = states too!

Then, you will find that the puzzles were never so much as half the fun of
writing your program!

Regards,
Billy Joe
http://home.adelphia.net/~bjb1939/email.html


Quote:
> I have a question.  I'm not sure if you guys have heard of Alphametic
> puzzles.  But if you haven't it's like America = Fifty + States    There
is
> a number that corresponds to each letter (like a cryptogram puzzle).  Now,
i
> was trying to write a program in QBasic (1.1) and i'm not getting very
far.
> Can someone help me write the code to find the numbers in these puzzles?

> -Graham



Thu, 01 Jul 2004 04:49:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A97 Wizard Qs

2. Newbie Qs: Optimizing Stylesheet with Fields

3. Qs on applying style

4. Qs on applying style (word2000)

5. connect to robohelp qs

6. VERBATUM EXAM Qs 91947

7. handling event from control qs

8. 2 fairly simple database Qs

9. Qs: VB4.0/OLE/ODBC

10. DBCombos and some general Qs

11. Qs about OO design

12. Two Qs...

 

 
Powered by phpBB® Forum Software