This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * The while loop represents the game. | |
| * Each iteration represents a turn of the game | |
| * where you are given inputs (the heights of the mountains) | |
| * and where you have to print an output (the index of the mountain to fire on) | |
| * The inputs you are given are automatically updated according to your last actions. | |
| **/ | |
| $table = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Auto-generated code below aims at helping you parse | |
| * the standard input according to the problem statement. | |
| **/ | |
| fscanf(STDIN, "%d", | |
| $n // the number of temperatures to analyse | |
| ); | |
| $inputs = fgets(STDIN); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var collection = { | |
| "2548": { | |
| "album": "Slippery When Wet", | |
| "artist": "Bon Jovi", | |
| "tracks": [ | |
| "Let It Rock", | |
| "You Give Love a Bad Name" | |
| ] | |
| }, | |
| "2468": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addTogether() { | |
| var _arguments = arguments; | |
| if (typeof arguments[0] !== 'number' || arguments[1] && typeof arguments[1] !== 'number') { | |
| return undefined; | |
| } | |
| if (arguments[1]) { | |
| return arguments[0] + arguments[1]; | |
| } | |
| return function (val) { | |
| return addTogether(_arguments[0], val); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function uniteUnique(arr) { | |
| var newArray = []; | |
| var numbArg = arguments.length; | |
| var numbVal; | |
| for (var i = 0; i < numbArg; i++){ | |
| numbVal = arguments[i].length; | |
| for (var j = 0; j < numbVal; j++ ){ | |
| newArray.push(arguments[i][j]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function whatIsInAName(collection, source) { | |
| var arr = []; | |
| var propertyListe = Object.keys(source); | |
| arr = collection.filter(function (val){ | |
| return propertyListe.every(function (propertyValue){ | |
| return source[propertyValue] === val[propertyValue]; | |
| }); | |
| }); | |
| return arr; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function binaryAgent(str) { | |
| var arraySplited = str.split(" "); | |
| var newArray = arraySplited.map(function(val){ | |
| return String.fromCharCode(parseInt(val, 2)); | |
| }); | |
| return newArray.join(""); | |
| } | |
| binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findElement(arr, func) { | |
| var num = 0; | |
| num = arr.filter(func).shift(); | |
| return num; | |
| } | |
| findElement([1, 3, 5, 8, 9, 10], function(num){ return num % 2 === 0; }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function smallestCommons(arr) { | |
| var max = Math.max(arr[0], arr[1]); | |
| var min = Math.min(arr[0], arr[1]); | |
| var res = min; | |
| for(var i = min; i<= max; i++){ | |
| if(res % i !== 0){ | |
| res += min; | |
| i = min; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sumPrimes(num) { | |
| var sum = 2; | |
| for ( var i = 2; i <= num; i++) { | |
| for (var j = 2; j < i; j++){ | |
| if (i % j === 0){ | |
| break; | |
| } | |
| else if (j === i-1) { | |
| sum += i; | |
| } |