Jump to content

Random, Non-Repeating Variable Numbers


Recommended Posts

We have a customer looking for Bingo cards.  Each card has 24 spaces, which the customer would like printed with random numbers from 1-75.  BUT . . .  numbers cannot repeat in any of the 24 spaces per card, and we have to produce 200 unique cards.

I did a search on the forum, but can't get my head around how to make this happen.  Thought it may be a combo of data creation, plus FP trickery, but I just can't come to an anwer.  Any creative ideas for this one?

Thanks!

Link to comment
Share on other sites

So, searching for "FusionPro bingo card job" on Google returns this as the top hit, which is a sample job that seems to do exactly what you want.

Though there is a more efficient way to accomplish this, especially with newer versions of FusionPro.

As to the more general question in the title of this thread, again, if you Google something like "JavaScript non repeating random numbers", there are a lot of threads on Stack Overflow and different sites with various solutions.  I would just do this:

var result = [];
while (result.length < 24)
{
    var num = Math.floor(Math.random() * 75) + 1;
    if (result.indexOf(num) < 0)
        result.push(num);
}
return result;

And in FP 13, you could modify this slightly as a table data rule:

var nums = [];
while (nums.length < 24)
{
    var num = Math.floor(Math.random() * 75) + 1;
    if (nums.indexOf(num) < 0)
        nums.push(num);
}

nums.splice(12, 0, "FREE");

var result = [];
for (var i = 0; i < nums.length; i += 5)
    result.push(nums.slice(i, i + 5));

return result;

Then you can the "Table Style" rule, and then create the "Table - from data rule" rule, with the rule above as the data rule and the Table Style rule as the style, and add columns to get five of them.  Then you can just tweak the properties in the style rule to get the output you want.

Link to comment
Share on other sites

Thanks Dan.  Didn't even think to include 'bingo card' in our search.  We are using the newest version, but have to admit this JS is beyond our shop's skill sets.  We're using the FP editor to create our rules for basic variable text, mostly.  We're on a subscription, so can update from 12 to the newest version, if that would make any difference for this.

I'll look further into the 'bingo' responses, and try to make heads or tails with this code.  Appreciate your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...