Housie/Bingo/Tambola ticket generator and number generator mobile apps

Over the weekend, I dabbled into Flutter – a cross platform app development framework. The purpose was to learn Flutter and my preferred way of learning any new programming language or framework is to use in a project or app.

So I ported my Housie ticket generator and number generator to mobile apps for Android and iPhone. I built the app and deployed it on the Google Play Store and Apple App Store.

Building a Housie/Bingo/Tambola Ticket Generator

I had created a Housie/Bingo/Tambola number generator some months back. Now I have also created a Housie/Bingo/Tambola Ticket Generator.

Housie is a group game. It is played when a bunch of friends and family have gathered. Everyone gets a Housie ticket and one person calls out numbers. The host picks up a number token and calls it out, those who have the number on their ticket mark it. There are prizes for the first person to mark 5 numbers on their ticket, for being the first one to mark all numbers on the top, middle and bottom row and then finally a full house – marking all numbers on the ticket.

Creating the Housie number generator was easy because it was only about generating a random number between 1-90.

Creating the ticket was a bit more complex. A Housie ticket has a set of rules

  • It has 3 rows and 9 columns.
  • Column 1 has numbers from 1-9, column 2 has from 21-29, column 3 has 31-39 and so on. Last column has numbers from 81-90.
  • Each row has 5 numbers, 15 numbers total on a ticket.
  • Each column can have 1 to 3 numbers.
  • Any column can’t be blank, any row can’t be blank.

This is what the House tickets look like

At first I thought it would be easy to generate. I would just have to generate 3 random numbers from each column falling between the minimum and maximum numbers for that column. But that would generate 27 numbers. I need only 15. Picking 15 random numbers from those 27 had a chance of one of tens (one column) not being picked at all.

I then decided to generate between 1 and 3 random numbers for each column. Again, it would not give me exact 15 numbers. It could generate any number between 9 and 27. So I put it in a loop to keep generating numbers till the final count of the numbers generated was 15. This would mean an uncertain number of iterations.

It gave me 15 numbers, but placing them was an issue.

Say it generated these numbers


I have numbers for each column but how do I place them? Take first column. It has 1,3. I can place it as 1,3,blank or 1,blank,3 or blank,1,3. I could have randomize that placement but then I won’t be sure if I will get exactly 5 numbers in each row.

This is where the complexity comes in. The numbers have to be distributed such that each row has exactly 5 numbers. I concluded that if I generated numbers first and then tried to place them, I would have to do multiple passes to distribute them evenly. It would take multiple loops and would be very complicated.

So I chucked the idea of generating numbers first. I decided to mark the cells which will have numbers.

I created an array of 9 elements containing zeros and ones. It should have 5 ones. Because each row has 5 numbers. Zeros are blank cells with no numbers in them. After generating this array I counted the number of ones. If the count of ones is not 5, I recreated the array till I got an array with 5 ones. This gave me my one row. I repeated the process two more times and I had 3 rows, each having 5 ones and 4 zeros.

for (r = 0; r < 3; r++) {
    var row = [];
    var onecount = 0;
    while (onecount != 5) {
	onecount = 0;
	row = [];
	for (c = 0; c < 9; c++) {
	    n = getZeroOne();
	    if (n == 1) onecount++;

Now I put the 3 arrays into a larger array and checked if each column had at least 1 one. If one column was entirely blank, I would regenerate all the 3 arrays again.

for (c = 0; c < 9; c++) {
    if (rows[0][c] == 1 || rows[1][c] == 1 || rows[2][c] == 1) {
	columnok = true;
    else {
	columnok = false;
	//$("#notes").append("Not OK<br>");

There is a scope for optimization here, I will come to it later.

So finally I had a grid of zeros and ones where each row had exactly five numbers and each column had at least one number.

I replaced all zeros with blank. Now I just had to replace ones with numbers. I iterated from column 1 to 9, got the count of ones in that column. Say there were 2 ones in the column, I generated two random numbers between the minimum and maximum of that column and replaced the ones with those numbers. I had my final grid ready.

for (c = 0; c < 9; c++) {
    //get count of 1s in this column
    var nums = rows[0][c] + rows[1][c] + rows[2][c];
    var min = c * 10 + 1;
    var max = min + 8;
    if (c == 8) max = 90;
    var tmp = [];
    for (n = min; n <= max; n++) {
    var arr = getRandom(tmp, nums).sort().reverse();
    for (r = 0; r < 3; r++) {
        if (rows[r][c] == 1) {
	    rows[r][c] = arr.pop();

I then added some bells and whistles like a random ticket colour every time you generate a new ticket. Added a confetti animation using confetti.js for marking first 5 numbers, and marking all the numbers in each of the rows. I also added a pure CSS shake animation on the ticket table.

Marking was just about adding a class on click on the TD. Instead of doing a simple jQuery toggleClass, I added a confirmation prompt for unmarking a number to prevent accidental unmarking.


There is scope for optimizing and reducing the number of iterations in number generation.

As I mentioned above, I generate the row array repeatedly till I get exact 5 ones. Instead, I can start with a fixed array of 5 ones and 4 zeros and then randomise (shuffle) that array, this will eliminate the need for generating the array again and again.

I also regenerate all the 3 row arrays repeatedly till I get a grid where each column has at least 1 one. This can also be optimized. After I have generated first two rows, I can check which column is still blank and put a 1 in the bottom cell of that column. I will again have to iterate through the last row to see if has 5 ones and if there are less than 5, I will have to put missing ones in some random blank cells in the bottom row.

Check out the Housie/Bingo/Tambola Ticket Generator at https://yash.info/bingo-ticket.htm

Bingo/Housie/Tambola Ticket Generator

Check out the Housie/Bingo/Tombola Ticket Generator created by me


Now for playing Housie with your friends and family you don’t need physical tickets and pens to mark the numbers. Everyone can have a digital ticket on their phone and mark the numbers just by tapping it.

It also show a cool animation when you mark your first 5 numbers and any of the rows.

Use it in conjunction with my earlier Housie Number Generator


Citizenship Amendment Act – what’s wrong with it?

The act is meant to give citizenship to persecuted minorities from Afghanistan, Pakistan and Bangladesh who have come to India before 2014.

The good

It is good that India is giving shelter and citizenship to persecuted minorities from neighbouring countries. That’s the right thing to do.

The bad

It does so on the basis of religion of the refugees. This is not good.

Why is giving citizenship on the basis of religion not a good thing?

Because India is a secular nation. Indian laws treat everyone equally irrespective of their religion. Once we start giving preference to people of certain religion and exclude others, we going down a slippery slop and setting a very wrong precedent.

How so?

CAA is to be followed by NRC – The National Register of Citizens. Everyone in India will be asked to prove their citizenship. How do you prove you are a citizen of India? The exact process will be laid out when NRC is implemented, but if we look at how it was done in Assam then it’s a problematic process.

It took 10 years and 1200 cores to implement NRC in Assam and in the end, no one was happy with it. More Hindus were not able to prove their citizenship than Muslims.

NRC, if and when implemented will mostly affect the poor. They are the ones who don’t have proper documents. If they can’t prove they are citizens, what happens to them? Enter CAA.

Under CAA, those who can’t provide adequate documents can still be counted as citizens if their religion is as per prescribed in CAA. Whom does it leave out? Muslims.

Amit Shah has gone on record and BJP has made it amply clear time and again that CAA is to be followed by NRC.

CAA+NRC is bad for the social fabric of the country.

Even CAA on it’s own is bad. Because it makes religion a basis of citizenship. This means India is a country for people of specific religions. This does not help a country in the long run. Just look at Pakistan.

In 1947, Pakistan was created as a separate country for Muslims. India, did not choose to be a country of Hindus. It adopted a secular constitution. (Thank Nehru, Ambedkar, Patel and other visionary leaders for that). Today, India is a flawed yet fledging democracy. Pakistan is an almost failed state.

Pakistan is controlled by the army via a puppet government. It’s economy is in doldrums and it is living on alms from US, China and wealthy Arabs. The country is rife with sectarian violence and terrorism. Religion has ruined the country.

With CAA, making religion the deciding factor in granting citizenships, we have taken the first step in becoming a mirror image of Pakistan.

Not good for the future of India.

We already know what happens when the government gives more importance to religious issues than economy, jobs and growth.

We are no longer debating the falling GDP growth rate, lack of jobs, poor quality of infrastructure and education. We are debating Ram mandir, citizenship laws, triple talaq, article 370 – all issues which have religion at its core.

If you are a BJP supporter, this is something for you to ponder over, what kind of India do you want for your children? A mirror image of Pakistan or a free, secular, inclusive India which treats everyone as equals regardless of their religion, caste, creed, language and gender?


Future: A world without jobs

It is future. Automation and robots have taken over all the routine jobs. There are hardly any jobs for humans to do. Machines dig the earth and extract minerals, they transport them to factories where other machines produce good for human consumption from them. Machines do the farming, process and cook the food. Humans only eat. Only a few humans are required to work. They design new machines, create new algorithms and supervise the machines. These jobs require very specific knowledge and high degree of skills, which are expensive to acquire. These humans command top dollar salaries. Rest of the human race is jobless. So how do they survive?

On government welfare. Most of things in life required for sustenance are free. Housing, food, healthcare, basic education, transportation – all paid for by the government. Where does government get money from? From taxes on corporations. Government is both a customer and service provider for corporations. Corporations are mighty profitable thanks to automation. Cost of production is very low and they don’t mind paying high taxes because those taxes eventually come back to them as sales revenue from the people.

What do people do? They mostly have fun, play augmented reality games and watch virtual reality movies and shows. Some people create works of art – poetry, music, plays, stories, paintings, sculptures. Humans do things that require random thinking because there’s one thing that computers can’t do is generate a truly random number.

Economy keeps chugging along by combined economic activity of machines producing goods and service of routine nature and humans producing good and services of random nature.

Mission Mangal is disappointing

Mission Mangal is a bad joke of a movie. A great movie could have been made about India’s stupendous achievement. But in a typical Bollywoodian fashion, it gets bogged down with unnecessary jingoism, heroism and melodrama. It’s such a shame! While the movie does have some moments that give you goose bumps, overall it’s a collection of scenes of half developed characters with ISRO in the background.
A monumental scientific endeavour like India’s first moon mission would have had its own thrilling moments which could definitely have been used to create the necessary drama for any “underdogs achieve great success” movie. But this movie instead tries to do too many things.

If anyone wants to see how to convert a real event into a great thrilling story – just watch Chernobyl or Sully or Everest. Mission Mangal is a wasted opportunity. How do you create thrill or suspense about a real event, the end result of which you already know? Watch Apollo 13.

I don’t understand why Indian movies shy away from using real characters. They invent every single character and give them emotional back stories. In the quest to add fictional elements to a real world event, our directors can’t resist the temptation of going full fictional to the extent that the real world event just becomes a backdrop. It becomes more like an alternative history movie rather than a movie based on true events. They would rather say at the beginning “this happened in an alternate universe”.

Yes, directors must take creative freedom and add fictional elements, otherwise it would be a documentary. But to what extent you do that is a call that a director has to take.

We went to Mars. On the first attempt. It’s an amazing feat. This movie fails to do justice to that.

Indian cricket has come a long way

I just watched an interview of Virat Kohli from World Cup. “We are not looking to entertain; we are looking at winning the game”. That explains a lot. I have watched a few games India has played this world cup. Many of them have been boring. Like a test match. You don’t see too many sixes being hit. But the Indian team is the only team so far that has not lost a game in this world cup.

Indian cricket team has come a long way from where it used to rely on individual performances of a Tendulkar or a Sehwag or a Kumble to win them a game. This is a side that works as a team. It has a definite plan. They have a plan for how to bowl to each opposition player to get them out. They have a plan while batting. Over by over.

Fitness. Virat Kohli runs between wickets at speed of 25 Kmph! I watched another of his video where he mentioned how he maintains a certain diet to be in top condition for the game. Gone are the days of portly cricketers who couldn’t run for their life. This Indian team actually looks like it’s made of professional athletes.

The bench strength of the Indian team is amazing. They lost a top batsman and a top bowler midway through the World Cup due to injuries and it has not made a difference in their performance on the field. This team hunts in a pack. When the batting doesn’t click, bowlers save the day. India has been the best fielding side this World Cup. Who would have thought?!

This Indian cricket team is so unlike other things Indian. There is an intent to win. It has skills and professionalism. They work well together. They plan meticulously and execute it superbly. How did we get here?

I believe the credit has to be given to BCCI and IPL. BCCI is a private business. The players are their products and the games they play is their business. It brings in the moolah. BCCI has invested in players, infrastructure and improved quality of the game. IPL for all its flaws has done wonders to improve the quality of Indian cricket. The increased competition has forced players to give it their best and stay in supreme condition to retain their place in the side.

Right now India are favourites to win the World Cup.

Quitting social media and learning Spanish

26 days ago, I deleted social media apps from my phone. Facebook, Twitter and LinkedIn. I kept Instagram and WhatsApp but I left all the groups on WhatsApp. Not that I was in many groups to begin with. But I still left whatever groups that I was in except parents’ group for my daughter’s school. That group is limited strictly to school and homework related stuff.

I also started learning Spanish on DuoLingo 26 days ago. The same day I deleted the social media accounts, I downloaded the DuoLingo app.

I came across a book called Ten Arguments for Deleting Your Social Media Accounts Right Now ironically on Twitter. I had witnessed social media was becoming toxic. I was an avid social media user. I would post multiple times a day on Facebook. I was outspoken in my political beliefs. I would unfollow people whose ideas I did not agree with. I found myself surrounded by like minded people. I was trapped in a bubble. I was hostile towards anyone having a differing point of view. It even affected some of my real-world relationships.

I was contemplating quitting social media. I had reduced my social media sharing a lot and I had become more of a consumer than creator of opinions on social media. Then I watched a TED talk called Quit social media by Dr. Cal Newport.

And I deleted all the social media apps. I did not delete the accounts outright. I would check them on desktop browser occasionally. It was tough initially for a couple of days. The urge to pick up your phone and see what’s new every few minutes is really strong. But it only lasted for a couple of days. The urge to visit Facebook even on browser reduced. And now I visit it may be once or twice a week. That too will reduce soon until the day I finally delete my account.

It’s been good so far.

Adios. Hasta luego.

Scroll to top