MATLAB Community

MATLAB, community & more

Cody’s Solution Map

Last week we added some exciting new features to Cody. I want to mention the new features and then go back and talk more about one of the old features.

What’s new? Here’s the short list.

  • Notifications
  • A Solutions page
  • A Comments page

If you like Cody, you’ll definitely want to turn on notifications for new problems. Here’s how you do it. Go to your “My Cody” page. At the top right you’ll see a link for My Cody Preferences. Once there you can check boxes so that you will be notified in any of the following situations:

  • New problem
  • Comment on a problem that you created
  • Comment on a solution to a problem that you created
  • Comment on a solution that you submitted

In addition to notifications, we now have a master solution page and solution search capabilities. From the navigation panel on the left side of the main page, select “Solutions”. From this page you can do interesting searches like: how many solutions use the function bsxfun? Of course, you won’t be able to read through the actual code until you’ve unlocked the answers for the corresponding problem. But as you solve more problems, this search tool becomes an ever more valuable resource. By the way, there are currently 750 solutions that use bsxfun. What is bsxfun? I’m glad you asked. That’s just the kind of thing that Cody is good at. You see all the cool kids using a function you’ve never heard of and you realize that’s it’s time you went and read the documentation.

Along with the solutions page, there’s also an aggregated comments page. I like being able to see what people are talking about, whether it’s an especially interesting solution or a problem that could use an improved test suite.

Finally, as promised, I want to go back to a feature that’s been in Cody since the beginning: the Solution Map. Recall that the Solution Map plots solutions as points against two axes: order of arrival (horizontally) and code size (vertically). Correct answers are green circles. Incorrect answers are red x’s. Cody is a window into how people write code and the Solution Map reveals some interesting patterns.

Some of the patterns are obvious. In a simple problem like Is My Wife Right? we see a rail of solid green. There is a single obvious answer (‘yes’. Duh), and anyone who doesn’t use it is just goofing around.

Some problems, say Triangle Numbers (problem 5), have two rails. There are two straightforward answers, and they really pop out at you in this view.

As the problems get more complicated, there is much more variety in the solution space. Here is the Perfect Squares problem (problem 23).

But within this chaos we find dozens of little dramas, each telling the story of some far-flung soul grappling with ferocious NaNs, sinister array indices, and the beguiling mysteries of the find command. You find small patterns of rising and falling action. In rising action, we observe a pattern of repeated failure as the code gets bigger. Once success has been achieved, we might see falling action: repeated successes as the code gets smaller. Here’s an example. Watch as Cody (and Contest) superstar Alfonso Nieto-Castanon steadily improves his code for problem 317, Find the Stride of the Longest Skip Sequence.

Here’s the link:

Did you notice the solution search functionality in the Solution Map there? We’re doing a search for Alfonso’s code only. Once on this page, you can use the left and right arrows to page through the solutions.

Want to see all the answers to Problem 497 that use the hankel function? Try this search.

Cruise around the solution maps of Cody. Use the search. What dramas do you see?

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.