04-04-2017 07:20 AM
I've sent my entry. Looking forward to results .
04-04-2017 07:31 AM
Thanks! I have just received it
We've received a huge range of different solutions so I look forward to sharing them with everyone next week.
Charlotte
04-13-2017 02:14 AM
Hi Everyone,
I picked a correct solution at random we now have a winner I've attached the winning code entry below and there's a free training voucher on its way to the programmer now! Congratulations!
A lot of people had a solution like this so I recommend checking out this link on auto-indexing for loops as that makes life a lot easier and stops the while loop within a while loop which can be easy to get stuck in!
Thank you to everyone who entered the competition! We will be running it again in the next few months so keep an eye out for the LabVIEW Digest. We had a lot of entries and despite a relatively simple problem, we had a huge number of different ways of solving it! I've posted below some of the other variations as there's always things to learn from other people's code.
04-13-2017 02:25 AM - edited 04-13-2017 08:37 AM
Search and replace array elements first, then sum - not quite right, will only find the first 10 value, not the second. Issue fixed below.
A beautifully simple solution:
Using auto indexing and for loops:
We even had an object-oriented solution from Thoric which I have attached:
Which solution do you like best?
04-13-2017 04:25 AM
I don't want to be that guy, but I will be! There is a small bug in solution 1 - try putting in two '10's, it will pick the first but not the latter. It's an issue I've put in code before with the 1D search. It just needs a little more code to work fully though - the concept is good.
I like the simple solution - I had a similar concept in mind. It feels more efficient than looping but I'm not sure if it is!
04-13-2017 08:39 AM
Oh good spot! That will teach me to only thoroughly check the winner. I thought I had checked them all but obviously not. I made a quick alternative solution based on that code to fix that bug. It's a bit more convoluted now though, perhaps there's a simpler way but still using the same idea of searching and replacing.
05-11-2017 10:32 AM
@CharlotteN wrote:
We even had an object-oriented solution from Thoric which I have attached:
The OO approach is extensible. The parent class for storing numbers can be overridden with any child class for exhibiting special behaviour when adding numbers. Also, the method for "sum" can be extended with new methods, such as "product" or "factorial" etc., without much effort.
For this problem it's clearly way over the top, but perhaps good reading for anyone interested in learning about OOP in LabVIEW.
I've enjoyed the challenge Charlotte, looking forward to the next one!
05-16-2017 07:55 AM
Hi
Can you please announce the winner of Challenge 1, and then post next challenge?
05-16-2017 08:01 AM
Hi Sankar06,
The winner was announced a few weeks ago and the winning solution can be seen above.
We will be running the challenge roughly every 3 months when we release the LabVIEW Digest Newsletter. If you're interested in hearing about the next challenge immediately I recommend looking at your email settings and selecting to receive the LabVIEW Digest. If not, keep checking back here for Challenge 2. You can expect it around late May, early June.
Thanks,
Charlotte
02-18-2019 04:54 PM - edited 02-18-2019 04:55 PM
This my solution: