asd
This commit is contained in:
parent
490efd2fcc
commit
f92b3d93ef
fordulo_3
Program
.vs/Program
CopilotIndices/17.13.431.34963
FileContentIndex
53c087b0-a46d-4e5b-8f8a-dcd317786d25.vsidx628ed0ad-8049-492c-95bc-a594579de0f6.vsidx9c7cb05b-f4e5-44ad-8957-e9f7be36d2c8.vsidxa700aa66-caff-4d72-90c9-2cec60b33973.vsidx
copilot-chat/f9c248b7/sessions
v17
bin/Debug
obj/Debug
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,13 +2,13 @@
|
|||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
|
@ -18,32 +18,33 @@
|
|||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"SelectedChildIndex": 2,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Sorozat.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeDocumentMoniker": "Sorozat.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeToolTip": "Sorozat.cs",
|
||||
"ViewState": "AgIAABwAAAAAAAAAAAAYwCMAAAAaAAAAAAAAAA==",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "PermutationGenerator.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs",
|
||||
"RelativeDocumentMoniker": "PermutationGenerator.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs",
|
||||
"RelativeToolTip": "PermutationGenerator.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABMAAAA8AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:59:58.311Z",
|
||||
"WhenOpened": "2025-03-12T17:31:40.758Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAAzAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAMAAAAAAAAAAAAwwBQAAAA6AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z"
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
|
@ -18,32 +18,33 @@
|
|||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"SelectedChildIndex": 2,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Sorozat.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeDocumentMoniker": "Sorozat.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeToolTip": "Sorozat.cs",
|
||||
"ViewState": "AgIAABwAAAAAAAAAAAAYwCMAAAAaAAAAAAAAAA==",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "PermutationGenerator.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs",
|
||||
"RelativeDocumentMoniker": "PermutationGenerator.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs",
|
||||
"RelativeToolTip": "PermutationGenerator.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABMAAAA8AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:59:58.311Z",
|
||||
"WhenOpened": "2025-03-12T17:31:40.758Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAAzAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAMAAAAAAAAAAAAwwBQAAAA6AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z"
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
73
fordulo_3/Program/PermutationGenerator.cs
Normal file
73
fordulo_3/Program/PermutationGenerator.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
class PermutationGenerator
|
||||
{
|
||||
public Dictionary<string, List<int[]>> GroupedPermutations { get; private set; }
|
||||
private HashSet<string> uniquePermutations;
|
||||
|
||||
public PermutationGenerator()
|
||||
{
|
||||
GroupedPermutations = new Dictionary<string, List<int[]>>();
|
||||
uniquePermutations = new HashSet<string>();
|
||||
}
|
||||
|
||||
public void GeneratePermutations(int[] digits, int length)
|
||||
{
|
||||
GeneratePermutations(digits, new int[length], 0);
|
||||
}
|
||||
|
||||
private void GeneratePermutations(int[] digits, int[] current, int index)
|
||||
{
|
||||
if (index == current.Length)
|
||||
{
|
||||
if (current[0] != 0) // Avoid permutations starting with 0
|
||||
{
|
||||
AddPermutation(current);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < digits.Length; i++)
|
||||
{
|
||||
current[index] = digits[i];
|
||||
GeneratePermutations(digits, current, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddPermutation(int[] permutation)
|
||||
{
|
||||
var key = string.Concat(permutation.OrderBy(x => x));
|
||||
var permutationString = string.Join("", permutation);
|
||||
|
||||
if (!uniquePermutations.Contains(permutationString))
|
||||
{
|
||||
uniquePermutations.Add(permutationString);
|
||||
|
||||
if (!GroupedPermutations.ContainsKey(key))
|
||||
{
|
||||
GroupedPermutations[key] = new List<int[]>();
|
||||
}
|
||||
GroupedPermutations[key].Add((int[])permutation.Clone());
|
||||
}
|
||||
}
|
||||
|
||||
public void PrintGroupedPermutations()
|
||||
{
|
||||
foreach (var group in GroupedPermutations)
|
||||
{
|
||||
Console.WriteLine($"Group: {group.Key}");
|
||||
foreach (var permutation in group.Value)
|
||||
{
|
||||
Console.WriteLine(string.Join("", permutation));
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,9 +10,133 @@ namespace Program
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Sorozat.ComputeCollatz(1000000);
|
||||
List<int> primes = new List<int>();
|
||||
|
||||
Sorozat.CollatzLengthWithPrint(837799);
|
||||
for (int i = 1000; i < 10000; i++)
|
||||
{
|
||||
if (IsPrime(i))
|
||||
{
|
||||
primes.Add(i);
|
||||
string result = string.Join("", GetSortedDigits(i));
|
||||
Console.WriteLine($"({i},{result}),");
|
||||
}
|
||||
}
|
||||
|
||||
List<int[]> primesWithDecimalValuesOrdered = new List<int[]>();
|
||||
|
||||
foreach (int i in primes)
|
||||
{
|
||||
primesWithDecimalValuesOrdered.Add(GetSortedDigits(i));
|
||||
}
|
||||
|
||||
var keyValuePairs = primesWithDecimalValuesOrdered
|
||||
.GroupBy(x => x, new IntArrayComparer())
|
||||
.Select(g => new KeyValuePair<int[], int>(g.Key, g.Count()))
|
||||
.Where(kvp => kvp.Value >= 6)
|
||||
.ToList().Count();
|
||||
|
||||
// Print the key-value pairs
|
||||
/*
|
||||
foreach (var kvp in keyValuePairs)
|
||||
{
|
||||
Console.WriteLine($"Key: {string.Join("", kvp.Key)}, Value: {kvp.Value}");
|
||||
}
|
||||
*/
|
||||
|
||||
Console.WriteLine(keyValuePairs);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int[] digits = { 0, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9 };
|
||||
int length = 4;
|
||||
|
||||
PermutationGenerator generator = new PermutationGenerator();
|
||||
generator.GeneratePermutations(digits, length);
|
||||
//generator.PrintGroupedPermutations();
|
||||
|
||||
// Get groups with at least 6 primes
|
||||
var groupsWithAtLeast6Primes = generator.GroupedPermutations
|
||||
.Where(group => group.Value.Count(permutation => IsPrime(int.Parse(string.Join("", permutation)))) >= 6)
|
||||
.ToList();
|
||||
|
||||
// Print the groups with at least 6 primes
|
||||
foreach (var group in groupsWithAtLeast6Primes)
|
||||
{
|
||||
Console.WriteLine($"Group: {group.Key}");
|
||||
foreach (var permutation in group.Value)
|
||||
{
|
||||
Console.WriteLine(string.Join("", permutation));
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int[] GetSortedDigits(int number)
|
||||
{
|
||||
// Convert the number to a string to access each digit
|
||||
string numberString = number.ToString();
|
||||
|
||||
// Convert each character to an integer
|
||||
int[] digits = numberString.Select(c => int.Parse(c.ToString())).ToArray();
|
||||
|
||||
// Sort the array of integers
|
||||
Array.Sort(digits);
|
||||
|
||||
return digits;
|
||||
}
|
||||
|
||||
static bool IsPrime(int number)
|
||||
{
|
||||
if (number <= 1) return false;
|
||||
if (number == 2) return true;
|
||||
if (number % 2 == 0) return false;
|
||||
|
||||
int boundary = (int)Math.Floor(Math.Sqrt(number));
|
||||
|
||||
for (int i = 3; i <= boundary; i += 2)
|
||||
{
|
||||
if (number % i == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class IntArrayComparer : IEqualityComparer<int[]>
|
||||
{
|
||||
public bool Equals(int[] x, int[] y)
|
||||
{
|
||||
if (x == null || y == null)
|
||||
return false;
|
||||
|
||||
if (x.Length != y.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < x.Length; i++)
|
||||
{
|
||||
if (x[i] != y[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode(int[] obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return 0;
|
||||
|
||||
int hash = 17;
|
||||
foreach (int i in obj)
|
||||
{
|
||||
hash = hash * 31 + i;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PermutationGenerator.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Sorozat.cs" />
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
52261ac204714890afe2467c25b9765789d39c141c743f2c478f13be997c8941
|
||||
0f60ae438c65b1815603680249bf9a5d03a307c39118102277870be2ddb77ab4
|
||||
|
|
Binary file not shown.
Binary file not shown.
1064
fordulo_3/primek.sql
Normal file
1064
fordulo_3/primek.sql
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,7 @@
|
|||
- `837799|524`
|
||||
|
||||
### 3. feladat
|
||||
- a: ``
|
||||
- a: `42`
|
||||
- b: ``
|
||||
|
||||
### 4. feladat
|
||||
|
|
Loading…
Reference in New Issue
Block a user