<repo_name>Tarfala/RankingsC-<file_sep>/Rankings/Rankings/Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rankings
{
    class Program
    {
        // https://en.wikipedia.org/wiki/Ranking#Strategies_for_assigning_rankings

        static void Main(string[] args)
        {
            Program program = new Program();
            program.StandardRanking1224();
            program.ModifiedRanking1334();
            program.DenseRanking1223();
            program.OrdinalRanking1234();
            program.FractionalRanking125254();       
            
        }

        public void StandardRanking1224()
        {
            int rank = 1;
            Console.WriteLine("Standard Ranking 1224");
            List<int> ranks = new List<int>
            {
                1,
                2,
                2,
                3
            };

            while (ranks.Count() != 0)
            {
                var ranksWithSameNumber = ranks.Where(x => x == ranks[0]).ToList();
                ranks.RemoveAll(x => ranksWithSameNumber.Exists(z => z == x));

                foreach (var item in ranksWithSameNumber)
                {
                    Console.WriteLine($"Rank of '{item}' is {rank}");
                }
                rank += ranksWithSameNumber.Count();

            }
        }

        public void ModifiedRanking1334()
        {
            int rank = 0;
            Console.WriteLine("Modified Ranking 1334");
            List<int> ranks = new List<int>
            {
                1,
                2,
                2,
                3

            };

            while (ranks.Count != 0)
            {
                var ranksWithSameNumber = ranks.Where(x => x == ranks[0]).ToList();
                ranks.RemoveAll(x => ranksWithSameNumber.Exists(z => z == x));
                rank += ranksWithSameNumber.Count();

                foreach (var item in ranksWithSameNumber)
                {
                    Console.WriteLine($"Rank of {item} is {rank}");
                }
            }
        }

        public void DenseRanking1223()
        {
            int rank = 1;
            Console.WriteLine("Modified Ranking 1223");
            List<int> ranks = new List<int>
            {
                1,
                2,
                2,
                3

            };

            while (ranks.Count != 0)
            {
                var ranksWithSameNumber = ranks.Where(x => x == ranks[0]).ToList();
                ranks.RemoveAll(x => ranksWithSameNumber.Exists(z => z == x));

                foreach (var item in ranksWithSameNumber)
                {
                    Console.WriteLine($"Rank of {item} is {rank}");
                }
                rank++;
            }
        }

        public void OrdinalRanking1234()
        {
            int rank = 1;
            Console.WriteLine("Ordinal Ranking 1234");
            List<int> ranks = new List<int>
            {
                1,
                2,
                2,
                3

            };

            while (ranks.Count != 0)
            {
                var ranksWithSameNumber = ranks.Where(x => x == ranks[0]).ToList();
                ranks.RemoveAll(x => ranksWithSameNumber.Exists(z => z == x));

                foreach (var item in ranksWithSameNumber)
                {
                    Console.WriteLine($"Rank of {item} is {rank}");
                    rank++;
                }
            }
        }

        public void FractionalRanking125254()
        {
            Console.WriteLine("Fractional Ranking 125254");
            var test = new List<FractClass>();
            List<double> ranks = new List<double>
            {
                1, // 1 - 1.5 (3/2)
                1, // 2 - 1.5 (3/2)
                2, // 3 - 3 (3/1)
                3, // 4 - 4.5 (9/2)
                3, // 5 - 4.5 (9/2)
                4, // 6 - 6 (6/1)
                5, // 7 - 8 (24/3)
                5, // 8 - 8 (24/3)
                5  // 9 - 8 (24/3)
            };

            for (int i = 0; i < ranks.Count; i++)
            {
                test.Add(new FractClass() { Rank = ranks[i], OriginRank = i+1 });
            }

            while (ranks.Count() != 0)
            {
                var single = test.Where(x => x.Rank == ranks[0]).ToList();
                ranks.RemoveAll(x => single.Exists(z => z.Rank == x));

                foreach (var item in single)
                {
                    Console.WriteLine($"Rank '{item.Rank}' has fractial rank {single.Sum(x => x.OriginRank) / single.Count()}");
                }
            }
        }
    }
}
<file_sep>/Rankings/Rankings/FractClass.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rankings
{
    class FractClass
    {
        public double Rank { get; set; }
        public double OriginRank { get; set; }
    }
}
