LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Palindromic Numbers Consisting of the Product of Two 3-digit Numbers

Solved!
Go to solution

@Oligarlicky wrote:

I'm noticing some weird stuff depending on how I benchmark. If I stick it all in a for loop I can hit ~2 ns/ itteration. To be fair, I'm only doing 256 palindrome checks in my search (everything else gets filtered out).


Watch out for folding artifacts. Hard to tell without seing the code?

 

Try to caclulate how many clock cycles it takes per iteration. 😄 (e.g. 2ns on a 4GHz prcessor is only 8 clock cycles)

0 Kudos
Message 21 of 29
(1,749 Views)

@Oligarlicky wrote:

[...] all 6 digit palindromes are multiples of 11 [...]


That got me down to 0.3 mS.  Thanks. 


@Oligarlicky wrote:

I'm noticing some weird stuff depending on how I benchmark. If I stick it all in a for loop I can hit ~2 ns/ itteration. To be fair, I'm only doing 256 palindrome checks in my search (everything else gets filtered out).


 I checked 1,388. 😄

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 22 of 29
(1,717 Views)

altenbach wrote: OK, if I include that test, mine drops to 0.12ms (Still using string compare, though)  😄

No longer doing the "11" check, but average time after some optimization is now 0.035ms (35us).

0 Kudos
Message 23 of 29
(1,682 Views)

Thanks so much!

0 Kudos
Message 24 of 29
(1,625 Views)

Let us know when the assignment is over so we can compare our versions. Maybe we can all learn something... 😄

 

Often combining the various "tricks" by the top performers allows the design of new code that is faster than all of them.

0 Kudos
Message 25 of 29
(1,620 Views)

It was over last Thurseday. I actually tried my best to understand your codes and other top performers' ones by asking my TA and instructors for Labview workshop on campus. Hopefully, I can progress a lot faster with you guys' help.

0 Kudos
Message 26 of 29
(1,614 Views)

For various reasons I love "code miniatures", code that achieves the goal with the smallest amount of code.

 

For example, my ~35µs code only contains the following elements (+ controls/indicators, the benchmark skeleton, and  a few diagram constants that are not shown ;)).

 

Can you do it? Can you do it with less?

 

The code needs to solve the problem from first principles (i.e. you cannot just use an indicator wired to a diagram constant of the solution 🐵

 

(Note that no additional copies of these 13 functions can be added. e.g. you must use exactly two subtraction functions (or less if you dare!))

 

 

0 Kudos
Message 27 of 29
(1,605 Views)

One while loop? Madness

 

Square? That's gotta be reducing the search space somehow

 

Also, I couldn't use the min max because I needed the boolean for my case structure.

 

Surely constant folding is allowed. It's not my fault the compiler is so aggresive 😉

0 Kudos
Message 28 of 29
(1,570 Views)

@Oligarlicky wrote:

Surely constant folding is allowed. It's not my fault the compiler is so aggresive 😉


My code does not do constant folding. e.g. if I replace any of the diagram constant wired to the outer loop with a control, the speed is about the same.

 

In any case, we could continue the technical discussion in this new, more recreational thread instead. 😄

0 Kudos
Message 29 of 29
(1,561 Views)