This commit is contained in:
Digi
2025-03-05 21:58:03 +01:00
parent 9be4cba137
commit 9969d17bcc
18 changed files with 236 additions and 54 deletions

View File

@@ -23,6 +23,10 @@ namespace Program
var dobasok = new List<int>();
var dontesek = new List<int>();
//d feladathoz
int pokermaxNum = 0;
//dobasok
var data = File.ReadAllText(path).Trim();
@@ -63,11 +67,17 @@ namespace Program
int jatekosCounter = 0;
List<int> dobasokFull = new List<int>();
List<int> dontesekFull = new List<int>();
for (int i = 0; i < dobasok.Count; i++)
{
int dobas = dobasok[i];
int dontes = dontesek[i];
dobasokFull.Add(dobas);
dontesekFull.Add(dontes);
if (dontes == 1)
{
dobasokSmallerScope.Add(dobas);
@@ -78,6 +88,12 @@ namespace Program
kor.dobasok = dobasokSmallerScope.ToArray();
kor.jatekos = jatekosok[jatekosCounter];
kor.dobasokFull = dobasokFull.ToArray();
kor.dontesekFull = dontesekFull.ToArray();
dobasokFull.Clear();
dontesekFull.Clear();
korok.Add(kor);
dobasokSmallerScope.Clear();
@@ -89,7 +105,7 @@ namespace Program
{
jatekosCounter++;
}
continue;
}
}
@@ -100,11 +116,176 @@ namespace Program
Console.WriteLine($"Teljes körök száma: {korok.Count / 3}");
// b feladat
foreach (var item in korok)
{
foreach (var kor in korok)
{
foreach (var jatekos in jatekosok)
{
if (jatekos.Nev == kor.jatekos.Nev)
{
int[] dobasokAKorben = kor.dobasok;
bool sorCondition = dobasokAKorben.Distinct().Count() == 5;
//nagysor
if (sorCondition && dobasokAKorben.Contains(6))
{
jatekos.Minta.Nagysor = true;
continue;
}
//kissor
if (sorCondition && dobasokAKorben.Contains(1))
{
jatekos.Minta.Kissor = true;
continue;
}
//poker
var pokerGroup = dobasokAKorben.GroupBy(x => x).FirstOrDefault(g => g.Count() == 4);
if (pokerGroup != null)
{
int pokerValue = pokerGroup.Key;
if (pokerValue > pokermaxNum)
{
pokermaxNum = pokerValue;
}
jatekos.Minta.Poker = true;
continue;
}
//full
if (dobasokAKorben.Count(x => x == 3) == 1 && dobasokAKorben.Count(x => x == 2) == 1)
{
jatekos.Minta.Full = true;
continue;
}
//terc
if (dobasokAKorben.Count(x => x == 3) == 1)
{
jatekos.Minta.Terc = true;
continue;
}
//ketpar
if (dobasokAKorben.Count(x => x == 2) == 2)
{
jatekos.Minta.KetPar = true;
continue;
}
//egypar
if (dobasokAKorben.Count(x => x == 2) == 1)
{
jatekos.Minta.EgyPar = true;
continue;
}
}
}
}
foreach (var jatekos in jatekosok)
{
if (jatekos.Minta.AllTrue())
{
Console.WriteLine($"{jatekos.Nev} nyerte meg a játékot");
}
}
// c feladat
int counter = 0;
foreach (var kor in korok)
{
if (kor.jatekos.Nev == "Gamma")
{
int[] dobasokAKorben = kor.dobasok;
counter++;
if (dobasokAKorben.Count(x => x == 3) == 1 && dobasokAKorben.Count(x => x == 2) == 1)
{
break;
}
}
}
Console.WriteLine($"Gamma ebbe a körbe dobott full-t: {counter + 1}");
// d feladat
Console.WriteLine($"A legnagyobb poker értéke: {pokermaxNum}");
// e feladat
foreach (var kor in korok)
{
IntArrKiir(kor.dobasokFull);
IntArrKiir(kor.dontesekFull);
Console.WriteLine("---------");
}
Console.WriteLine(CountPairs(new int[] { 2, 2, 3, 3, 4 }));
}
static int GetAllPairs(List<int> dobasok, List<int> dontesek)
{
int pairs = 0;
List<int> asztalok = new List<int>();
foreach (var dobas in dobasok)
{
}
return pairs;
}
static int CountPairs(int[] dobasok)
{
int pairs = 0;
//terc
if (dobasok.Count(x => x == 3) == 1)
{
return 0;
}
var pokerGroup = dobasok.GroupBy(x => x).FirstOrDefault(g => g.Count() == 4);
if (pokerGroup != null)
{
return 0;
}
for (int i = 0; i < dobasok.Length; i++)
{
for (int j = i + 1; j < dobasok.Length; j++)
{
if (dobasok[i] == dobasok[j])
{
pairs++;
}
}
}
return pairs;
}
static void IntArrKiir(int[] arr)
{
foreach (var item in arr)
{
Console.Write(item + " ");
}
Console.WriteLine();
}
static void Feladat1()
@@ -169,25 +350,26 @@ namespace Program
int counter = 0;
int iterations = 0;
int napokCounter = 0;
int napokCounter = 1;
foreach (var item in idopontok2)
{
if (counter == anglesToLookFor.Count)
{
break;
}
if (item.Angle == anglesToLookFor[counter])
{
counter++;
}
if (counter == anglesToLookFor.Count)
{
break;
}
iterations++;
if (iterations == 1440)
{
napokCounter++;
iterations = 0;
}
}