The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: CLAD2017 - Answer the requirement: Sum those Rows

SercoSteveB
Active Participant

You are asked to write a VI that will take in a 2D Array of numeric values and output a 1D Array that contains the sum of the values for each row of the input array.  Which of the following VIs satisfies the requirements?

 

Have a go at coding the VI yourself or expand the Spoiler tag to see the possible answers.

 

Spoiler

 

a)

Add Rows #3.png

 

b)

Add Rows #2.png

 

c)

Add Rows #4.png

 

d)

Add Rows #1.png

 

Comments
jwscs
Active Participant

D, because a) sums the columns, b) and c) don't reinitialize to zero after each row, also

Spoiler
sum.those.rows.png

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Matt-A.
Member

I suppose I could've used the nested for loops, but this was easier. 

Spoiler
for_dailyclad.png

other than that, D

crossrulz
Knight of NI

D, but I wold have done the same as Matt-A.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
jwscs
Active Participant

definately the more general solution, but somehow numeric resonated with labviews Numeric Type for me


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
CataM
NI Employee (retired)

d)

nik35324
Member

D

chrisponte
Member

"D"

Vasuk
Member

D) But I`ve done this way - the constant is inside the loop. But the solution of Matt-A is the best.

 

Spoiler
2017-09-25_15-01-44.png

 

sankar06
Member

D

Happy to Wire
qubirt
Member

D

SercoSteveB
Active Participant

Answer: D.  Nice one all.

 

The CLAD2017 Preparation Guide seems to suggest that questions of this type (answer a requirement) will feature quite often in the exam and as a consequence in The Daily CLAD.    jwscs and Matt-A who have posted VIs (thanks and Kudos to all who posted a VI) have focused on the simplest solution which in real life is the way to go but I don't think that NI could ever have a CLAD question that asks the examinee to select the simplest (or fastest, or best etc.) solution. Identifying which VI is the simplest (or fastest, or best etc.) requires a level of knowledge outside of the CLAD and is open to all sorts of interpretation/personal preference from the examinee.  I think you are much more likely to see questions with answer options that are all functionally similar where the idea is that you work through each answer option to identify the one that is correct.

istan0227
Member

D