Jump to content

75 logos randomly placed into 25 spaces on a bingo card.


jonjaynes

Recommended Posts

I'm looking to create a rule that takes 75 images and randomly places them on 25 spots with no duplicates. 

Ideally, 1-15 random for column 1... 15-30 column 2 etc. like a bingo card.

I've started but having issues.

Any ideas?

 

// Example array of 75 logos
const logos = Array.from({ length: 75 }, (_, i) => `Logo ${i + 1}`);

// Function to generate bingo cards
function generateBingoCards(numCards, logos) {
    const cards = [];

    for (let i = 0; i < numCards; i++) {
        // Shuffle logos and select the first 25
        const shuffledLogos = shuffleArray([...logos]);
        const bingoCard = shuffledLogos.slice(0, 25);
        cards.push(bingoCard);
    }

    return cards;
}

// Function to shuffle an array
function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]]; // Swap elements
    }
    return array;
}

// Generate 200 unique bingo cards
const bingoCards = generateBingoCards(200, logos);

// Example: Log the first bingo card
console.log(bingoCards[0]);
 

Link to comment
Share on other sites

Thanks for the question.  However, it's best to search the forum first before starting a new thread.  Bingo cards are a FAQ here.  A search for "bingo" returns a lot of posts, many of which reference this:

That creates a five-column table, which I think is still the best solution.  It's placing text, but changing it to place your graphics shouldn't be hard.

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...