Rail.Suleymanov
BAN USERSee highest answer by avico81
 Rail.Suleymanov November 13, 2012Go to 50th floor and use your first egg. If it breaks, then use remaining egg to test lower floors beginning from 1 as helen 2211 proposed. If it doesn't break, go to 75th floor e.t.c. dividing remaining number of floors by 2 until your first egg is not broken.
 Rail.Suleymanov November 13, 2012I think I've discovered my problem: need to use 'elif' in 2 last conditions...
 Rail.Suleymanov November 09, 2012Hmmm, now it seems to be correct, but my implemented code still displays wrong result:
def DNFAlgo(a) :
right = len(a)  1
if right < 1 : return
left = 0
mid = 0
while mid <= right :
if a[mid] == 0 :
a[left], a[mid] = a[mid], a[left]
mid = mid + 1
left = left + 1
if a[mid] == 1 :
mid = mid + 1
if a[mid] == 2 :
a[mid], a[right] = a[right], a[mid]
right = right  1
for your array {1,1,2,2,2,0,1,2,0} it displays result:
{0,0,1,1,2,1,2,2,2}
Good job, but you'll need 'left++' in 3rd statement as well
 Rail.Suleymanov November 08, 20121. Find number of '0', '1' and '2'
2. Create new array (or replace old) knowing how many '0's, '1's and '2's should be there.
static void Main(string[] args)
{
int n = 1, m = 1000000;
if (n % 2 != 0) n++;
for (int i = n + 1; i < m; i = i + 2)
if (IsPrime(i))
Console.WriteLine(i);
}
public static bool IsPrime(int Num)
{
double sqrt = Math.Sqrt(Num);
int N = int.Parse(Math.Ceiling(sqrt).ToString()) + 1;
for (int i = 3; i < N; i = i + 2)
if (Num % i == 0)
return false;
return true;
}

Rail.Suleymanov
October 29, 2012 for (i = 0; i < N; i++)
Arr[i] = Arr[i] * Arr[i];
for (i = 0; i < N  2; i++)
{
for (j = i + 1; j < N  1; j++)
{
for (k = j + 1; j < N; j++)
{
if (Arr[i] + Arr[j] == Arr[k])
{
Console.WriteLine("{0}\t{1}\t{2}", Arr[i], Arr[j], Arr[k]);
Console.WriteLine("{0}\t{1}\t{2}", i, j, k);
}
else if (Arr[i] + Arr[k] == Arr[j])
{
Console.WriteLine("{0}\t{1}\t{2}", Arr[i], Arr[j], Arr[k]);
Console.WriteLine("{0}\t{1}\t{2}", i, j, k);
}
else if (Arr[k] + Arr[j] == Arr[i])
{
Console.WriteLine("{0}\t{1}\t{2}", Arr[i], Arr[j], Arr[k]);
Console.WriteLine("{0}\t{1}\t{2}", i, j, k);
}
}
}
}

Rail.Suleymanov
October 29, 2012 What if your ml is odd?
 Rail.Suleymanov October 24, 2012static void Main(string[] args)
{
int[,] Matr;
int Sz = 5;
Matr = new int[Sz, Sz];
// initialize matrix
for (int i = 0; i < Sz; i++)
for (int j = 0; j < Sz; j++)
Matr[i, j] = i * Sz + j + 1;
// rotate
for (int i = 0; i < (Sz  Sz % 2) / 2; i++)
{
for (int j = i; j < Sz  i  1; j++)
{
SWAP(ref Matr[i, j], ref Matr[j, Sz  i  1]);
SWAP(ref Matr[Sz  j  1, i], ref Matr[i, j]);
SWAP(ref Matr[Sz  i  1, Sz  j  1], ref Matr[Sz  j  1, i]);
}
}
}
public static void SWAP(ref int a, ref int b)
{
a = a + b;
b = a  b;
a = a  b;
}

Rail.Suleymanov
October 24, 2012
Reppamelajoung, Dev Lead at Absolute Softech Ltd
I have worked as a wedding photographer for the past two years, first as a photographerâ€™s assistant and then ...
Open Chat in New Window
What does it mean  "each of these denominations are in infinite numbers"?
 Rail.Suleymanov November 14, 2012