LAVA 1.0 Content Posted June 3, 2008 Report Share Posted June 3, 2008 Hi all, A friend of mine recently dragged me into the Euler Project, anyone here is spending his nights doing it as well ? By the way, LabVIEW is not in the default "language list" :thumbdown: Quote Link to comment
Cmal Posted June 3, 2008 Report Share Posted June 3, 2008 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 Quote Link to comment
PaulG. Posted June 3, 2008 Report Share Posted June 3, 2008 :thumbup: Yes, but it's been a while, though. I love where my head goes when I'm trying to work out one of their problems. Quote Link to comment
Aristos Queue Posted June 3, 2008 Report Share Posted June 3, 2008 QUOTE (Cmal @ Jun 2 2008, 10:03 AM) For example, try to find 1000! in LabVIEW. Here's how: http://forums.lavag.org/index.php?s=&s...post&p=5194 You might also follow up with this link: http://forums.lavag.org/index.php?s=&s...post&p=5190 Quote Link to comment
JiMM Posted June 4, 2008 Report Share Posted June 4, 2008 Wow, that's some beautiful code! Quote Link to comment
jaegen Posted June 4, 2008 Report Share Posted June 4, 2008 LabVIEW is now in the language list. :ninja: Jaegen Quote Link to comment
JiMM Posted June 5, 2008 Report Share Posted June 5, 2008 Antoine, Thank you for introducing me to this fascinating challenge. My wife would not thank you 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! Quote Link to comment
LAVA 1.0 Content Posted June 5, 2008 Author Report Share Posted June 5, 2008 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 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 . 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 ! 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 Cheers Quote Link to comment
LAVA 1.0 Content Posted June 5, 2008 Author Report Share Posted June 5, 2008 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 . What version of LabVIEW did you use ? Can you repost it please ? Quote Link to comment
JiMM Posted June 5, 2008 Report Share Posted June 5, 2008 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 The attached VIs are in LV7.1. Quote Link to comment
JDave Posted June 5, 2008 Report Share Posted June 5, 2008 QUOTE (JiMM @ Jun 4 2008, 02:47 PM) 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 The attached VIs are in LV7.1. 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. QUOTE (JiMM @ Jun 3 2008, 04:55 PM) My wife would not thank you I don't know if my wife would appreciate me starting up. It does look fun though. Quote Link to comment
JiMM Posted June 6, 2008 Report Share Posted June 6, 2008 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. Quote Link to comment
JiMM Posted June 7, 2008 Report Share Posted June 7, 2008 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!!!!!! Quote Link to comment
LAVA 1.0 Content Posted June 10, 2008 Author Report Share Posted June 10, 2008 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 . 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. Quote Link to comment
TobyD Posted June 10, 2008 Report Share Posted June 10, 2008 QUOTE (Antoine @ Jun 2 2008, 07:00 AM) anyone here is spending his nights doing it as well ?By the way, LabVIEW is not in the default "language list" :thumbdown: 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 Quote Link to comment
LAVA 1.0 Content Posted June 10, 2008 Author Report Share Posted June 10, 2008 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 I did ask for it, but I didn't receive the mail form the admin :thumbdown: Quote Link to comment
FLAnatic Posted June 11, 2008 Report Share Posted June 11, 2008 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. Quote Link to comment
JiMM Posted June 11, 2008 Report Share Posted June 11, 2008 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 I sent an email the first time I went to the web site :thumbup: Quote Link to comment
LAVA 1.0 Content Posted June 12, 2008 Author Report Share Posted June 12, 2008 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 ! Quote Link to comment
LAVA 1.0 Content Posted July 3, 2008 Author Report Share Posted July 3, 2008 Darn you. You wasted my evening away... Quote Link to comment
JiMM Posted July 3, 2008 Report Share Posted July 3, 2008 QUOTE (LV_FPGA_SE @ Jul 1 2008, 11:27 PM) Darn you. You wasted my evening away... Don't worry, it won't be the last one! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.