-
7 Comments
Cannot be reproduced, creates an error in execution in R2016a.
I noticed a lot of leading solutions are using 'str2num' or regexp functions, though codes can be written in a simpler and shorter way without invoking these functions. e.g., in this case, 1:10; would have done trick but still, it shows a larger size compared to the above solution. can anyone explain?
@Imran it's a quirk of the Cody scoring system. A solution's size is the node count in the internal MATLAB representation of the code submitted. Try running m = mtree(fileread("oneToTen.m")); in the console; then m.dumptree will show you the parse tree, and m.count will show you the number of nodes, i.e. the score it'll get on Cody. The reason that this achieves a lower size than more direct solutions can be found by comparing the parse trees.
Suggested Problems
-
Permute diagonal and antidiagonal
461 Solvers
-
The Answer to Life, the Universe, and Everything
544 Solvers
-
647 Solvers
-
Height of a right-angled triangle
1865 Solvers
-
741 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!