npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tambola-generator

v1.0.0

Published

A library for generating tambola tickets and calling the draw

Downloads

127

Readme

tambola-generator

A library for generating tambola tickets and the draw sequence Home / demo page

Installation

We use npm for dependency management, run

npm install --save tambola-generator

Usage

In your NodeJS application, require the module:

var tambola = require('tambola-generator');

To get tickets, use the getTickets(count) method:

tambola.getTickets(100) //This generates 100 tambola tickets

To get the draw sequence, use the getDrawSequence() method:

tambola.getDrawSequence() //Returns numbers 1-90 scrambled

JSON

// Tickets array
[
  [
    [0,18,23,40,48,0,0,73,0],
    [5,0,0,0,42,52,0,80,83],
    [0,20,0,0,49,58,65,0,85]
  ],
  [
    [10,0,21,34,0,0,65,0,83],
    [0,11,0,36,41,0,62,0,85],
    [0,19,26,37,43,0,67,0,0]
  ]
]
// Draw Sequence
[72,65,47,89,42,4,61,84,36,22,37,18,9,27,
12,71,46,15,30,55,17,3,56,25,68,80,43,26,
50,39,53,38,60,31,28,11,8,62,49,79,51,35,
14,67,45,41,40,5,44,34,73,32,86,69,70,48,
21,33,83,13,54,77,78,90,29,6,52,59,58,66,
76,1,10,24,19,64,85,7,74,2,16,63,88,23,57
,87,81,82,20,75]

Rules

A ticket consists of a random distribution of 15 numbers between 1-90 in a 3x9 grid

  • RULE #1 - Each row cannot have more than 5 numbers
  • RULE #2 - Each column is assigned a range of numbers only: 1-10 can appear only in column 1, 11-20 can appear only in column 2, 81-90 can appear only in column 9
  • RULE #3 - In a specific column, numbers must be arranged in ascending order from top to bottom
  • RULE #4 - Each column must have at least 1 number

Algorithm

  • Generate a grouped list of numbers from 1-90, grouped by every 10th number. Each group corresponds to a column of the ticket.
  • Generate a 2D array of 3 rows and 9 columns filled with 0s.
  • For each column of the ticket, randomly choose a row and number from the grouped list above.
    • If the row is not already full (<5) and the number in that location is 0,
      • Insert the chosen number
      • Delete the chosen number from the grouped list
  • Recursively, loop through all rows and colums of the ticket:
    • Generate a random chance value as a boolean.
    • If the row is not already full (<5) and the column is not already full (<3) and the random chance is true and the value at the location is 0
      • Insert the chosen number
      • Delete the chosen number from the grouped list