ultrafish
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
public void LotteryTest()
{
var values = new Dictionary<int, int>();
for (int i = 0; i < 1000; i++)
{
string valueString = i.ToString().PadLeft(3, '0');
var value = Convert.ToByte(valueString[0].ToString()) + Convert.ToByte(valueString[1].ToString()) + Convert.ToByte(valueString[2].ToString());
if (!values.ContainsKey(value))
{
values.Add(value, 1);
}
else
{
values[value]++;
}
}
var total = values.Sum(v => v.Value * v.Value); //combination of left 3 and right 3
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- ultrafish April 08, 2013