0

I have been working on a project where I have to create a grid. Inside the grid are 19 rows, with each n-amount of cells. Every cell has an alphabetical value that is hidden.

I want to show a number inside some cells, but there are some conditions that have to be met before I can show that number.

  • Every row has to have at least 1 number shown.
  • Every number has to appear on at least 2 different rows.
  • Every number is assigned an alphabetical value. (e.g. 1 = 'B', 2 = 'D', 3 = 'Z', etc...), those values are hidden, but they have to be the same for every number (e.g. an 'A' which has the value of 4, can not have the value of 8 on a different row).

It would have look a little bit like this: a grid with numbers randomly placed inside of it

I am really struggling to find a solution. I have found ways link different numbers to different letters, I can place them inside the grid, but I can't randomly remove them, as then there will be a change that a number will only appear once.

I hope this is somewhat clear what I am trying to achieve and if someone can help giving me a direction with how to proceed, that would be absolutely grand.

Btw: this is for a hobby project, not a school assignment.

  • 1
    Please visit the [help], take the [tour] to see what and [ask]. If you get stuck, post a [mcve] of your attempt, noting input and expected output using the [\[<>\]](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Jul 22 '22 at 18:56
  • I do not understand what the alphabetical rule has to do with anything, or why your example has each row being of different length. As it stands it seems like straightforward random number generation / retry if not all conditions were met. But I strongly suspect that there are key requirements that you didn't give us. – btilly Jul 22 '22 at 20:59
  • Well, each row is a word and the user has to guess the word, hence the different lengths. The numbers in the cells represent a hint letter of the word. I tried the brute force random generation way, but it feels very inelegant and inefficient. – Johannes Schreurs Jul 22 '22 at 22:00

0 Answers0