One of the things I like about Cody is that it not only encourages you to solve a particular problem, but it encourages you to solve it many different ways. Even better, after you’ve done your best, you can look at how other people solve the same problem. This is often the most enlightening part of the Cody process. I am always surprised and often delighted when I look at other people’s solutions. As I do so, you’re likely to hear me mumbling things like “I didn’t know you could do that” or “That never would have occurred to me” or even “I’ve never heard of that function before!”
Let me give you an example of learning from Cody. Specifically from Problem 661: Spot the outlier. Which of these points is not located on a single line?
If I show you the points as numbers, it’s a little tricky to work it out. But once you see it on a plot, it’s quite easy. Easy for you, but how would you teach MATLAB to solve this problem?
Let’s look at how people solved this one. First of all here is the Solution Map for all the solutions so far.
We can see that the size ranges from 12 to around 200 with a handful of answers even bigger than that. And there are more than twice as many wrong answers as correct answers. But beyond that, there’s not a lot of insight to be gained here.
Here’s a histogram of the size of all the correct answers.
Now we can see that most of the correct answers come in at around size=70. That shows how many people are solving the problem. But how are they solving it? We can sift through individual solutions, but it would be nice if there were some way we could get some insight into lots of solutions at once. One way to do this is with a function cloud. First we boil each solution down until it’s just list of functions. Then we can build up a word cloud with these functions. Thus: function cloud. Here’s a function cloud for all 323 correct solutions received so far.
It’s kind of a mess, but you can get some ideas from what you see there: polyarea, corrcoef, detrend, nchoosek. Each one of these is a clue worth puzzling over. But let’s try another tactic. Let’s make a function cloud of the smallest correct solutions.
Hmmm. Clearly delaunay is the key here. But how? The Delaunay triangulation returns a list of triangles based on the points you give it. By virtue of being the one point that’s off the line, point 2 shows up in all the triangles returned by delaunay. That means that its index, 2, appears in the matrix tri more than any other number. So the mode of the numbers in the matrix is our answer: 2.
It never would have occurred to me to do it that way, but I’m sure glad Cody reminded of this useful function.
Comments are closed.
5 CommentsOldest to Newest
Would you consider adding a word cloud to the problems, using some kind of an algorithm based on the current solution size that was submitted? Example if the user submits a solution with size 100 then provide a word cloud with size 90 and upwards. One downside is that it may provide too much of a hint.
It would be interesting to see topic analysis (clustering based on which functions were used) on this; i.e. how are functions grouped together by solution. The new function fitlda does this and would allow you to look at word clouds of the different topics.
I like the idea of showing function clouds for all problems. You wouldn’t want to show it too soon or it would give away too much. But after you’ve unlocked the answers, it would be a nice thing to show.
How may I blog about some code I have written?
— Alex Geiger
Do you have a blog? It’s easy (and free) to get one over at WordPress.com.