I don't understand the failed test message
Afficher commentaires plus anciens
Hello,
I was solving some cody problem called perfect squares that asks for a given vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.
Example:
input a = [2 3 4]
output b is true
my code
function b = isItSquare(a)
y = []
for i = 1:length(a)
j = 1:length(a)
if a(i) == a(j)^2
y = horzcat(y,1)
else
y = horzcat(y,0)
end
end
end
if any(y(:)) ==1
b = true
else
b = false
end
end
I got 7 out of 8 tests correct, the first test is incorrect

I don't even understand what does this mean?
1 commentaire
Torsten
le 21 Août 2023
Maybe one of the challenges was not to use "else" in your code ? But you used it ...
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Communications Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!