Recurrent server error message while submitting solution for a given problem in Cody
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nicolas Douillet
am 19 Jun. 2025
Kommentiert: Nicolas Douillet
am 25 Jun. 2025
Hi,
When I test it in the scratch pad, all the tests run successfully.
However, when I try to submit it -since the begining of the week now- I get the recurrent server error message :
"The server is not available. Wait a few minutes, and then retry your request. If the problem persists, contact the instructor."
Could you please help ?
Thank you
My solution by the way (even it may not be perfect, I don't see any reason it would come from here ?) :
function [pp,a,b] = PythagoreanPrime(n)
u = [];
k = 5;
while numel(u) < n
[r,a,b] = isPythagoreanPrime(k);
if r
u = cat(2,u,k);
end
k = k + 2;
end
pp = u(end);
end
function [r,a,b] = isPythagoreanPrime(p)
r = (mod(p-1,4) == 0) & isprime(p);
if r
k = 1;
while k < floor(0.5*p)
c = [k,p-k];
if sum(floor(sqrt(c)) == sqrt(c),2) == 2
a = sqrt(k);
b = sqrt(p-k);
break;
end
k = k + 1;
end
else
a = [];
b = [];
end
end
0 Kommentare
Akzeptierte Antwort
Swastik Sarkar
am 25 Jun. 2025
I have encountered and resolved the issue you described. Upon investigation, it appears that the server error arises when the input value exceeds a certain threshold (e.g., 10,000). This is likely due to performance inefficiencies in the current implementation.
In particular, operations such as frequent use of numel() within loops and dynamic array concatenation can significantly impact execution time and memory usage. These patterns tend to scale poorly with larger inputs and may lead to server timeouts or instability.
I would recommend reviewing the algorithm with a focus on computational efficiency. Consider alternatives that reduce redundant operations and avoid dynamic memory allocation within iterative structures.
All the best !
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!