MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodayPedro submitted a Comment to Solution 237221

Hi, Florent.
The scoring in Cody is based on the number of nodes in the parse tree, and strings only require one node.
You can have a look for yourself by typing:
'>> mtree('back_and_forth.m','-file').show'.
Try to do it for the same code, without str2num, and you'll see that even small things like parenthesis or plus signs require their own node in the tree.
In terms of performance, the two versions are not so different. The problem here is that every solution, that use str2num in this way, will have the same Cody score, regardless of how elegant or efficient the anonymous function is.

on 23 May 2013

Pedro submitted a Comment to Solution 226226

That would be something, wouldn't it? The mistake was copy-pasting this version, with the [1 1]s, instead of a version without them. They are not needed, as you noticed.

on 16 May 2013

Pedro submitted a Comment to Solution 226226

Hi, Heather. To be honest, this was an older version that I was using to test containers.Map, and ended up submitting by mistake.

on 14 May 2013

Pedro submitted a Comment to Solution 237221

Sorry for the nasty solution. I'm hoping the use of str2num and anonymous functions will eventually be limited, since most simple problems can be solved with this cheat.

on 28 Apr 2013

Pedro submitted Solution 227225 to Problem 14. Find the numeric mean of the prime numbers in a matrix.

on 4 Apr 2013

Pedro submitted Solution 227224 to Problem 14. Find the numeric mean of the prime numbers in a matrix.

on 4 Apr 2013

Pedro submitted Solution 227091 to Problem 38. Return a list sorted by number of occurrences

on 4 Apr 2013

Pedro submitted Solution 226380 to Problem 158. Is my wife right? Now with even more wrong husband

on 2 Apr 2013

Pedro submitted Solution 226086 to Problem 38. Return a list sorted by number of occurrences

on 1 Apr 2013

Pedro submitted Solution 225474 to Problem 10. Determine whether a vector is monotonically increasing

on 29 Mar 2013

Pedro submitted Solution 225472 to Problem 10. Determine whether a vector is monotonically increasing

on 29 Mar 2013

Pedro submitted Solution 225408 to Problem 17. Find all elements less than 0 or greater than 10 and replace them with NaN

on 29 Mar 2013

Pedro submitted Solution 225407 to Problem 17. Find all elements less than 0 or greater than 10 and replace them with NaN

on 29 Mar 2013