Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Created October 14, 2012 01:09
Show Gist options
  • Save alexsandro-xpt/3886850 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/3886850 to your computer and use it in GitHub Desktop.
Teste
public static Dictionary<char, int> teste(string url)
{
var arUrl = url.ToCharArray();
var gUrl = arUrl.GroupBy(n => n);
Console.WriteLine(gUrl.Count());
var pos = new Dictionary<char, int>();
var gUrlA = gUrl.ToArray();
for (int i = 0; i < gUrlA.Length; i++)
{
//Console.WriteLine("{2} -> {0} = {1}", gUrlA[i].Key, gUrlA[i].Count(), (byte)gUrlA[i].Key);
pos[gUrlA[i].Key] = 0;
}
for (int i = 0; i < arUrl.Length; i++)
{
pos[arUrl[i]] += arUrl[i] * (i + 1);
}
int tot = 0;
foreach (var item in pos)
{
tot += item.Value;
}
Console.WriteLine(tot);
Console.WriteLine();
return pos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment