using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public class Res{
public string Key;
public int Val;
}
public static void Main()
var locationOutputDistinct = new List<string>
"PERSON:2 ",
"PERSON:1 SCOOTER:1 ",
"PERSON:1 BIKE:1 ",
"PERSON:2 BIKE:1 ",
"PERSON:1 BIKE:1 SCOOTER:1 ",
"PERSON:3 ",
"PERSON:3 BIKE:1 ",
"PERSON:4 ",
"PERSON:4 BIKE:1 ",
"PERSON:2 SCOOTER:1 ",
"PERSON:5 ",
"PERSON:3 SCOOTER:1 ",
"PERSON:6 "
};
var loc =
locationOutputDistinct
.Select(x => x.Trim().Split(' ')
.Select(
y => {
var kv = y.Split(':');
return new Res()
{ Key = kv[0],
Val = int.Parse
(kv[1])
};}))
.GroupBy(x =>
String.Join(",",
x.Select(y => y.Key))
);
foreach(var x in loc)
Console.WriteLine
(//x.Key+": " +
x.SelectMany(y => y
.GroupBy(w => w.Key)
.Select(w => new Res()
Key =
w.Select(z => z.Key).First()
, Val =
w.Max(z => z.Val)
})
)
.GroupBy(q => q.Key)
.Select(z =>
z.Key +"="+
z.Max(q => q.Val))
));