• ###### Amel Haraciccommented on "Find the next perfect square!" kata

I fixed it, it works perfect now. Thanks :)

Same

• ###### JohanWiltinkresolved a question on "Find the next perfect square!" kata

Insufficient data. Closing.

approved

• ###### kyttacreated a suggestion for "Find the next perfect square!" kata

In Rust code for this kata, the return type is specified as optional u64, which makes returning -1 impossible. From tests it is clear, that None should be returned, yet it'd be helpful to also say this in the description.

• ###### efimov90created a suggestion for "Find the next perfect square!" kata

This comment is hidden because it contains spoiler information about the solution

• ###### morpheus_cultcommented on "Find the next perfect square!" kata

function findNextSquare(sq) {
// Return the next square if sq is a perfect square, -1 otherwise
let sqrtNum = Math.sqrt(sq);
let nextNum = sqrtNum + 1;
if(sqrtNum % 1 === 0){
return nextNum ** 2;
} else {
return -1;
}
}

• ###### ProgramarComigocommented on "Find the next perfect square!" kata

function findNextSquare(sq) {

let nextSq = Math.floor(Math.sqrt(sq)) + 1
if(sq === nextSq){
return Math.pow(nextSq, 2)
}
else {
return -1
}
}

console.log(findNextSquare(121))
console.log(findNextSquare(625))
console.log(findNextSquare(319225))
console.log(findNextSquare(15241383936))

This is my code. I rly don't understand where is the problem. Did i miss something?

• ###### ianmc74commented on "Find the next perfect square!" kata

This comment is hidden because it contains spoiler information about the solution

• ###### Amel Haraciccommented on "Find the next perfect square!" kata

my code works ok, passed all the basic tests but when it comes to random ones my code time out. Execution Timed Out (12000 ms)
what could be the problem? can anyone help me with this one? thanks :)

• ###### Chrono79commented on "Find the next perfect square!" kata

At least in the sample tests, simply returning instead of printing the result made your code work. Also check how to post your code in Discourse with markdown formatting.

• ###### radicalbaconresolved a question on "Find the next perfect square!" kata

yanno, I had read it at least 3x before, but it never hurts to read it again.