finished all tasks
This commit is contained in:
parent
4370f4cd05
commit
dc971298b8
|
@ -84,7 +84,8 @@ public static class Karakterek
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int TotalDistanceTraveled(string input){
|
public static int TotalDistanceTraveled(string input)
|
||||||
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
|
@ -111,7 +112,8 @@ public static class Karakterek
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Szoveg{
|
public static class Szoveg
|
||||||
|
{
|
||||||
public static List<string> fullTextInListOfString = new List<string>();
|
public static List<string> fullTextInListOfString = new List<string>();
|
||||||
public static List<string> wordsWithUniqeCharactersOnly = new List<string>();
|
public static List<string> wordsWithUniqeCharactersOnly = new List<string>();
|
||||||
|
|
||||||
|
@ -151,129 +153,167 @@ public static class Szoveg{
|
||||||
public static int GreatestDistanceBetweenWords(string input)
|
public static int GreatestDistanceBetweenWords(string input)
|
||||||
{
|
{
|
||||||
int maxDistance = 0;
|
int maxDistance = 0;
|
||||||
int? firstIndex = null;
|
|
||||||
|
|
||||||
int firstEndIndex = 0;
|
int firstEndIndex = 0;
|
||||||
int? secondIndex = null;
|
|
||||||
int secondStartIndex = 0;
|
int secondStartIndex = 0;
|
||||||
int secondEndIndex = 0;
|
int secondEndIndex = 0;
|
||||||
|
|
||||||
for (int i = 1; i < input.Length - 2; i++)
|
for (int i = 1; i < input.Length - 2; i++)
|
||||||
{
|
{
|
||||||
// új névelő megtalálva
|
// új névelő megtalálva
|
||||||
if (input[i] == 'A' && input[i - 1] == ' ' && input[i + 1] == ' ')
|
if (input[i] == 'A' && input[i - 1] == ' ' && input[i + 1] == ' ')
|
||||||
{
|
{
|
||||||
if (firstIndex == null)
|
if (firstEndIndex == 0)
|
||||||
{
|
{
|
||||||
firstIndex = i;
|
|
||||||
firstEndIndex = i;
|
firstEndIndex = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondIndex == null && firstIndex != null)
|
if (secondEndIndex == 0 && firstEndIndex != 0)
|
||||||
{
|
{
|
||||||
secondIndex = i;
|
|
||||||
secondStartIndex = i;
|
secondStartIndex = i;
|
||||||
secondEndIndex = i;
|
secondEndIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// kettő közötti távolság
|
// kettő közötti távolság
|
||||||
int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1);
|
int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1);
|
||||||
if (distance > maxDistance)
|
if (distance > maxDistance)
|
||||||
{
|
{
|
||||||
maxDistance = distance;
|
maxDistance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstIndex = secondIndex;
|
|
||||||
|
|
||||||
firstEndIndex = secondEndIndex;
|
firstEndIndex = secondEndIndex;
|
||||||
|
|
||||||
secondIndex = i;
|
|
||||||
secondStartIndex = i;
|
secondStartIndex = i;
|
||||||
secondEndIndex = i;
|
secondEndIndex = i;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input [i] == 'A' && input[i + 1] == 'Z' && input[i - 1] == ' ' && input[i + 2] == ' '){
|
if (input[i] == 'A' && input[i + 1] == 'Z' && input[i - 1] == ' ' && input[i + 2] == ' ')
|
||||||
if (firstIndex == null)
|
{
|
||||||
|
if (firstEndIndex == 0)
|
||||||
{
|
{
|
||||||
firstIndex = i;
|
firstEndIndex = i;
|
||||||
firstEndIndex = i + 1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondIndex == null && firstIndex != null)
|
if (secondEndIndex == 0 && firstEndIndex != 0)
|
||||||
{
|
{
|
||||||
secondIndex = i;
|
|
||||||
secondStartIndex = i;
|
secondStartIndex = i;
|
||||||
secondEndIndex = i + 1;
|
secondEndIndex = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// kettő közötti távolság
|
// kettő közötti távolság
|
||||||
int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1);
|
int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1);
|
||||||
if (distance > maxDistance)
|
if (distance > maxDistance)
|
||||||
{
|
{
|
||||||
maxDistance = distance;
|
maxDistance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstIndex = secondIndex;
|
|
||||||
|
|
||||||
firstEndIndex = secondEndIndex;
|
firstEndIndex = secondEndIndex;
|
||||||
|
|
||||||
secondIndex = i;
|
|
||||||
secondStartIndex = i;
|
secondStartIndex = i;
|
||||||
secondEndIndex = i + 1;
|
secondEndIndex = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return maxDistance;
|
return maxDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int MaxDistanceBetweenArticles(string text)
|
||||||
|
{
|
||||||
|
List<int> distances = new List<int>();
|
||||||
|
Regex regex = new Regex(@"\b(AZ|A)\b", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
foreach (Match match in regex.Matches(text))
|
||||||
|
{
|
||||||
|
int startPosition = match.Index;
|
||||||
|
int endPosition = match.Index + match.Length - 1;
|
||||||
|
|
||||||
|
var asd = match.NextMatch();
|
||||||
|
var nextStart = asd.Index;
|
||||||
|
var nextEnd = asd.Index + asd.Length - 1;
|
||||||
|
|
||||||
|
distances.Add(nextStart - endPosition - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return distances.Max(); // Max distance
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int UniquePalindromes()
|
||||||
|
{
|
||||||
|
List<string> palindromes = new List<string>();
|
||||||
|
|
||||||
|
foreach (var word in fullTextInListOfString)
|
||||||
|
{
|
||||||
|
if (word.Length < 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (word == new string(word.Reverse().ToArray()))
|
||||||
|
{
|
||||||
|
if (!palindromes.Contains(word))
|
||||||
|
{
|
||||||
|
palindromes.Add(word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return palindromes.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
Karakterek.ReadDataFromFile(@"..\karsor.txt");
|
||||||
{
|
|
||||||
Karakterek.ReadDataFromFile(@"..\karsor.txt");
|
|
||||||
|
|
||||||
//System.Console.WriteLine($"{Karakterek.KarakterekList.Count}");
|
//System.Console.WriteLine($"{Karakterek.KarakterekList.Count}");
|
||||||
|
|
||||||
// feladat 1 a
|
// feladat 1 a
|
||||||
/*
|
/*
|
||||||
var longestStringWithTwoCharactersOnly = Karakterek.LongestStringWithTwoCharactersOnly();
|
var longestStringWithTwoCharactersOnly = Karakterek.LongestStringWithTwoCharactersOnly();
|
||||||
var karakterek = longestStringWithTwoCharactersOnly.Distinct().OrderBy(c => c).ToArray();
|
var karakterek = longestStringWithTwoCharactersOnly.Distinct().OrderBy(c => c).ToArray();
|
||||||
int longestStringWithTwoCharactersOnlyLength = longestStringWithTwoCharactersOnly.Count;
|
int longestStringWithTwoCharactersOnlyLength = longestStringWithTwoCharactersOnly.Count;
|
||||||
|
|
||||||
System.Console.WriteLine($"{karakterek[0]}{karakterek[1]}{longestStringWithTwoCharactersOnlyLength}");
|
System.Console.WriteLine($"{karakterek[0]}{karakterek[1]}{longestStringWithTwoCharactersOnlyLength}");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// feladat 1 b
|
// feladat 1 b
|
||||||
|
|
||||||
// ez az input változó volt használva a b és a c részben is
|
|
||||||
//string input = new string(Karakterek.KarakterekList.ToArray());
|
|
||||||
|
|
||||||
//System.Console.WriteLine($"{Karakterek.CountABCSequences(input)}");
|
// ez az input változó volt használva a b és a c részben is
|
||||||
|
//string input = new string(Karakterek.KarakterekList.ToArray());
|
||||||
|
|
||||||
// feladat 1 c
|
//System.Console.WriteLine($"{Karakterek.CountABCSequences(input)}");
|
||||||
//System.Console.WriteLine($"{Karakterek.TotalDistanceTraveled(input)}");
|
|
||||||
|
|
||||||
// feladat 2 a
|
// feladat 1 c
|
||||||
|
//System.Console.WriteLine($"{Karakterek.TotalDistanceTraveled(input)}");
|
||||||
|
|
||||||
Szoveg.ReadDataFromFile(@"..\testinput.txt");
|
// feladat 2 a
|
||||||
|
|
||||||
/*
|
Szoveg.ReadDataFromFile(@"..\szoveg.txt");
|
||||||
Szoveg.wordsWithUniqeCharactersOnly = Szoveg.WordsWithUniqeCharactersOnly();
|
|
||||||
|
|
||||||
System.Console.WriteLine($"{Szoveg.LongestStringWithUniqueCharacters()}");
|
/*
|
||||||
*/
|
Szoveg.wordsWithUniqeCharactersOnly = Szoveg.WordsWithUniqeCharactersOnly();
|
||||||
|
|
||||||
// feladat 2 b
|
System.Console.WriteLine($"{Szoveg.LongestStringWithUniqueCharacters()}");
|
||||||
string fullTextInSingleString = string.Join(" ", Szoveg.fullTextInListOfString);
|
*/
|
||||||
|
|
||||||
int value = Szoveg.GreatestDistanceBetweenWords(fullTextInSingleString);
|
// feladat 2 b
|
||||||
|
string fullTextInSingleString = string.Join(" ", Szoveg.fullTextInListOfString);
|
||||||
|
|
||||||
System.Console.WriteLine($"{value}");
|
//int value = Szoveg.GreatestDistanceBetweenWords(fullTextInSingleString);
|
||||||
|
|
||||||
}
|
int value = Szoveg.MaxDistanceBetweenArticles(fullTextInSingleString);
|
||||||
}
|
|
||||||
|
System.Console.WriteLine($"{value}");
|
||||||
|
|
||||||
|
System.Console.WriteLine($"{Szoveg.UniquePalindromes()}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Program")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Program")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2d3a3b5498848de0502de226cf3680344b851fa3")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4370f4cd05125a6cf533b209e139477f99b353dd")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Program")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Program")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Program")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Program")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
5f0e7be5aed498aebc515a122ed65f513d902cc336ac583393b795272d573e2f
|
73ebb59b91d6ddf6e8dd33d5b30abd9efdedbeb154e4bd540e805b4ea0fe83ff
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,2 +1,2 @@
|
||||||
HOL TEREM A M A GYAR VITEZ
|
HOL TEREM A MAGYAR VITEZ
|
||||||
AZ PATAKBAN KET GYERMEK FURDIK
|
A PATAKBAN KET GYERMEK FURDIK
|
BIN
images/feladat3.png
Normal file
BIN
images/feladat3.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 21 KiB |
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
### 2. feladat
|
### 2. feladat
|
||||||
- a: `MEGFORDULTAK`
|
- a: `MEGFORDULTAK`
|
||||||
- b: ``
|
- b: `322`
|
||||||
- c: ``
|
- c: `20`
|
||||||
|
|
||||||
### 3. feladat
|
### 3. feladat
|
||||||
- a: `7`
|
- a: `7`
|
||||||
- b: ``
|
- b: `78`
|
||||||
- c: ``
|

|
||||||
|
- c: `53`
|
Loading…
Reference in New Issue
Block a user