# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Simplest method in finding a Numeric Palindrome

Hello everyone!!

Below is one method of finding a numeric Palindrome.

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..

Message 1 of 44
(5,117 Views)

## Re: Simplest method in finding a Numeric Palindrome

Hi Priyardarsini,

finding a palindrom is quite easy:

😄

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
Message 2 of 44
(5,077 Views)

## Re: Simplest method in finding a Numeric Palindrome

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?

Message 3 of 44
(5,074 Views)

## Re: Simplest method in finding a Numeric Palindrome

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

Message 4 of 44
(5,065 Views)

## Re: Simplest method in finding a Numeric Palindrome

@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 !!

Message 5 of 44
(5,058 Views)

## Re: Simplest method in finding a Numeric Palindrome

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
Message 6 of 44
(5,047 Views)

## Re: Simplest method in finding a Numeric Palindrome

@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.. 🙂

Message 7 of 44
(5,046 Views)

## Re: Simplest method in finding a Numeric Palindrome

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

How about loops? Diagram constants? etc.

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.

Message 8 of 44
(5,027 Views)

## Re: Simplest method in finding a Numeric Palindrome

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:

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

How about loops? Diagram constants? etc.

Message 9 of 44
(5,003 Views)

## Re: Simplest method in finding a Numeric Palindrome

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!!

Message 10 of 44
(4,998 Views)