cancel
Showing results for 
Search instead for 
Did you mean: 

Flip digits

SOLVED
Ambrose1464
Member

Re: Flip digits


@RavensFan wrote:

Do the check inside the loop.  Use a conditional tunnel to build an array of values if it is a palindrome.

 

I don't understand why you wired upper limit to the N terminal, and use lower limit.  You are just going to figure out if the lower limit value is a palindrome a number of times in a row to equal "upper limit".

 

Try running your code with Highlight execution turned on so you can figure out how it works.

 

And use block  diagram cleanup.


I have probelm for this, that why i dunno how to build to check the palindrome number in given range. for example i want find all the palindrome number in the range between 0 - 100000 like that. I first time using LabVIEW and still no idea how does it works. 

RavensFan
Knight of NI

Re: Flip digits

You need to put the value you are checking into a shift register so that when increment it the next iteration, you check the next value.

Ambrose1464
Member

Re: Flip digits


@RavensFan wrote:

You need to put the value you are checking into a shift register so that when increment it the next iteration, you check the next value.


Could you please show me the code how does it look like? 

RavensFan
Knight of NI

Re: Flip digits

Message contains an attachment

this

Ambrose1464
Member

Re: Flip digits

Message contains an attachment

@RavensFan wrote:

this


The number of times is it my end of number range? How i going to display all the number in the range between example 0- 99999? am i did the wrong code?

RavensFan
Knight of NI

Re: Flip digits


@Ambrose1464 wrote:

@RavensFan wrote:

this


The number of times is it my end of number range?

 

Yes

 

How i going to display all the number in the range between example 0- 99999? am i did the wrong code?

 

Look at my picture again.  You did not put in the condtional auto-indexing tunnel.


The Equals to check if the number is a palindrome is part of the check to see if it is a palindrome and belongs in the frame I showed, not outside of everything.
Have you been running the code with highlight execution on to understand how it works?  I don't think you have, otherwise you'd have an idea as to why what you have now doesn't work and could fix it.
Also, in that inner while loop, make both of the 10 constants blue integer data types.

 

Ambrose1464
Member

Re: Flip digits

Message contains an attachment

@RavensFan wrote:

@Ambrose1464 wrote:

@RavensFan wrote:

this


The number of times is it my end of number range?

 

Yes

 

How i going to display all the number in the range between example 0- 99999? am i did the wrong code?

 

Look at my picture again.  You did not put in the condtional auto-indexing tunnel.


The Equals to check if the number is a palindrome is part of the check to see if it is a palindrome and belongs in the frame I showed, not outside of everything.
Have you been running the code with highlight execution on to understand how it works?  I don't think you have, otherwise you'd have an idea as to why what you have now doesn't work and could fix it.
Also, in that inner while loop, make both of the 10 constants blue integer data types.

 


chane to this?

altenbach
Knight of NI

Re: Flip digits

What is the point of the boolean control?

Ambrose1464
Member

Re: Flip digits

i'm confusing. I totally no idea how to display the palindrome number range example between 0- 99999 

Highlighted
Bob_Schor
Knight of NI

Re: Flip digits

Message contains an image Message contains an attachment

Ambrose,

 

     I'm puzzled.  You appear to be taking a class in LabVIEW, as this sounds like an interesting Homework Assignment, yet you seem to know almost nothing about LabVIEW, the common Structures (While Loops, For Loops, etc.), how arrays behave, the principles of Data Flow, and other topics that should have been covered in the first few classes.

 

     Have you spent any time with the Tutorial material listed on the upper right corner of the LabVIEW Forum's first page?  You can also do a Web search for LabVIEW Tutorials -- a number are videos.

 

     To help you get started, I'm attaching Project Palindrome, a LabVIEW Project (which you probably don't know about) that contains three VIs -- Find Palindromes (which directly returns an array of all the Palindrome integers up to some "Top" Integer), a sub-VI, Is Palindrome, which tests an Integer and returns a Boolean (True if it is an Palindrome), and another sub-VI, Reverse Digits, that returns the reversed-digit version of its input integer.

 

     These are exactly the VIs I suggested to you in my reply yesterday.  One of my colleagues showed you something similar to my Find Palindromes, but included a "Starting Integer" (whereas I implicitly start at 0).

 

     Some things to note about this Project and the VIs inside:

  • You open a Project by clicking on the .lvproj (the "Project") file, here called "PROJECT Palindrome.lvproj".  When it opens, it will show you all of the VIs included in the Project, and will simplify linking them together into a cohesive whole.  I recommend creating a Project File for all but the most trivial "stand-alone" VIs.
  • Find Palindromes is "finished" in the sense that there is nothing more to do with this VI.  Let me show it to you:
  • Find Palindromes.pngNote the sub-VI "Is Palindrome" -- you "know" what it is because it has an icon that identifies it.  So you can look at this top-level VI and say, "Yes, if "Is Palindrome" works as advertised, this will produce an array of all of the Palindromes from 0 (the starting value of the For Loop) to (oops, actually) one less than the value I have in "Top" Integer.  [How embarrassing -- an off-by-one error!].  Do you understand the function of the Indexing Tunnel on the output of the For Loop?  Do you understand the Conditional part of this tunnel?
  • When I run this, it finds 1098 Palindromes from 0 to 100000 (actually, because of the off-by-one bug, 0 to 99999), and does it in about 20 milliseconds.
  • I've included "dummy" versions of Is Palindrome and Reverse Digits.  The VIs have Icons (so you can easily identify them on the Block Diagram), inputs, and outputs, but there is no code on the Block Diagram -- that's left for you to fill in.
  • These VIs illustrate some good practices you should follow if you want to do any serious LabVIEW programming, in particular, if you want to write some LabVIEW code that you will likely use for an extended period of time (i.e. more than just the next Class Assignment).  They include the following:
    • VIs are mostly written to do Just One Thing, but to do it well, and completely.
    • Every VI has an Icon that makes it "obvious" what it does (makes the Block Diagram that uses the VI easier to understand).
    • Every VI uses the 4-2-2-4 connector pane, which makes the Inputs and Outputs line up nicely.
    • Every sub-VI has an Error In and Error Out cluster wired to the lower left and right connectors.
    • Every VI had a Description that (briefly) says what it does and names its Inputs and Outputs.

I realize that this is probably "overkill", given your level of expertise, but I'm hoping that maybe you'll take an interest and apply yourself to learning LabVIEW by doing some work, yourself, instead of coming to us and asking us to do it for you.  And if not, maybe another student who might follow this thread will learn something useful ...

 

Bob Schor

 

P.S. -- oops, almost posted without the attachment ...