예제 #1
0
        private void tmrPizzazNumbers_Tick(object sender, EventArgs e) // displays random numbers
        {
            Random rnd = new Random();

            lblFirstNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblFirstNumber.Text = randomLetter;
            }
            lblSecondNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter         = RandomLetter.GetLetter().ToString();
                lblSecondNumber.Text = randomLetter;
            }
            lblThirdNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblThirdNumber.Text = randomLetter;
            }
            lblFourthNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter         = RandomLetter.GetLetter().ToString();
                lblFourthNumber.Text = randomLetter;
            }
            lblFifthNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblFifthNumber.Text = randomLetter;
            }
        }
예제 #2
0
        public static void Setup()
        {
            Random random = new Random();

            // Destroyer 1 Random Coordinates

            char playersCoordinates1 = RandomLetter.GetLetter(0, 3);
            int  playersCoordinates2 = random.Next(2, 7);

            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 - 1));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 + 1));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 + 2));

            // Battleship Random Coordinates

            char playersCoordinates3 = RandomLetter.GetLetter(4, 6);
            int  playersCoordinates4 = random.Next(2, 7);

            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 - 2));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 - 1));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 + 1));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 + 2));

            // // Destroyer 2 Random Coordinates

            var playersCoordinates5 = RandomLetter.GetLetter(6, 9);
            var playersCoordinates6 = random.Next(2, 7);

            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 - 1));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 + 1));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 + 2));
        }
예제 #3
0
            /// GENERATES A RANDOM STRING OF LETTERS AND NUMBERS.
            /// LETTERS CAN BE RANDOMLY CAPITAL OR SMALL. RETURNS THERANDOMLY GENERATED KEY</returns>
            public string Generate()
            {
                int    i_key;
                float  Random1;
                short  arrIndex;
                var    sb = new StringBuilder();
                string RandomLetter;

                /// CONVERT LettersArray & NumbersArray TO CHARACTR ARRAYS
                LettersArray = Key_Letters.ToCharArray();
                NumbersArray = Key_Numbers.ToCharArray();
                var loopTo = Key_Chars;

                for (i_key = 1; i_key <= loopTo; i_key++)
                {
                    /// START THE CLOCK    - LAITH - 27/07/2005 18:01:18 -
                    VBMath.Randomize();
                    Random1  = VBMath.Rnd();
                    arrIndex = -1;
                    /// IF THE VALUE IS AN EVEN NUMBER WE GENERATE A LETTER,
                    /// OTHERWISE WE GENERATE A NUMBER
                    /// THE NUMBER '111' WAS RANDOMLY CHOSEN. ANY NUMBER
                    /// WILL DO, WE JUST NEED TO BRING THE VALUE
                    /// ABOVE '0'
                    if (Conversions.ToInteger(Random1 * 111) % 2 == 0)
                    {
                        /// GENERATE A RANDOM INDEX IN THE LETTERS
                        /// CHARACTER ARRAY
                        while (arrIndex < 0)
                        {
                            arrIndex = Convert.ToInt16(LettersArray.GetUpperBound(0) * Random1);
                        }
                        RandomLetter = Conversions.ToString(LettersArray[arrIndex]);
                        /// CREATE ANOTHER RANDOM NUMBER. IF IT IS ODD,
                        /// WE CAPITALIZE THE LETTER
                        if (Conversions.ToInteger(arrIndex * Random1 * 99) % 2 != 0)
                        {
                            RandomLetter = LettersArray[arrIndex].ToString();
                            RandomLetter = RandomLetter.ToUpper();
                        }

                        sb.Append(RandomLetter);
                    }
                    else
                    {
                        /// GENERATE A RANDOM INDEX IN THE NUMBERS
                        /// CHARACTER ARRAY
                        while (arrIndex < 0)
                        {
                            arrIndex = Convert.ToInt16(NumbersArray.GetUpperBound(0) * Random1);
                        }
                        sb.Append(NumbersArray[arrIndex]);
                    }
                }

                return(sb.ToString());
            }
예제 #4
0
    // Start is called before the first frame update
    void Start()
    {
        numbersLeft = numberOfLetters;
        characters  = new List <char>();
        while (numberOfLetters > 0)
        {
            characters.Add(RandomLetter.GetLetter());
            numberOfLetters--;
        }

        projector.text = characters[numberOfLetters].ToString().ToUpper();
    }
예제 #5
0
        public void BinaryMultipleTest()
        {
            string path  = @"../../words.txt";
            var    lines = File.ReadLines(path).ToList();

            BinarySearch search = new BinarySearch();

            for (int i = 0; i < 10001; i++)
            {
                var searchItem = RandomLetter.GetLetter();
                search.Binary(searchItem, lines);
                Assert.IsNotNull(search);
            }
        }
예제 #6
0
        public void SearchMultipleLinearTest()
        {
            string path  = @"../../words.txt";
            var    lines = File.ReadLines(path).ToList();

            LinearSearch search = new LinearSearch();

            for (int i = 0; i < 10001; i++)
            {
                var searchItem = RandomLetter.GetLetter();
                search.SearchLinear(searchItem, lines);
            }
            Assert.IsNotNull(search);
        }
예제 #7
0
        static public void part2()
        {
            MD5 md5   = MD5.Create();
            int index = 0;

            char[] password = new char[8] {
                '-', '-', '-', '-', '-', '-', '-', '-'
            };
            while (true)
            {
                byte[]        inputBytes = Encoding.ASCII.GetBytes("abbhdwsy" + index);
                byte[]        hash       = md5.ComputeHash(inputBytes);
                StringBuilder sb         = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }
                string s = sb.ToString();
                if (s.Substring(0, 5) == "00000")
                {
                    int pos;
                    if (Int32.TryParse(s[5].ToString(), out pos) && pos < 8 && password[pos] == '-')
                    {
                        password[pos] = s[6];
                    }
                }
                if (index % 10000 == 0)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if (password[i] != '-')
                        {
                            Console.Write(password[i]);
                        }
                        else
                        {
                            Console.Write(RandomLetter.GetLetter());
                        }
                    }
                    Console.Write("\r");
                }
                index++;
            }
        }
예제 #8
0
        public void startGame()
        {
            timer1.Restart();
            timer2.Start();
            round++;
            lblRound.Text     = "Runde: " + round;
            start_Buchstabe   = RandomLetter.GetLetter();
            lblBuchstabe.Text = "Buchstabe: " + Char.ToString(start_Buchstabe);

            txtStart.Enabled = false;
            txtEnd.Enabled   = false;
            Stats.Enabled    = false;

            txtFluss.Enabled = true;
            txtLand.Enabled  = true;
            txtStadt.Enabled = true;
            txtStadt.Text    = "";
            txtLand.Text     = "";
            txtFluss.Text    = "";
        }
예제 #9
0
        static public void part1()
        {
            MD5         md5 = MD5.Create();
            int         index = 0, count = 0;
            List <char> password = new List <char>();

            while (true)
            {
                byte[]        inputBytes = Encoding.ASCII.GetBytes("abbhdwsy" + index);
                byte[]        hash       = md5.ComputeHash(inputBytes);
                StringBuilder sb         = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }
                string s = sb.ToString();
                if (s.Substring(0, 5) == "00000")
                {
                    count++;
                    password.Add(s[5]);
                }

                if (index % 10000 == 0)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if (i < count)
                        {
                            Console.Write(password[i]);
                        }
                        else
                        {
                            Console.Write(RandomLetter.GetLetter());
                        }
                    }
                    Console.Write("\r");
                }
                index++;
            }
        }