score:8

Accepted answer

Try the following

dictionary
  .SelectMany(pair => Enumerable.Repeat((double)pair.Key, pair.Value))
  .OrderByDescending(x => x)
  .ToList();

score:1

foreach (var pair in dict)
    for (int i=0;i<pair.Value;i++)
        list.Add((double)pair.Key);

score:5

dictionary
    .SelectMany(kvp => Enumerable.Repeat(Decimal.ToDouble(kvp.Key), kvp.Value))
    .ToList()

score:0

public static IEnumerable<T> Blowout<T>(T value, int length)
{
    for (int i = 0; i < length; i++) yield return value;
}

dictionary
    .SelectMany(pair => Blowout((double)pair.Key, pair.Value));

Related Articles