Thinking of playing Powerball now that the jackpot is so high? Test the odds using this depressing Powerball Simulator.

I wanted to generate some "jackpot" winning numbers using this method.

You can create a new form application and run it if you have a C# IDE laying around.

http://imgur.com/PYYgoeb

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Powerball
{
    public partial class Form1 : Form
    {
        private Random rand = new Random();
        private Task win;
        private int[] yours;
        private int[] theirs;
        private int closest = 0;
        private int tries = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            yours = new int[6];
            theirs = new int[6];
            win = Task.Run(() => play() );
        }

        private void play()
        {
            while (true)
            {
                generateNumbers();
                if (checkNumbers())
                {
                    MessageBox.Show("Yay!");
                    return;
                }
            }
        }

        private void generateNumbers()
        {
            for (int x = 0; x < 5; x++)
            {
                yours[x] = getNumber(yours);
                theirs[x] = getNumber(theirs);
            }

            yours[5] = 99;
            theirs[5] = 99;

            Array.Sort(yours);
            Array.Sort(theirs);

            yours[5] = rand.Next(1, 36);
            theirs[5] = rand.Next(1, 36);

            //////////////////////////////////////////////////////////////////////////////////
            //You can create the following text boxes and uncomment this code to see results
            //////////////////////////////////////////////////////////////////////////////////
            /*n1.Text = yours[0].ToString();
            n2.Text = yours[1].ToString();
            n3.Text = yours[2].ToString();
            n4.Text = yours[3].ToString();
            n5.Text = yours[4].ToString();
            p1.Text = yours[5].ToString();
            c1.Text = theirs[0].ToString();
            c2.Text = theirs[1].ToString();
            c3.Text = theirs[2].ToString();
            c4.Text = theirs[3].ToString();
            c5.Text = theirs[4].ToString();
            p2.Text = theirs[5].ToString();*/
        }

        private bool checkNumbers()
        {
            int close = 0;
            if (yours[0] == theirs[0])
            {
                close = 1;
                if (yours[1] == theirs[1])
                {
                    close = 2;
                    if (yours[2] == theirs[2])
                    {
                        close = 3;
                        if (yours[3] == theirs[3])
                        {
                            close = 4;
                            if (yours[4] == theirs[4])
                            {
                                close = 5;
                                MessageBox.Show("1 Million");
                                MessageBox.Show(String.Format("{0}-{1}-{2}-{3}-{4}-{5}", yours[0], yours[1], yours[2], yours[3], yours[4], yours[5]));
                                if (yours[5] == theirs[5])
                                {
                                    close = 6;
                                    closest = 6;
                                    this.Text = "JACKPOT!";
                                    MessageBox.Show("JACKPOT!");
                                    MessageBox.Show(String.Format("{0}-{1}-{2}-{3}-{4}-{5}", yours[0], yours[1], yours[2], yours[3], yours[4], yours[5]));
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
            if (close > closest)
                closest = close;
            tries++;
            this.Text = tries + " - " + closest;
            return false;
        }

        private int getNumber(int[] current)
        {
            int t = 0;
            bool unique;
            do
            {
                unique = true;
                t = rand.Next(1, 60);
                for (int x = 0; x < current.Length; x++)
                {
                    if (t == current[x])
                    {
                        unique = false;
                        break;
                    }
                }
            } while (!unique);
            return t;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

        }

        private void Form1_Click(object sender, EventArgs e)
        {
            this.Focus();
        }
    }
}
/r/InternetIsBeautiful Thread Link - powerballsim.appspot.com