LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simplest method in finding a Numeric Palindrome

Solved!
Go to solution

Hello everyone!!

 

Below is one method of finding a numeric Palindrome.
PALINDROME.PNG

Is there any way in which functions used can still be reduced. I have tried with T/F strings, mathematical approach and applied further more logic's. But, at max 3 functions were used in all of those, whereas the requirement is 2 functions.

 

 

We can't help everyone, but everyone can help someone.. Smiley Happy

0 Kudos
Message 1 of 44
(5,116 Views)

Hi Priyardarsini,

 

finding a palindrom is quite easy:

check.png😄

Your VI is checking an input for a palindrom…

 

What's the point in reducing the number of used primitives?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 44
(5,076 Views)

I guess your might e.g. want to use a loop and find all numbers below a certain upper limit that are palindromic when formatted as decimal. (of course you could also try to find palindromes in hex, octal, or binary formatted numbers, etc. these are probably easier)

 

I don't think you can get "simpler" than what you show, but you might get faster. 😄 (not sure though)

 

One interesting way to do this would be all blue (i.e. without any pink wires), so try that. 😉

 

What's your definition of a "function" and how do you count them?

0 Kudos
Message 3 of 44
(5,073 Views)

Given a reasonable upper limit and sufficient RAM, you could just use a lookup table 😄

 

PalindromeCheck.png

0 Kudos
Message 4 of 44
(5,064 Views)

@GerdW wrote:

 

What's the point in reducing the number of used primitives?


Just a challenge!!

on Optimizing the Task..

Every single logic can be further minimized with LabVIEW, in that perspective.. it is always possible.

Comeon Gerd, we may find a new way of checking an input for a palindrome !!

 

Smiley Happy

0 Kudos
Message 5 of 44
(5,057 Views)

Hi Priyardarsini,

 

on Optimizing the Task

"Optimizing" a VI ("algorithm implementation") most often is a trade-off between speed and disk/memory requirements. You need to define the kind of optimization you need to achieve!

As you requested "less functions/primitives" you should follow Christians suggestion on using a LUT: it apparently only uses just one primitive and is quite fast too. The trade-off here is memory consumption (and pre-compile preparations)…

 

Every single logic can be further minimized with LabVIEW, in that perspective.. it is always possible.

You shouldn't generalize this way…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 44
(5,046 Views)

@altenbach wrote:

 

One interesting way to do this would be all blue (i.e. without any pink wires), so try that. 😉


Am actually trying to bring up with the Blue wire, altenbach.. but the problem is, its some how exceeding the limit of functions used.

Equal, reverse strings and number to decimal string are functions.

 

And can you just brief the LUT concept, please.. 🙂 

0 Kudos
Message 7 of 44
(5,045 Views)

@PriyadarsiniS wrote:
Equal, reverse strings and number to decimal string are functions.

 


How about loops? Diagram constants? etc.

 


@PriyadarsiniS wrote:
And can you just brief the LUT concept, please.. 🙂 

The LUT (lookup table) is a boolean array that for each element knows if the index pointing to it is a palindrome or not. You can generate the LUT by placing your original code inside a FOR loop, wiring [i] to the input, and auto indexing the boolean at an output tunnel. When done, convert the indicator into a diagram constant, copy it, and implement my code in a new VI. Change the "data entry" for the numeric input (wired to index) to coerce to the valid range of numbers, i.e. the size of he LUT.

0 Kudos
Message 8 of 44
(5,026 Views)

LUT.PNG

Thank you Christian, so that's what LUT means.. that should definitely work for the given range of pre-analyzed values.. But still the future inputs may be out of the range of Boolean constants, rite!!

My work is to reduce the functions used and to check Palindrome, whatever be the numeric range.

 

Is this signify equal, number to string conversion and reverse strings shouldn't be said functions. Am I clear ?!

 


@altenbach wrote:

@PriyadarsiniS wrote:
Equal, reverse strings and number to decimal string are functions.

 


How about loops? Diagram constants? etc.

 


 

 

0 Kudos
Message 9 of 44
(5,002 Views)

The task must be optimized in terms of Speed, Gerd.

For whatever the numeric range be, the palindrome check as you said must be done..

 


@GerdW wrote:

 

Every single logic can be further minimized with LabVIEW, in that perspective.. it is always possible.

You shouldn't generalize this way…


May be, as I have mentioned I personally believe there is always a simple and another method to solve a kind of problem it varies with person to person. More or less, drawing a class diagram in LOOP's with a generalized topic.. you may branch them, differently and I may branch it differently.. as far as the clear cut purpose/motive is known!! Smiley Happy

0 Kudos
Message 10 of 44
(4,997 Views)