Problem 44375. Missing five
Solution Stats
Problem Comments
-
4 Comments
Too bad this problem number has a '5' in it! :-)
Ha Ha! six is the new 5!
function y = dec2missing5(x)
vec=[];
for i=1:15000
ele=num2str(i);
for j=1:length(ele)
if ele(j)=='5'
ele='';
break;
end
end
vec=[vec str2num(ele)];
end
y=vec(x);
end
why my solution is wrong???
You should return the last element of the vector
Solution Comments
-
1 Comment
nonary
-
1 Comment
Any suggestions on my brute force method?
-
1 Comment
sorry, I added a couple of test cases to discourage this sort of solutions
Problem Recent Solvers317
Suggested Problems
-
Select every other element of a vector
25169 Solvers
-
Read a column of numbers and interpolate missing data
1703 Solvers
-
Get the area codes from a list of phone numbers
780 Solvers
-
Back to basics 4 - Search Path
340 Solvers
-
Flip the vector from right to left
4911 Solvers
More from this Author38
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!