Need help with keycard generator

Hi everyone,

I got the assignement to write a program which generates hole patterns for keycards, however, they have to differ as much as possible. Problem is I don't really have an idea on how to implement said task in C++. I thought about using two 2-dimensional arrays, one for the last generated pattern and one for the current one so I can compare them, but then I'd let out all the other patterns created prior to these two.

Could anybody point me in the right direction on how to solve this problem?
I don't need any code (luckily capable of doing that myself) just the general idea how you'd implement this :) .
Last edited on
The simpliest idea would be this:

Assuming that the key pattern is alphanumerical.
Using a queue: Push the 36 values randomized -> Pop the key size -> Push the key size values randomized.
Thank you very much for your answer, I thought about something similar too, but I won't have any way to make the differ as much as I want as it is using randomization. Anyways, going to try that right now, maybe I can expand it to somehow "notice" consimilar cards.


BTW:
Assuming that the key pattern is alphanumerical.


I actually didn't explain it, but it should only consist of +'s and O's like this:
1
2
3
4
+++O+
+O+O+
OOOO+
++OO+


but that shouldn't be too much of a problem, as it'll work as well.
Then you may use indexes in the queue. Each index stands for a pattern.

It would simplify the task because you need to randomize it only once the beginning and then just use push/pop.

But you might consider to randomize the queue again after a certain count to avoid that the order is always the same.
Last edited on
Thanks again, your advice really helped a lot!
Topic archived. No new replies allowed.