LabVIEW Digest Programming Challenges

Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.

Re: LabVIEW Digest Challenge 1

I've sent my entry. Looking forward to results Smiley Happy.

0 Kudos
Message 11 of 20
(2,143 Views)

Re: LabVIEW Digest Challenge 1

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

0 Kudos
Message 12 of 20
(2,136 Views)

Re: LabVIEW Digest Challenge 1

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!

Winning Entry.PNG

 

 

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.

 

 

 

0 Kudos
Message 13 of 20
(2,078 Views)

Re: LabVIEW Digest Challenge 1

Search and replace array elements first, then sum - not quite right, will only find the first 10 value, not the second. Issue fixed below.

 

Case Structure.PNG

 

A beautifully simple solution:

 

Simplicity.PNG

 

Using auto indexing and for loops:

 

For loop.PNG

We even had an object-oriented solution from Thoric which I have attached:

 

OOP.PNG

 

 

Which solution do you like best?

 

 

 

Message 14 of 20
(2,075 Views)

Re: LabVIEW Digest Challenge 1

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!

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
0 Kudos
Message 15 of 20
(2,064 Views)

Re: LabVIEW Digest Challenge 1

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.

 

Search.PNG

0 Kudos
Message 16 of 20
(2,048 Views)

Re: LabVIEW Digest Challenge 1


@CharlotteN wrote:

 

 

We even had an object-oriented solution from Thoric which I have attached:

 

OOP.PNG

 

 

 


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!

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 17 of 20
(1,950 Views)

Re: LabVIEW Digest Challenge 1

Hi

Can you please announce the winner of Challenge 1, and then post next challenge?

Happy to Wire
0 Kudos
Message 18 of 20
(1,930 Views)

Re: LabVIEW Digest Challenge 1

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

Message 19 of 20
(1,927 Views)

Re: LabVIEW Digest Challenge 1

This my solution:

Sum of Array (snippet).png

HOB Consultores S.A.
Área de Investigación, Desarrollo e Innovación Tecnológica
0 Kudos
Message 20 of 20
(891 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.