Codility

    long long count =0;
    int B[N];
    B[0] = A[0];
    for(long i =1; i<N;i++)  {
        B[i]=A[i];
        A[i] += A[i-1]; }
    long last = A[N-1];
    for(long i =0; i<N;i++)
    {if (B[i]==0)
        {
            count += last-A[i]; }}
    return count;
    long long count =0;
    int B[N];
    B[0] = A[0];
    for(long i =1; i<N;i++)  {
        B[i]=A[i];
        A[i] += A[i-1];
    }
    long last = A[N-1];
    for(long i =0; i<N;i++)  {
        if (B[i]==0)     {
            count += last-A[i];    
        }
    }
    if(count >1E9 || count< 0)
    return -1;
    else
    return count;

minavgtwoslice

def solution(A):
    min_idx = 0
    min_value = 10001
    for idx in xrange(0, len(A)-1):
        if (A[idx] + A[idx+1])/2.0 < min_value:
            min_idx = idx
            min_value = (A[idx] + A[idx+1])/2.0
        if idx < len(A)-2 and (A[idx] + A[idx+1] + A[idx+2])/3.0 < min_value:
            min_idx = idx
            min_value = (A[idx] + A[idx+1] + A[idx+2])/3.0
    return min_idx
        Array.Sort(A);
        long s=A.Length;
        double max = -1E9;
        if(s==3)
            {
                return A[0]*A[1]*A[2];
            }
        else
        {       if (max<A[0]*A[1]*A[s-1])
                {
                    max=A[0]*A[1]*A[s-1];
                }
                if(max<A[s-3]*A[s-2]*A[s-1])
                {
                    max=A[s-3]*A[s-2]*A[s-1];
        }   }   
        return int.Parse(max.ToString());
    }

Triangle

https://codility.com/demo/results/demo79SQT3-9X4/

https://codility.com/demo/results/demoW37BJM-T5J/

 

https://codility.com/demo/results/demo7JFZRJ-UNF/

https://codility.com/demo/results/demoGTDS63-3UW/

https://codility.com/demo/results/demoJMZPE4-KYH/

https://codility.com/demo/results/demoE58Q72-5R6/

https://codility.com/demo/results/demoE58Q72-5R6/

Codility

By Brijesh Kumar