From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory usage of an array

Use a 2D I8 array with 4 rows and 4 columns. The 16 „playing cards“ are labeled by the numbers 1, 2,…,8. The array shall be initialized by 0 („no value assigned yet)

 

Implement the following SubVIs:

SubVI  init: Initialization of the „playing cards“. Every n  {1, 2,…, 8} shall be placed at exactly two different random locations of the array

 

input: 2D array initialized by 0

output: 2D array with randomly distributed Playing cards

init shall call SubVI placeNumber for every n  {1, 2,…, 8} twice.

 

SubVI placeNumber:

Input: 2D array, number n  {1, 2,…, 8}

Output: 2D array, number n placed at a random, free location

 

Use SubVI set:

Input:  2D array, two distinct positions (i1,j1), (i2,j2) of cards. 

Output :  numbers for both positions. A negative value indicates that the card was already removed. In this case, the move has to be repeated

 

move shall use SubVI get:

Input: 2D array, position (i,j)

Output : number for positionen (i,j) („uncovered playing card“). A negative value indicates a card that is no longer available

 

Note : please find the attached Working file and kindly help me to solve the Sub VI's 

 

Regards,

Muthukumar

 

 

0 Kudos
Message 1 of 8
(2,468 Views)

Are you asking a question?

 

Or just showing us your homework assignment?

 

What does this have to do with "Memory usage of an array"?

0 Kudos
Message 2 of 8
(2,439 Views)

Hello,

 

Thank you So much for replying . Actually i am new to Labview so the subject may differ.

 

But i am asking the question i have done the first SUB VI part that is what i have attached . So kindly help me to do the other Sub VI

 

Note: i have attached the PDF in that PDF if we drag down we will get question no A3 . that is the question i need to solve

 

Thanks,

Muthukumar  

0 Kudos
Message 3 of 8
(2,430 Views)

Sometimes BD Real Estate is worth more memory than the array size (easy enough with blue wires)

Postage stampPostage stamp

 

Your BD is too big and the While loop is not guaranteed to exit, you need a timeout!


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 8
(2,428 Views)

Jeff, your code does not guarantee that each card exists exactly twice. Here's what I would do.

 

4x4Cards.png

 

Still, the instructions require the convoluted use of subVIs and to generate the array in steps by trial and error, so this cannot be used anyway. 😄

0 Kudos
Message 5 of 8
(2,417 Views)

@Jocker005 wrote:

 

Thank you So much for replying . Actually i am new to Labview so the subject may differ.

 

 


The problem is called "Memory" because it tries to simulate a 4x4 version of the well known memory game

 


@Jocker005 wrote: 

But i am asking the question i have done the first SUB VI part that is what i have attached . So kindly help me to do the other Sub VI

 


You already have a version that potentially solves(?) (I have not tested) the problem with flat code. It is NOT a subVI and you don't have any connectors assigned.

 

Now you are required to create a subVI that takes a number and a 2D array as input and returns the 2D array with the number placed on a remaining empty (containing zero) field.

 

All you need is initialze a 4x4 array with zeroes and call it twice for each number  1..8. Since the 2D array completes incrementally it needs to be kept in a shift register for the duration of the game. You know about shift registers, because you already used them in your code.

 

(Note that the instructions have a mistake because the input to "place number" can also contain zero (not just {1..8} as written) until all tiles are placed.)

 

So, your init VI Calls "place number" 16 times. After that you create the remaining VIs to play, etc. operating on the 2D array as required.

 


@Jocker005 wrote:

 

Note: i have attached the PDF in that PDF if we drag down we will get question no A3 . that is the question i need to solve

 


Obviously, this is a course and you would not have to solve this unless you learned all required techniques in class. So go through your lecture notes. There are also plenty of online tutorials. The forum is a good place to ask questions and we will make sure to point your nose in the right direction if you run into a wall, but we will not write you a turnkey solution, of course. So please continue to write code and whenever you run into a problem, ask specific questions. We are here to help. 😄

0 Kudos
Message 6 of 8
(2,412 Views)

@altenbach wrote:

Jeff, your code does not guarantee that each card exists exactly twice. Here's what I would do.

 

4x4Cards.png

 

Still, the instructions require the convoluted use of subVIs and to generate the array in steps by trial and error, so this cannot be used anyway. 😄


Use Riffled Index ! simpler!


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(2,388 Views)

@JÞB wrote:


Use Riffled Index ! simpler!


No, then you would get numbers [1.. 16] once each instead of [1 ..8] twice each.

 

(If you use the riffled index, you would need to e.g. add a Q&R and continue with the remainder, for example. More code!)

0 Kudos
Message 8 of 8
(2,382 Views)