Jump to content

Challenge yourself


Recommended Posts

QUOTE (Antoine @ Jun 2 2008, 09:00 AM)

Hi all,

A friend of mine recently dragged me into the http://projecteuler.net/' rel='nofollow' target="_blank">Euler Project, anyone here is spending his nights doing it as well ?

By the way, LabVIEW is not in the default "language list" :thumbdown:

I've been a fan of it for a while, and it's good to see someone else doing the problems with LabVIEW. Just out of curiosity, how have you been handling the questions that require (or encourage) using big integers? For example, try to find 1000! in LabVIEW.

Chris M

Link to comment

Antoine,

Thank you for introducing me to this fascinating challenge. My wife would not thank you :D I would be interested in any suggestions to improve my code. I can get the job done, but I am sure that my LV coding skills can only go up. Attached is my solution to the Euler project chalenge #3. I would love to hear any suggestions as to how to improve it's efficiency. I am not looking for fancy mathematical insights (won't help future projects). I have a solution, it's just slow (~4.5 minutes). What I am interested to learn is how to improve the code using more efficient LabVIEW practices. Thanks for any insights!

Link to comment

QUOTE (jaegen @ Jun 3 2008, 08:02 PM)

LabVIEW is now in the language list. :ninja:

Jaegen

That's cool !

QUOTE

Antoine,

Thank you for introducing me to this fascinating challenge. My wife would not thank you
:D
I would be interested in any suggestions to improve my code. I can get the job done, but I am sure that my
LV
coding skills can only go up. Attached is my solution to the Euler project chalenge #3. I would love to hear any suggestions as to how to improve it's efficiency. I am not looking for fancy mathematical insights (won't help future projects). I have a solution, it's just slow (~4.5 minutes). What I am interested to learn is how to improve the code using more efficient LabVIEW practices. Thanks for any insights!

I hope I'm putting you into trouble :unsure: .

I started the Euler projet with the same intent : improving my LabVIEW skills.

The first solution I found for problem 3 is quite slow as well, now that I saw the above linked code I will try to get inspired and improve my subVIs because it's easy to draw a solution that WILL find the solution but not untill the end of the universe ! :shifty:

Don't have time right now to have a look at your code, but I will.

EDIT :

I tested the prime factor VI that won the coding challenge on NI Forums, it takes 2ms to find the solution of prob 3 :blink:

Cheers

Link to comment

QUOTE (JiMM @ Jun 4 2008, 01:55 AM)

Antoine,

[...]

I would love to hear any suggestions as to how to improve it's efficiency. I am not looking for fancy mathematical insights (won't help future projects). I have a solution, it's just slow (~4.5 minutes). What I am interested to learn is how to improve the code using more efficient LabVIEW practices. Thanks for any insights!

I can't open you VI :o .

What version of LabVIEW did you use ?

Can you repost it please ?

Link to comment

The first posted version was in LV8. I now have two revised versions. The first (Euler3_Take2.vi) fixes blatent errors in my first attempt - like I eliminated testing of even numbers (DUH!). That dropped execution to ~2.3 minutes. The third version (Euler3_VJT.vi) uses a theory that to test N for primality you only need to check for divisibility by all of the primes up to N/2. Not the route I was really looking for because it relies on number theory rather than programming efficiency, but interesting to try. That one dropped execution time to 1.2 minutes. And used up my lunch hour rather than a night :D The attached VIs are in LV7.1.

Link to comment

QUOTE (JDave @ Jun 4 2008, 06:32 PM)

Math efficiency is going to be a large part of keeping the speed down. A slow mathematical algorithm will be slow no matter have programmatically efficient you make it.

Oh, there is no doubt that knowing tricks of the mathematical trade will help solve those problems more efficiently. As is seen by the version thatn only looks to the smaller primes for divisibility. But I was not looking to set records. I am meerly looking for insights from better LV programmers as to how I can optimize my use of arrays, loops etc. Trying to polish my toolbox, and improve my ability to use it :thumbup:

I don't know if my wife would appreciate me starting up. It does look fun though.

It is interesting to both solve the problem, and then say "how can I do this better?" At work I to often get in the mode of solve the problem and move on. If it works, the boss doesn't care (or notice) if it's elegant, or efficient.

Link to comment

Holy Mackerel! I am stunned by how fast the Coding Chalenge winner did this. Of course it was obvious that clever math tactics would be necessary to minimize time, but .... just WOW. I got less than 1ms with that VI on my PC. AMAZING! :worship: I am not worthy!!!!!!

Link to comment

QUOTE (JiMM @ Jun 6 2008, 03:51 AM)

Holy Mackerel! I am stunned by how fast the Coding Chalenge winner did this. Of course it was obvious that clever math tactics would be necessary to minimize time, but .... just WOW. I got less than 1ms with that VI on my PC. AMAZING! :worship: I am not worthy!!!!!!

I had a quick look at your VI "IsPrime.vi", one thing you can improve is the number of time you run the loop to see if the tested number is prime ; it's no use to test a prime divisor if it is bigger than the square root of the tested number ;)

EDIT :

My solution takes less than 2 secondes on my old laptop and it is not really different rom yours :yes: .

A few other advices to improve performance :

- avoid to use "build array" primitive,

- avoid cohersion dots,

- inline code.

One interesting hit I found, in my solution there is one subVI, if I inline the code to have only one VI, it runs faster ~10% ; I guess this is due to the way LabVIEW passes inputs to callees and outputs to callers.

Link to comment

QUOTE (Antoine @ Jun 2 2008, 07:00 AM)

This is fun stuff. Thanks for posting the link. I'm up to number 9! WooHoo!

QUOTE (jaegen @ Jun 3 2008, 11:02 AM)

LabVIEW is now in the language list. :ninja:

I requested that it be added when I signed up and right away the admin replied that he had added it. He said something about me getting my friends to request it as well so he must have received more than one email :shifty:

Link to comment

QUOTE (TobyD @ Jun 9 2008, 10:59 PM)

This is fun stuff. Thanks for posting the link. I'm up to number 9! WooHoo!

I requested that it be added when I signed up and right away the admin replied that he had added it. He said something about me getting my friends to request it as well so he must have received more than one email :shifty:

I did ask for it, but I didn't receive the mail form the admin :thumbdown:

Link to comment

QUOTE (Antoine @ Jun 9 2008, 06:11 PM)

I did ask for it, but I didn't receive the mail form the admin :thumbdown:

I was actually really into this and was hoping to solve all of the problems at some point. I've solved 90 of them but haven't visited in several months. Most of my solutions have been using c++ although I did solve the pathfinding problems using LabVIEW.

Link to comment

QUOTE (TobyD @ Jun 9 2008, 04:59 PM)

This is fun stuff. Thanks for posting the link. I'm up to number 9! WooHoo!

That's exactly where I am!

QUOTE

I requested that it be added when I signed up and right away the admin replied that he had added it. He said something about me getting my friends to request it as well so he must have received more than one email
:shifty:

I sent an email the first time I went to the web site :thumbup:

Link to comment

QUOTE (FLAnatic @ Jun 10 2008, 08:21 PM)

I was actually really into this and was hoping to solve all of the problems at some point. I've solved 90 of them but haven't visited in several months. Most of my solutions have been using c++ although I did solve the pathfinding problems using LabVIEW.

Wow... 90, well done !

I've got 20 (all in LabVIEW since it is the only language I know) at the moment but I won't stay here, it's great fun !

Link to comment
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.