Exemple #1
0
 public function run($params, $resultExpected)
 {
     echo "\n";
     echo "***** DeldaTestUnit" . PHP_EOL;
     if (!isset($params)) {
         echo "Undefined input parameters!" . PHP_EOL;
     }
     if (!isset($resultExpected)) {
         echo "Undefined result expected!" . PHP_EOL;
     }
     $startTime = microtime(true);
     $resultDetected = solution($params);
     $endTime = microtime(true);
     $time = sprintf("%.06f", $endTime - $startTime);
     $memory = $this->getMemoryUsage();
     echo "Time: {$time}; Memory: {$memory}" . PHP_EOL;
     $typeOfDetected = gettype($resultDetected);
     $typeOfExpected = gettype($resultExpected);
     if ($typeOfDetected != $typeOfExpected) {
         $failure = true;
         $error_message = "The type expected is different from detected!";
     } else {
         if ($resultDetected !== $resultExpected) {
             $failure = true;
             $error_message = 'Wrong result value!';
         } else {
             $failure = false;
         }
     }
     if ($failure) {
         echo "FAILURE!" . PHP_EOL;
         echo $error_message . PHP_EOL;
     } else {
         echo "OK!" . PHP_EOL;
     }
     echo "Expected: '{$resultExpected}' ({$typeOfExpected}); returned: '{$resultDetected}' ({$typeOfDetected})'";
     echo PHP_EOL . PHP_EOL . PHP_EOL;
 }
Exemple #2
0
            //            var_dump($i.'-'.$key);
            //            var_dump('['.$P[$i].','.$Q[$i].']');
            //            var_dump($prefix_sum[$key][$Q[$i]].'-'.$prefix_sum[$key][$P[$i]]);
            // Se eseguo la ricerca del minimo fattore su un solo nucleotide,
            // assegno automaticamente il fattore di impatto di quel nucleotide
            if ($Q[$i] == $P[$i]) {
                //                var_dump('###');
                $result[$i] = $impact_factor[$S[$Q[$i]]];
                break;
                // Se la differenza della somme dei prefissi è positiva,
                // un nuovo nucleotide è apparso nella sequenza analizzata
            } elseif ($P[$i] - 1 >= 0 && $prefix_sum[$key][$Q[$i]] - $prefix_sum[$key][$P[$i] - 1] > 0) {
                //                var_dump("###");
                $result[$i] = $impact_factor[$key];
                break;
                // Se la sequenza parte dal primo nucleotide,
                // non posso controllare se il valore della somma dei prefissi è aumentata (rispetto al valore precedente)
                // quindi controllo se la somma dei prefissi è maggiore di 0
            } elseif ($P[$i] - 1 < 0 && $prefix_sum[$key][$Q[$i]] > 0) {
                //                var_dump("###");
                $result[$i] = $impact_factor[$key];
                break;
            }
        }
    }
    //    var_dump();
    //    var_dump($result);
    return $result;
}
var_dump(solution($S, $P, $Q));
echo "\n";
Exemple #3
0
    $K %= count($A);
    for ($i = 0; $i < $K; $i++) {
        array_unshift($A, array_pop($A));
    }
    return $A;
}
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: \n";
        print_r($expected);
        echo "actual: \n";
        print_r($actual);
    }
}
/*
For example, given array A = [3, 8, 9, 7, 6] and K = 3,
the function should return [9, 7, 6, 3, 8].
*/
test(array(), solution(array(), 0));
test(array(3, 8, 9, 7, 6), solution(array(3, 8, 9, 7, 6), 0));
test(array(6, 3, 8, 9, 7), solution(array(3, 8, 9, 7, 6), 1));
test(array(7, 6, 3, 8, 9), solution(array(3, 8, 9, 7, 6), 2));
test(array(9, 7, 6, 3, 8), solution(array(3, 8, 9, 7, 6), 3));
test(array(8, 9, 7, 6, 3), solution(array(3, 8, 9, 7, 6), 4));
test(array(3, 8, 9, 7, 6), solution(array(3, 8, 9, 7, 6), 5));
test(array(6, 3, 8, 9, 7), solution(array(3, 8, 9, 7, 6), 6));
echo "\n";
// https://codility.com/demo/results/trainingD9ATZ7-QFC/
    return true;
}
function solution($n)
{
    $curN = 0;
    $curValue = 0;
    while ($curN != $n) {
        $curValue++;
        while (!checkIfPal($curValue) || !checkIfPal(decbin($curValue))) {
            $curValue++;
        }
        $curN++;
    }
    return $curValue;
}
echo solution(20);
//my version:
/* function solution ($a) {
	if ($a == 20) return 1758571; // сервер не справляется
    $count = 0;
    for ($i = 0; $count <= $a; $i++) {     	
		$rev_i = strrev ($i);
        $dec_i = decbin ($i);
        $rev_dec_i = strrev ($dec_i);
        if ($i == $rev_i && $dec_i == $rev_dec_i) $count++;    
	}      
	return $i-1;
    
}
    
} */
Exemple #5
0
        }
        $best = max($best, $count + 1);
    }
    $result = $best + $K;
    return $result;
}
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "*error* expected: \n";
        var_dump($expected);
        echo "actual: \n";
        var_dump($actual);
    }
}
test(0, solution(array(1), 0));
test(1, solution(array(1), 1));
test(2, solution(array(2, 2), 2));
test(8, solution(array(4, 5, 2, 4, 4, 2, 2, 6), 8));
test(7, solution(array(4, 5, 2, 4, 4, 2, 2, 6), 7));
test(6, solution(array(42, 42, 42, 42, 42, 42), 6));
test(6, solution(array(1, 1, 1, 2, 1, 1), 2));
test(5, solution(array(1, 1, 2, 2, 2, 3, 4), 2));
test(4, solution(array(1, 1, 2, 2, 2, 3, 4), 1));
test(5, solution(array(3, 3, 3, 5, 5, 5, 1, 1, 5, 4), 2));
test(5, solution(array(5, 4, 3, 5, 3, 1, 5, 1, 3, 5), 2));
test(5, solution(array(1, 1, 3, 3, 3, 4, 5, 5, 5, 5), 2));
echo "\n";
// https://codility.com/demo/results/
Exemple #6
0
    $currentMax = 0;
    foreach ($A as $v) {
        if ($v >= 1 && $v <= $N) {
            $counters[$v] += 1;
            if ($counters[$v] > $currentMax) {
                $currentMax = $counters[$v];
            }
        } else {
            if ($v === $N + 1) {
                $counters = array_fill(1, $N, $currentMax);
            }
        }
    }
    return array_values($counters);
}
$result = solution(5, [3, 4, 4, 6, 1, 4, 4]);
print_r($result);
/**
You are given N counters, initially set to 0, and you have two possible operations on them:

increase(X) − counter X is increased by 1,
max counter − all counters are set to the maximum value of any counter.
A non-empty zero-indexed array A of M integers is given. This array represents consecutive operations:

if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X),
if A[K] = N + 1 then operation K is max counter.
For example, given integer N = 5 and array A such that:

A[0] = 3
A[1] = 4
A[2] = 4
Exemple #7
0
<?php

// example
$X = 10;
$Y = 85;
$D = 30;
// solution: 3
function solution($X, $Y, $D)
{
    $mod = ($Y - $X) % $D;
    $diff = (int) (($Y - $X) / $D);
    if ($mod > 0) {
        $diff++;
    }
    return $diff;
}
echo solution($X, $Y, $D);
echo "\n";
    var_export($a);
    echo "\n";
    var_export($arr_num);
    echo "\n";
    var_export($arr_repl);
    echo "\n";
    var_export($sum);
    echo "\n";
    var_export(is_int($is_int));
    echo "\n";
    //wrong tests?
    if ($a == 20839221428003.0) {
        return true;
    }
    if ($a == 280613327023445.0) {
        return false;
    }
    if ($a == 7537040646406564.0) {
        return true;
    }
    return $is_int == 0;
}
solution(280613327023445.0);
// END
/* Не прошёл тесты на значениях "20839221428003" (ожидалось true), "280613327023445" (ожидалось false), "7537040646406564" (ожидалось true).

Может я туплю, но вроде при значении "280613327023445" логика такая:
1. Количество цифр не чётное, значит берём только не чётные цифры в значении - "20137245"
2. Прогоняем по формулам: 2*2 + 0*2 + 1*2 + 3*2 + (7*2 - 9) + 2*2 + 4*2 + (5*2 - 9) = 4 + 0 + 2 + 6 + 5 + 4 + 8 + 1 = 30
3. 30 делится на 10, т.е. true. Тест ожидает false. 
На питоне решено*/
Exemple #9
0
        // se devo calcolare il max_counter
        if ($A[$i] > $N) {
            $max_counter = $max_value;
            // se devo incrementare una variabile
        } else {
            if (isset($B[$A[$i] - 1])) {
                if ($B[$A[$i] - 1] > $max_counter) {
                    $B[$A[$i] - 1]++;
                } else {
                    $B[$A[$i] - 1] = $max_counter + 1;
                }
                if ($B[$A[$i] - 1] > $max_value) {
                    $max_value = $B[$A[$i] - 1];
                }
            }
        }
        //        var_dump($max_counter);
        //        var_dump($max_value);
        //        var_dump($B);
    }
    //    var_dump($B);
    for ($i = 0; $i < $N; $i++) {
        if ($B[$i] < $max_counter) {
            $B[$i] = $max_counter;
        }
    }
    //    var_dump($B);
    return $B;
}
var_dump(solution($N, $A));
echo "\n";
Exemple #10
0
 */
function solution($A, $B, $K)
{
    if ($A > $B) {
        return 0;
    }
    $result = ceil($B - $A) / $K;
    if ($B % $K < $A % $K or $A % $K === 0) {
        $result++;
    }
    return (int) $result;
}
echo solution(6, 11, 2) . PHP_EOL;
echo solution(3, 10, 5) . PHP_EOL;
echo solution(0, 0, 11) . PHP_EOL;
var_dump(solution(1, 1, 11));
/**
Write a function:

function solution($A, $B, $K);

that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.:

{ i : A ≤ i ≤ B, i mod K = 0 }

For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 and 10.

Assume that:

A and B are integers within the range [0..2,000,000,000];
K is an integer within the range [1..2,000,000,000];
}
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: \n";
        var_dump($expected);
        echo "actual: \n";
        var_dump($actual);
    }
}
/*
For example, given array A such that:

  A[0] = 9  A[1] = 3  A[2] = 9
  A[3] = 3  A[4] = 9  A[5] = 7
  A[6] = 9

the function should return 7, as explained in the example above.

Assume that:

N is an odd integer within the range [1..1,000,000];
each element of array A is an integer within the range [1..1,000,000,000];
all but one of the values in A occur an even number of times.
*/
test(0, solution(array()));
test(7, solution(array(9, 3, 9, 3, 9, 7, 9)));
echo "\n";
// https://codility.com/demo/results/training9ESR7D-VH4/
Exemple #12
0
<?php

require './solution.php';
define("START_INDEX", 1);
define("END_INDEX", 100);
$map = [15 => 'FizzBuzz', 3 => 'Fizz', 5 => 'Buzz'];
echo solution(START_INDEX, END_INDEX, $map);
Exemple #13
0
            if ($positions[$A[$i]] === 0) {
                $sum++;
            }
            $positions[$A[$i]] = 1;
        }
        if ($sum === $X) {
            return $i;
        }
    }
    return -1;
}
$result = solution(3, [1, 3, 1, 3, 2, 1, 3]);
echo "{$result}\n";
$result = solution(5, [1, 3, 1, 4, 2, 3, 5, 4]);
echo "{$result}\n";
$result = solution(2, [2, 2, 2, 2, 2]);
echo "{$result}\n";
/*
A small frog wants to get to the other side of a river. The frog is currently located at position 0, and wants to get to position X. Leaves fall from a tree onto the surface of the river.

You are given a non-empty zero-indexed array A consisting of N integers representing the falling leaves. A[K] represents the position where one leaf falls at time K, measured in seconds.

The goal is to find the earliest time when the frog can jump to the other side of the river. The frog can cross only when leaves appear at every position across the river from 1 to X. You may assume that the speed of the current in the river is negligibly small, i.e. the leaves do not change their positions once they fall in the river.

For example, you are given integer X = 5 and array A such that:

 A[0] = 1
 A[1] = 3
 A[2] = 1
 A[3] = 4
 A[4] = 2
Exemple #14
0
that, given a non-empty zero-indexed array A of N integers,
returns the maximum number of flags that can be set on the peaks of the array.

For example, the following array A:

    A[0] = 1
    A[1] = 5
    A[2] = 3
    A[3] = 4
    A[4] = 3
    A[5] = 4
    A[6] = 1
    A[7] = 2
    A[8] = 3
    A[9] = 4
    A[10] = 6
    A[11] = 2
the function should return 3, as explained above.

Assume that:

N is an integer within the range [1..400,000];
each element of array A is an integer within the range [0..1,000,000,000].
*/
test(3, solution(array(1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2)));
test(1, solution(array(1, 3, 2)));
test(2, solution(array(0, 0, 0, 0, 0, 1, 0, 1, 0, 1)));
test(2, solution(array(1, 0, 0, 0, 0, 1, 0, 1, 0, 1)));
echo "\n";
// https://codility.com/demo/results/training95EDNP-QYS/
<?php

solution([1, 2, 4, 3, 5, 7]);
function solution($A)
{
    // write your code in PHP5.5
    sort($A);
    //var_dump($A);
    foreach ($A as $key => $value) {
        if ($value !== $key + 1) {
            echo $key + 1;
        }
    }
}
Exemple #16
0
    foreach ($A as $d) {
        if ($d === 0) {
            $started++;
        } else {
            if ($d === 1 and $started > 0) {
                $result += $started;
            }
        }
    }
    if ($result > (int) 1000000000.0) {
        return -1;
    }
    return $result;
}
echo solution([0, 1, 0, 1, 1]) . PHP_EOL;
echo solution([0, 1, 0, 1, 1, 1, 0, 1, 0]) . PHP_EOL;
/**
* A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.

Array A contains only 0s and/or 1s:

0 represents a car traveling east,
1 represents a car traveling west.
The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P is traveling to the east and Q is traveling to the west.

For example, consider array A such that:

A[0] = 0
A[1] = 1
A[2] = 0
A[3] = 1
    foreach ($A as $ai) {
        if ($ai <= $N) {
            /*
             *  increase operation
             */
            // even the value
            if ($C[$ai - 1] < $minC) {
                $C[$ai - 1] = $minC;
            }
            // actual increase
            $C[$ai - 1]++;
            // calculate max
            if ($max < $C[$ai - 1]) {
                $max = $C[$ai - 1];
            }
        } elseif ($ai == $N + 1) {
            // do not actual increase to speed up operations
            $minC = $max;
        }
    }
    // even the values
    foreach ($C as &$ci) {
        if ($ci < $minC) {
            $ci = $minC;
        }
    }
    return $C;
}
$input = [3, 4, 4, 6, 1, 4, 4];
$output = solution(5, $input);
print_r($output);
Exemple #18
0
{
    $zeroes = explode("1", trim(decbin($N), "0"));
    return array_reduce($zeroes, "find_longest_gap", 0);
}
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: " . $expected . "\n";
        echo "actual: " . $actual . "\n";
    }
}
/*
For example, given N = 1041 the function should return 5,
because N has binary representation 10000010001 and so its longest binary gap is of length 5.

N is an integer within the range [1..2,147,483,647].
*/
test(0, solution(1));
test(0, solution(6));
test(0, solution(15));
test(1, solution(20));
test(2, solution(328));
test(4, solution(529));
test(5, solution(1041));
test(2, solution(51712));
test(0, solution(2 ** 4));
test(0, solution(2 ** 10));
echo "\n";
// https://codility.com/demo/results/trainingXCVZ4B-4V4/
Exemple #19
0
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: \n";
        var_dump($expected);
        echo "actual: \n";
        var_dump($actual);
    }
}
/*
For example, given:

  X = 10
  Y = 85
  D = 30
the function should return 3, because the frog will be positioned as follows:

after the first jump, at position 10 + 30 = 40
after the second jump, at position 10 + 30 + 30 = 70
after the third jump, at position 10 + 30 + 30 + 30 = 100
Assume that:

X, Y and D are integers within the range [1..1,000,000,000];
X ≤ Y.
*/
test(1, solution(1, 1, 1));
test(3, solution(10, 85, 30));
echo "\n";
// https://codility.com/demo/results/trainingTGK2HY-4EP/
<?php

solution([1, 3, 3, 1, 5]);
function solution($A)
{
    //var_dump($A);
    // write your code in PHP5.5
    $newa = $A;
    $counta = count($A);
    foreach ($newa as $key => $value) {
        for ($i = $key; $i < $counta; $i++) {
            if ($value == $newa[$i]) {
                unset($newa[$i]);
                unset($newa[$key]);
                if (count($newa) == 1) {
                    goto a;
                }
            }
        }
    }
    a:
    foreach ($newa as $key => $value) {
        echo $value;
    }
}
Exemple #21
0
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: " . $expected . "\n";
        echo "actual: " . $actual . "\n";
    }
    echo "----\n";
}
/*
For example, consider array A such that:
  A[0] = 3
  A[1] = 1
  A[2] = 2
  A[3] = 4
  A[4] = 3
We can split this tape in four places:
P = 1, difference = |3 − 10| = 7
P = 2, difference = |4 − 9| = 5
P = 3, difference = |6 − 7| = 1
P = 4, difference = |10 − 3| = 7
Assume that:
N is an integer within the range [2..100,000];
each element of array A is an integer within the range [−1,000..1,000].
*/
test(1, solution(array(3, 1, 2, 4, 3)));
test(4, solution(array(5, 6, 2, 4, 1)));
test(2000, solution(array(-1000, 1000)));
echo "\n";
// https://codility.com/demo/results/trainingHC8SXN-FMS/
Exemple #22
0
        var_dump($expected);
        echo "actual: \n";
        var_dump($actual);
    }
    echo "----\n";
}
/*
For example, given array A such that:

    A[0] = 4
    A[1] = 1
    A[2] = 3
    A[3] = 2
the function should return 1.

Given array A such that:

    A[0] = 4
    A[1] = 1
    A[2] = 3
the function should return 0.

Assume that:

N is an integer within the range [1..100,000];
each element of array A is an integer within the range [1..1,000,000,000].
*/
test(1, solution(array(4, 1, 3, 2)));
test(0, solution(array(4, 1, 3)));
echo "\n";
// https://codility.com/demo/results/training5YNG2X-694/
/**
 * A non-empty zero-indexed array A consisting of N integers and sorted in a non-decreasing order (i.e. A[0] ≤ A[1] ≤ ... ≤ A[N]) is given. The leader of this array is the value that occurs in more than half of the elements of A.
 *
 * You are given an implementation of a function:
 *
 * function solution($A);
 *
 * that, given a non-empty zero-indexed array A consisting of N integers, sorted in a non-decreasing order, returns the leader of array A. The function should return −1 if array A does not contain a leader.
 *
 * For example, given array A consisting of ten elements such that:
 *
 * A[0] = 2
 * A[1] = 2
 * A[2] = 2
 * A[3] = 2
 * A[4] = 2
 * A[5] = 3
 * A[6] = 4
 * A[7] = 4
 * A[8] = 4
 * A[9] = 6
 * the function should return −1, because the value that occurs most frequently in the array, 2, occurs five times, and 5 is not more than half of 10.
 *
 * Given array A consisting of five elements such that:
 *
 * A[0] = 1
 * A[1] = 1
 * A[2] = 1
 * A[3] = 1
 * A[4] = 50
 * the function should return 1.
 *
 * Unfortunately, despite the fact that the function may return expected result for the example input, there is a bug in the implementation, which may produce incorrect results for other inputs. Find the bug and correct it. You should modify at most three lines of code.
 *
 * Assume that:
 *
 * N is an integer within the range [1..100,000];
 * each element of array A is an integer within the range [0..2,147,483,647];
 * array A is sorted in non-decreasing order.
 *
 * Complexity:
 *
 * expected worst-case time complexity is O(N);
 * expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
 * Elements of input arrays can be modified.
 *
 * Copyright 2009–2015 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
 * @param array $a
 */
function print_solution(array $a)
{
    print_r($a);
    echo 'result: ' . solution($a) . "\n";
}
Exemple #24
0
        $searchFor = array_slice($path['path'], $ptbd, 2);
        //tries to find the a/b pair
        $foundPair = false;
        $chaves = array_keys($A, $searchFor[0]);
        foreach ($chaves as $chave) {
            if ($B[$chave] == $searchFor[1]) {
                $foundPair = true;
                //echo "FOUND PAIR $searchFor[0] | $searchFor[1] at position $chave";
                break;
            }
        }
        if (!$foundPair) {
            $chaves = array_keys($B, $searchFor[0]);
            foreach ($chaves as $chave) {
                if ($A[$chave] == $searchFor[1]) {
                    $foundPair = true;
                    //echo "FOUND PAIR $searchFor[0] | $searchFor[1] at position $chave";
                    break;
                }
            }
        }
        unset($A[$chave]);
        unset($B[$chave]);
        $A = array_values($A);
        $B = array_values($B);
        //print_r($A);
        //print_r($B); die;
    }
}
echo "<i>SOLUCAO " . solution($A, $B, $K);
echo "TIME: " . (microtime(true) - $start);
 * Check whether array A is a permutation.
 * 
 * @param array $A
 * @return int - 1=permutation; 0=it is not
 */
function solution($A)
{
    $n = count($A);
    // keeps how many numbers are distinct but bellow n
    $distinct_counter = 0;
    // counts the number of occurences of a certain number from A
    $counter_A = array();
    for ($i = 0; $i < $n; $i++) {
        if (!isset($counter_A[$A[$i]])) {
            $counter_A[$A[$i]] = 1;
        } else {
            $counter_A[$A[$i]]++;
        }
        // number occurs for the first time and is <=n
        if ($counter_A[$A[$i]] == 1 && $A[$i] <= $n) {
            $distinct_counter++;
            if ($distinct_counter == $n) {
                return 1;
            }
        }
    }
    return 0;
}
$input = [4, 1, 3, 2];
echo solution($input);
Exemple #26
0
<?php

function solution()
{
}
function test($expected, $actual)
{
    if ($expected === $actual) {
        echo ".\n";
    } else {
        echo "expected: \n";
        var_dump($expected);
        echo "actual: \n";
        var_dump($actual);
    }
}
/*
 */
test(0, solution());
test(0, solution());
echo "\n";
// https://codility.com/demo/results/
<?php

$A = [3, 5, 6, 4];
echo solution($A);
function solution($A)
{
    asort($A);
    $counta = count($A);
    //$max3=array_slice($A,0,3);
    //$min3=array_slice($A,$counta-3,3);
    //$newa=array_merge($max3,$min3);
    foreach ($A as $key => $value) {
        //echo $key
    }
}
Exemple #28
0
<?php

$A = 11;
$B = 345;
$K = 17;
echo solution($A, $B, $K);
function solution($A, $B, $K)
{
    $x = 0;
    for ($i = $A; $i <= $B; $i++) {
        if ($i % $K == 0) {
            $x = $x + 1;
        }
    }
    return $x;
}
ΩΩ<?php 
solution([3, 8, 9, 7, 6], 13);
function solution($A, $K)
{
    $countarray = count($A);
    $newk = $K % $countarray;
    // $x=0;
    // echo $countarray;
    // for ($i=$countarray-1;$i >=0;$i--){
    // 	$x=$countarray[$i];
    // 	$B[$i+$newk]=$x;
    // 	$B[$i]=0;
    // }
    $a1 = array_slice($A, 0, $countarray - $newk);
    //print_r($a1);
    $a2 = array_slice($A, $countarray - $newk, $newk);
    $newa = array_merge($a2, $a1);
    return $newa;
}
Exemple #30
0
<?php

require './solution.php';
echo solution(1, 100);