using System;
//ISSUE cINPUT1INT and CINPUT2INT are 0!
namespace testconsole
{
internal class Program
{
int number = 1234;
public int[] list = new int[9877];
public int cInput2int, digit1, digit2, digit3, digit4, cInput1int, randomArrayItem, firstOne, wrong, correct;
bool value = false;
public static bool win_;
Random rnd = new Random();
static void Main(string[] args)
{
Program some = new Program();
some.askForNumber();
some.createArray();
some.avoidImposible();
do
{
some.selectArrayItem();
some.checkForCorrectness();
foreach (int i in some.list)
{
if (some.list[i] != 0)
{
some.firstOne = some.list[some.randomArrayItem];
some.value = some.compareNumbers(some.firstOne, i, some.cInput1int, some.cInput2int);
if (some.value == false)
{
if (some.list[i] != 0)
{
if (some.list[i] == 1234)
{
// some.cinput's are 0 for some reason
Console.WriteLine("Eliminated 1234 because: " + "some.firstone: " + some.firstOne + " i: " + i + " some.cInput1int: " + some.cInput1int + " some.cinput2int: " + some.cInput2int);
Console.WriteLine("YOU ARE THE ONE MESSED UP!");
Console.ReadKey();
Environment.Exit(420);
}
Console.WriteLine("eliminating " + some.list[i]);
some.list[i] = 0;
}
}
}
}
} while (win_ is false);
}
public void createArray()
{
// Creates array that ranges from 1234-9876
do
{
list[number] = number;
number = number + 1;
} while (number < 9877);
}
public void avoidImposible()
{
foreach (int i in list)
{
if (list[i] != 0)
{
digit1 = list[i] / 1000;
digit2 = list[i] - (digit1 * 1000);
digit2 = digit2 / 100;
digit3 = list[i] - (digit2 * 100 + digit1 * 1000);
digit3 = digit3 / 10;
digit4 = list[i] - (digit2 * 100 + digit1 * 1000 + digit3 * 10);
if (digit1 == 0 || digit2 == 0 || digit3 == 0 || digit4 == 0)
{
list[i] = 0;
}
if (digit1 == digit2 || digit1 == digit3 || digit1 == digit4 || digit2 == digit3 || digit2 == digit4 || digit3 == digit4)
{
list[i] = 0;
}
}
}
}
public void askForNumber()
{
Console.WriteLine("Enter your 4 digit number that does not contain 0's or repeating digits: ");
int playerNumber = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter in '{possitive number},{negative number}' form: ");
}
public void selectArrayItem()
{
randomArrayItem = 1257;
//randomArrayItem = rnd.Next(0, list.Length);
if (list[randomArrayItem] != 0)
{
Console.WriteLine(list[randomArrayItem]);
}
else
{
selectArrayItem();
}
}
public void checkForCorrectness()
{
//here cInput's are normal
string correctnessInput = Console.ReadLine();
string cInput1 = ToSplit(correctnessInput, 0);
string cInput2 = ToSplit(correctnessInput, 1);
Console.WriteLine("cInput1: " + cInput1 + " cInput2: " + cInput2);
int cInput1int = Convert.ToInt32(cInput1);
int cInput2int = Convert.ToInt32(cInput2);
Console.WriteLine("cInput1int: " + cInput1int + " cInput2int: " + cInput2int);
}
string ToSplit(string a, int b)
{
return a.Split(',')[b];
}
bool compareNumbers(int a , int b, int otherCorrect, int otherWrong)
{
correct = 0;
wrong = 0;
//compares a to b and checks if otherCorrect and otherWrong is mathching gives true or false
//numberdigit is a. number2digit is b
//spliting a into 4 digits
int numberDigit1 = (a / 1000);
int numberDigit2 = (a - numberDigit1 * 1000) / 100;
int numberDigit3 = (a - numberDigit2 * 100 + numberDigit1 * 1000) / 10;
int numberDigit4 = (a - numberDigit2 * 100 + numberDigit1 * 1000 + numberDigit3 * 10);
//spliting b into 4 digits
int number2Digit1 = (b / 1000);
int number2Digit2 = (b - number2Digit1 * 1000) / 100;
int number2Digit3 = (b - number2Digit2 * 100 + number2Digit1 * 1000) / 10;
int number2Digit4 = (b - number2Digit2 * 100 + number2Digit1 * 1000 + number2Digit3 * 10);
if (numberDigit1 == number2Digit1)
{
correct++;
}
if (number2Digit1 == number2Digit2 || numberDigit1 == number2Digit3 || numberDigit1 == number2Digit4)
{
wrong++;
}
if (numberDigit2 == number2Digit2)
{
correct++;
}
if (numberDigit2 == number2Digit1 || numberDigit2 == number2Digit3 || numberDigit2 == number2Digit4)
{
wrong++;
}
if (numberDigit3 == number2Digit3)
{
correct++;
}
if (numberDigit3 == number2Digit1 || numberDigit3 == number2Digit2 || numberDigit3 == number2Digit4)
{
wrong++;
}
if (numberDigit4 == number2Digit4)
{
correct++;
}
if (numberDigit4 == number2Digit1 || numberDigit4 == number2Digit2 || numberDigit4 == number2Digit3)
{
wrong++;
}
Console.WriteLine("Corrects: " + correct + " " + otherCorrect + " " + wrong + " " + otherWrong);
if (correct == otherCorrect && wrong == otherWrong)
{
Console.WriteLine("mathces");
return true;
}
else
{
Console.WriteLine("doesn't match");
return false;
}
}
public void printArray()
{
foreach (int i in list)
{
Console.WriteLine(list[i]);
}
}
}
}