Problem 29. Nearest Numbers
Solution Stats
Problem Comments
-
4 Comments
Best score without using Neural Net Toolbox is 38
123 lol.
It took me half an hour to solve test 4.
pretty simple
Solution Comments
-
1 Comment
Huh, using indices within each other actually worked.
-
2 Comments
Worlds longest solution winner please, cody!
Wow this is long haha. Congrats!
-
1 Comment
This Solution works perfectly on MATLAB. Why not here? Need help
-
1 Comment
my solution passes all the tests in matlab R2011a
-
1 Comment
function [index1, index2] = nearestNumbers(A)
s=[1,1,Inf];
for i = 1:length(A)-1
for j= 1:length(A)-i
s1=[i,i+j,abs(A(i)-A(i+j))];
if s1(3)
-
1 Comment
This passed all of the test cases when using MATLAB on my computer, yet it fails here. Anyone know what's wrong with it? I'd appreciate it!
-
1 Comment
Hard, but doable!
-
1 Comment
I really liked this problem and although I provided a lot of code to solve it I am pleased with the thought process that took me to it.
-
1 Comment
This solution is working on my computer.
I don't understand why it is not working
-
1 Comment
why is this not working? gives correct solution to all test cases on my computer
-
1 Comment
Another unreadable statement. Does anyone else have trouble using backspace in the "comment on solution box"?
-
3 Comments
This only works if you have the Neural Network Toolbox
Until they are banned like other functions, many people are using these. It is interesting that only a subset of functions work.
I am partial to dist, it's such a useful function...
-
1 Comment
Is dist() still available on Cody?
I thought it required one of multiple toolboxes
Problem Recent Solvers3941
Suggested Problems
-
7176 Solvers
-
Increment a number, given its digits
610 Solvers
-
680 Solvers
-
749 Solvers
-
Calculate Amount of Cake Frosting
17668 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!