Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vampire numbers 1

Status
Not open for further replies.

brisray

Programmer
Feb 7, 2002
88
0
0
US
This is a bit long, but I'd appreciate the help.

I've been messing about with number series, and now I've managed to confuse myself.

Vampire numbers are those numbers that have an even number of digits. The digits can be mixed and split so that each pair of numbers when multiplied together give the vampire number. For example, 1,435 is a vampire number as you can get 35 * 41 from it, so is 2,187 (27 * 81)

I've managed to write a program to work out the vampire numbers for 4 digit numbers, now I'm working on the 6 digit ones. These are going to have 2, 3 digit numbers as the "fangs". Which give this number series its name.

I've got the numbers into a string then split the string into individual digits and put these into an array using

VampLen = LEN(LTRIM$(VampStr$))
FOR Count = 1 TO VampLen
VampAry$(Count) = MID$(VampStr$, Count, 1)
NEXT Count

I used a bunch of SWAP statements to change the order of the array when creating and testing the 2 digit numbers for the 4 figure vampire numbers.

ReCurs = ReCurs + 1

SELECT CASE ReCurs

CASE 1
SWAP VampAry$(1), VampAry$(2)
CASE 2
SWAP VampAry$(1), VampAry$(2)
SWAP VampAry$(3), VampAry$(4)
CASE 3
SWAP VampAry$(1), VampAry$(2)
CASE 4
SWAP VampAry$(1), VampAry$(2)
SWAP VampAry$(2), VampAry$(3)
CASE 5
SWAP VampAry$(3), VampAry$(4)
CASE 6
SWAP VampAry$(1), VampAry$(2)
CASE 7
SWAP VampAry$(3), VampAry$(4)
CASE 8
SWAP VampAry$(1), VampAry$(2)
SWAP VampAry$(2), VampAry$(4)
CASE 9
SWAP VampAry$(3), VampAry$(4)
CASE 10
SWAP VampAry$(1), VampAry$(2)
CASE 11
SWAP VampAry$(3), VampAry$(4)
END SELECT

If I try to do this creating the 2, 3 digit numbers for 6 digit vampire numbers I'm going to end up writing at least 350 swap statements. Can anyone suggest a quicker way of creating all the possible position variations for these numbers? I know I'm going to have to do at least 405,450 calculataions for these numbers, and over 40 million if I extend the program to 8 digit numbers, so any help will be greatly appreciated.

If I've managed to confuse anyone besides myself, think of this. I want all possible positional combinations of the string ABCDEF, such as ACBDEF, ACDBEF etc. etc. For my purposes ABC DEF is the same as DEF ABC but I can take care of the duplications myself.

If you'd like to know more about vampire numbers then see and
Ray
 
(Not to drag this too far off-topic)

Tranman, I too would be interested in that COBOL Jumble solver. Actually, a jumble solver in any language is greatly appreciated - and examples in several languages would be perfect! I'm doing a paper on code solution similarities between different languages, and jumble solvers is the topic I chose...

Thanks in advance,

-jimm@digitalmouse.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top