From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simplest method in finding a Numeric Palindrome

Solved!
Go to solution

@Ben wrote:

 

Can it be done using a regular expression?

 


Probably, but not with only two functions.

 

Starting from a numeric, we first need to format into string, followed by the suitable regex (not sure how). Then we need to convert the output into a boolean. Still three functions. 😄

Message 21 of 44
(1,862 Views)

The loop was just to set a random selection on numeric range limit. 


max-number.png

And, I was cautious on the number limit too, christian. As far this default value

exceeds the I32 control both in numeric control and Array control works fine.

0 Kudos
Message 22 of 44
(1,851 Views)

Actually, it is possible Ben.. with logarithmic and all math concepts involved. And in that case too, it goes different with odd and even palindrome's.. It's definitely, good to think as we are doing now.. Logically!!


@Ben wrote:

While not my area of expertise...

 

Can it be done using a regular expression?

 


Moreover, am thinking of a solution that wouldn't involve Numeric to decimal string conversion function. Cause, that's the only method to use only 2 functions in place of 3 as I have mentioned in Topic at first. Lets see.. 

0 Kudos
Message 23 of 44
(1,850 Views)

@PriyadarsiniS wrote:

Actually, it is possible Ben.. with logarithmic and all math concepts involved. And in that case too, it goes different with odd and even palindrome's.. It's definitely, good to think as we are doing now.. Logically!!


@Ben wrote:

While not my area of expertise...

 

Can it be done using a regular expression?

 


Moreover, am thinking of a solution that wouldn't involve Numeric to decimal string conversion function. Cause, that's the only method to use only 2 functions in place of 3 as I have mentioned in Topic at first. Lets see.. 


Exercise artistic liberty and define that the number be entered as a string.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 24 of 44
(1,848 Views)
Solution
Accepted by topic author PriyadarsiniS


PALINDROME.PNG

The solution goes something like this.. Am just thinking other possible sol. too, to just iterate the claim Smiley Wink

 

simplified_pal.png

As in place of 3 functions, we reduce them to 2 functions by removing decimal string conversion and using the NumericText. Text property node. Thereby, taking string form of a number from itself!!


 

Message 25 of 44
(1,843 Views)

@PriyadarsiniS wrote:

 

 

simplified_pal.png

As in place of 3 functions, we reduce them to 2 functions by removing decimal string conversion and using the NumericText. Text property node. Thereby, taking string form of a number from itself!!


 


That is still three function, one being a very expensive property node! Make the input a string and get it over with. As a bonus, it will work with almost any number of digits and even detects in any random text string is palindromic at the same time.

 

As long as you only enter numeric characters, there is no difference to the other code.

0 Kudos
Message 26 of 44
(1,845 Views)

2 functions (1 p-node)

Spoiler
Capture1.png

"Should be" isn't "Is" -Jay
0 Kudos
Message 27 of 44
(1,845 Views)

Yup, Ben.. this was the first thought that came into picture.

Instead, of all this logical method of analyzing we just just straight away make the user right in a string control with artistic liberty, with some limitations written on the *terms and conditions view. Smiley Very Happy

 

Better an oops than a what if.. Smiley Wink

0 Kudos
Message 28 of 44
(1,839 Views)

@JÞB wrote:

2 functions (1 p-node)

Spoiler
Capture1.png

If am not mentioning it wrongly..

Why was it named Spoiler ?! Smiley Surprised

 

0 Kudos
Message 29 of 44
(1,834 Views)

OK So Great minds think alike

 

(Interesting cross-post)

 

How about 1 primitive? no fair peeking.......

Spoiler
Capture2.png

"Should be" isn't "Is" -Jay
0 Kudos
Message 30 of 44
(1,829 Views)