1.Ranking- More Exercises: Associative Arrays- corelation betwen values of two Dictionaries
I need some help for this exercise. If somebody have some spare time, could they, please check my print method at the end. I think my logic is correct, but I can't print each contest with the points in descending order, because the information from the another list becomes invalid.
I have two dictionaries: var usernamesListOfContests= new SortedDictionary<string, List<string>>() with username and all the contests per user and var usernamesListOfPoints= new Dictionary<string, List<int>>() with username and all points.
If I change the order in the second dictionary, the information in the first dictionary becomes invalid and incorrect. I need some corelation betwen those two lists when I try to sort and print the result. I'am not very confident to use dictionary from dictionaryies.
Thanks in advance.
https://softuni.bg/trainings/resources/officedocument/38560/more-exercise-technology-fundamentals-with-csharp-january-2019/2237
https://judge.softuni.bg/Contests/Practice/Index/1302#0
https://pastebin.com/7FLT6E0i - 40/100
Console.WriteLine("Ranking: ");
foreach (var kvp in usernamesListOfContests)
{
string username = kvp.Key;
Console.WriteLine($"{username}");
var listOfContest = kvp.Value;
var listOfPoints = usernamesListOfPoints[username];
for (int i = 0; i <listOfContest.Count() ; i++)
{
Console.WriteLine($"# {listOfContest[i]} -> {listOfPoints[i]}");
}
Благодаря много! :)
Разбрах вече- връзката между стойностите на двата листа от съответните речници се прави отново с речник. И така срещу всеки стринг от listOfContest стои съответния инт от listOfPoints. След прилагането на OrderByDescending върху новосъздадения речник, вече няма разместване на данните.
Никога повече няма да се зачудя как се прави връзката между стойностите на два речника. :)
Благодарение на Вас, вече имам решение 100/100 https://pastebin.com/X03WQr2e
Поздрави и хубава вечер!