BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Vampire Numbers (Balaji, where are you????)

Vampire numbers are the numbers (with even number of digits) that can be expressed as the product of the digits in the numbers itself.

For example : 1260 is a vampire number. It can be expressed as a product of 21 and 60 . 21 and 60 are called FANGS

 

Here is a code which i have developed which is able to find the vampire numbers (4 digits ony) along with there fangs

 

 

(This was a challenge given to me By BALAJI. Where are you Balaji?????????????? M waiting for my kudos and some good discussion)

Somil Gautam
Think Weird
0 Kudos
Message 1 of 18
(9,684 Views)

I executed your code and find, the highest 4 digit Vampire number as per your code is 6880 and is appearing two times. (86 and 80, 80 and 86. Then again 86 and 80, 80 and 86 which is not required)

 

Mathan

0 Kudos
Message 2 of 18
(9,676 Views)

Hi mathan  🙂 🙂

 

 Ya, you are right. it displays the number two times and that can be certainly filtered out

Somil Gautam
Think Weird
0 Kudos
Message 3 of 18
(9,672 Views)

Vampire Numbers was a coding challenge.

The request

The result

 

How would it work with LV 2009, parallel loops on multicore CPU? Altenbach I think you have the code on hands. What about a retest?

Message Edited by waldemar.hersacher on 09-29-2009 01:21 PM
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 18
(9,669 Views)
HaHa, i had seen that before i was going to start with the challenge.Smiley Wink
It was given to me as a challenge by BALAJI to test my skills as i am a beginner in labVIEWSmiley Happy
Somil Gautam
Think Weird
0 Kudos
Message 5 of 18
(9,663 Views)

Somil wrote:

It was given to me as a challenge by BALAJI to test my skills as i am a beginner in labVIEWSmiley Happy

Here is the link he is referring to.

0 Kudos
Message 6 of 18
(9,660 Views)
And Just 1 post below that is the link to which you directed me
Somil Gautam
Think Weird
0 Kudos
Message 7 of 18
(9,657 Views)
It's a long way from "My Computer" to Vampire Numbers. I didn't read the other thread all those pages.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 8 of 18
(9,650 Views)

waldemar.hersacher wrote:

How would it work with LV 2009, parallel loops on multicore CPU? Altenbach I think you have the code on hands. What about a retest?


Yes, I still have all my code. Unfortunately I am pretty busy at the moment.

 

 

Somil,

 

This is certainly a good learning tool, but your code needs a significant makeover.

 

  • Don't use hidden indicators as a source of  local variables. None of those are needed.
  • There is no need to constantly hide hidden controls. Once there are hidden, they stay that way.
  • Six out of seven cases have near identical code, see if you can get away with a single instance of it.
  • To index out three elements, there is no need to convert an array to a cluster and then unbundle it. Constantly swapping data structures is expensive. Index array is resizeable and does the same directly. You don't even need to wire the indices. SInce you make it back int an array later, you never have to extract individual elements anyway, right?
  • None of these intermediate results (hidden arrays with local variables) are needed. All you need is six iterations, building the final array in a shift register. (you get the functionality of case 7 for free)
  • "output array" is not needed, simply feed the output of stage 1 into the second loop. This create a data dependency and you no longer need the sequence structure.
  • I would have never expected to see a pt-by-pt function in a math application. There are certainly better ways to do that. They are also unsuitable, because they create extra zeroes in the output array. Try to built the output in a shift regsiter and write it once at the end of the program. There is no need to update the indicator in an inner loop.
  • Your code is not scaleable. Doing the same for e.g. 6 digit vampire numbers would require a significant rewriting. Try to write code can work with any number of digits (at least as supported with simple numerical types).
  • You need to filter out duplicate results.

 

 

You should make the VI compatible with the template of the challenge. 

Why don't you do a banchmark. This should literally take only microseconds with better code. 😉 (My code was able to get all vampire numbers (thousands!) with up to 8 digits in a faster time.)

Message 9 of 18
(9,619 Views)

Hi Altenbach

 

So this time, the Knight of NI and the winner of the same contest is helping me with his valuable suggestions.

Thanks a lot and i will certainly go for all the makeovers.

 

I have one query. how can i make an array of numbers (only for the true case) in the code attached!!!

 

 

 

Somil Gautam
Think Weird
0 Kudos
Message 10 of 18
(9,587 Views)