Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Caller Card

eHag-FRU edited this page Sep 12, 2021 · 3 revisions

Description

The master card that keeps track of all the called numbers for the round.


Card construction

The card is a 2D matrix, with five rows and 21 columns.

      B | - - - - - - - - - - - - - - - | 
      I | - - - - - - - - - - - - - - - | 
      N | - - - - - - - - - - - - - - - | 
      G | - - - - - - - - - - - - - - - | 
      O | - - - - - - - - - - - - - - - | 

Once a number is added to the card, it will look something like what is pictured below.

      B| -  -  -  -  -  -  -  -  -  -  -  -  -  -  |
      I| -  -  -  - 21 -  -  -  -  -  -  -  -  -  |
      N| -  -  -  -  -  -  -  -  -  -  -  -  -  -  |
      G| -  -  -  -  -  -  -  -  -  -  -  -  -  -  |
      O| -  -  -  -  -  -  -  -  -  -  -  -  -  -  |

This continues until the card is wiped and restarted.


Sorting Method

To sort the numbers some comparison logic is used to determine what "letter" (row) the number falls under.

The B row

If the number is less than or equal to 15 then the number is in the B row.

  card[0][number - 1] = number;

The position in the row is determined by taking the number and subtracting one from it. This is due to the first position of an array being numbered zero.

The I Row

If the number is between 16 and 30 then the number is in the I row.

 card[1][number - (cardLength + 1)] = number;

The position in the row is determined by taking the number and subtracting the length of the card (15) plus one. For example, if the next number is 16, it is determined it is in the I row. Next, the position within the I row is 16 - (15 + 1). This leaves the position as zero, which is the first position of that row (card[1][0]).

The N Row

If the number is between 31 and 45 then the number is in the N row.

 card[2][number - (cardLength * 2)] = number;

The position in the row is determined by taking the number and subtracting the product of the length of the card (15) multiplied by two. For example, if the next number is 31, it is determined it is in the N row. Next, the position within the N row is 31 - (15 * 2). This leaves the position as zero, which is the first position of that row (card[2][0]).

The G Row

If the number is between 46 and 60 then the number is in the G row.

  card[3][number - (cardLength * 3)] = number;

The position in the row is determined by taking the number and subtracting the product of the length of the card (15) multiplied by three. For example, if the next number is 46, it is determined it is in the G row. Next, the position within the N row is 46 - (15 * 3). This leaves the position as zero, which is the first position of that row (card[3][0]).

The O Row

If the number is between 61 and 75 then the number is in the I row

 card[4][number - (cardLength * 4)] = number;

The position in the row is determined by taking the number and subtracting the product of the length of the card (15) multiplied by four. For example, if the next number is 61, it is determined it is in the G row. Next, the position within the G row is 61 - (15 * 4). This leaves the position as zero, which is the first position of that row (card[4][0]).


While this method may seem inefficient, this only has to deal with 75 numbers. That is a fraction of what most major applications have to deal with (thousands to millions of calculations). Due to the small size, this method is still quick, especially for the use case of this application.

Clone this wiki locally