Benford's Law states that the distribution of leading digits is not random. This is probably because many things grow logarithmically. Extract the leading digit from these vectors.
Input will be a vector
x = [1 0.3 -2 0.001 -0.0006, 582398, 3020];
Output should be
y = [1 3 2 1 6 5 3];
I added some extra test cases to fail some of the bogus answers.
Amazing Law!!!!!!!!!!!!
I cannot understand the problem.
Interesting. Looks like it failed due to some rounding issue.
Whats wrong here ?
This appears to be the best solution that doesn't use regexp
A good method. num2str
Sorry, I did not want to copy you! Just tried to understand what you did...
Doesn't work if x = 0.3000
The best solution n codesize for me and w/o cheating !
not fun at all :-)
bm, you have many good solutions in Cody. Why put in garbage like this?
You have just made me sad. Sorry.
i wrote this a long time ago (on the third day of Cody). i figured that as soon as the test suite was changed, this solution would be gone with the wind. sorry to anyone i offended :(
Doesn't work if x = 0.3000
Not general. Solution depends on the particular test case.
Doesn't work if x = 0.3000
200 Solvers
654 Solvers
Cell Counting: How Many Draws?
237 Solvers
451 Solvers
Solving Quadratic Equations (Version 1)
355 Solvers