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 solution(A) { | |
var L = A.length; // Length of the array | |
var X = ((L + 1) * L) / 2; // Sum from 1..L | |
var Y = 0; // Sum of evaluated values | |
var I = 0; // Counter | |
var F = []; // Found elements | |
var V = -1; // Container | |
while (I < L) { // Start searching the array | |
V = A[I]; // Get the value |
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 solution(X, A) { | |
if (A.length === 1) { // If the array is one element | |
// And if its first item is 1 as well as the value to search for, | |
// the frog doesn't need to move | |
if (A[0] === 1 && X === 1) return 0; | |
// If not, it's impossible to go anywhere | |
else return -1; | |
} | |
var i = -1, // Counter |
NewerOlder