# MATLAB Spoken Here

## The Master Speaks: An Interview with Cody Champion @bmtran

Bryant Tran, better known to the Cody-playing world as @bmtran, has been the leading player on Cody since the week it launched. What is the secret to his Cody-dominating awesomeness? We were intrigued, so we tracked him down and asked him a few questions. Bryant graciously agreed to let us publish the resulting Q & A here.

Want to become a Cody champ yourself? Read and learn…

Q: Tell us a little about yourself and your experience with MATLAB. Where are you now… grad school where and for what? When did you learn MATLAB? When did you first realize you were a major power user?

A: My name is Bryant, and I’ve been born and raised in Austin, Texaas. I did my undergraduate degree at the Cockrell School at The University of Texas at Austin (Go Horns!) in Electrical Engineering, and am currently pursuing a Masters of Science in Mechanical Engineering studying Acoustics. I’ve been using MATLAB for about two years now. I vaguely knew about MATLAB during my undergrad (http://koentmnd.ytmnd.com/) though I was jaded into thinking it was extremely slow and inefficient (1-based indexing had a lot to do with that).

After getting a summer research position when I graduated, I began learning how to use MATLAB for signal processing. At the time, I was still convinced that C was the way to go, so the first advanced item I learned how to do was to use the MEX interface. I eventually realized the error of my ways and slowly began to learn about vectorization and logical indexing through the resident MATLAB guru in my group, and the rest is history! I’m now convinced that MATLAB is one of the best and most accessible programming paradigms in existence for scientific computing.

Q: Do people come to you for MATLAB help?

A: I’m definitely one of the go-to MATLAB “experts” at my workplace. I’m mostly helpful in doing performance analysis and optimization. One time, I was able to speed up a coworkers code from 3 hours to 13 seconds (830x speedup!) primarily through vectorization.

Q: How did you find out about Cody?

A: I was interested in the semiannual MATLAB contests, so I signed up for the mailing list since I kept missing them (I’ve yet to submit a solution to a contest, whoops). When Cody was released, I got an email on that mailing list. It was pretty good timing too since I had, just a couple weeks before, started doing Project Euler in MATLAB.

Q: We were all amazed at how quickly you solved all 96 of our original problems. Tell us about that first night.

A: When I started, I didn’t know it was the first day. I assumed that it had been going on for a while and I just kind of jumped in. I didn’t even realize that there was a scoring system at first; I just wanted to solve all of the problems, especially since the majority were fairly simple. As I said before, I’d been doing Project Euler for a couple weeks before I started Cody, and the momentum just carried. The same goes for the original 96: I just kept solving problems mechanically until I realized that I had solved the majority and I just had to finish it up!

Q: What motivates you to play? Is staying in first place a major factor?

A: I always enjoyed puzzles as a kid, and I’m arguably a pretty good programmer, so it kind of fits. Staying in first place was never really that big of motivation, but when Alfonso was creeping up on me in March, I realized that I was more competitive I had originally thought. The biggest motivation for me most of the time was 100% completion, which I had a handle on for a while. This was especially easy since Cody sorts the unsolved problems at the beginning. It started to curb with Matt Fig’s Mechanics I, with Robert Canfield’s minimization problems, and eventually with Richard Zapor’s insanity problems.

Q: You’ve been number one since the first week of the contest. Do you watch the leaderboard to see who’s gaining on you?

A: I do watch the leaderboard just to see if my rank has changed and who is number 2. I’ve since made a Trendy plot of my rank. I wish I could retroactively look up the scores and ranks and plot them.

Q: What does a typical session look like for you? When you’re solving a new problem, do you like to get a good answer in quickly and then tune it steadily into a better answer? Or do you like to knock them down quickly and move on?

A: When I first started and Alfonso Nieto-Castanon was submitting some top-notch solutions, I would try extremely hard to steal the leader spot from him (though I rarely ever did). Recently, I have much less free time since my research picked up, so I just solve the problem, look at the other answers, tweak it maybe once or twice, and then move on.

Q: What makes a good Cody problem? What are some simple mistakes that problem authors should avoid?

A: I think the best advice I could give to someone making a problem is to make a varied and comprehensive test suite. There are a fair number of hackers out there who will exploit weaknesses on that front (myself included). I also really appreciate good examples and references so I can understand the topic more.

Q: What makes a good Cody answer? Obviously Cody wants your answer to be short, but beyond that what makes a beautiful answer?

A: This might get controversial, but I like Cody answers that use exotic MATLAB functions that I either didn’t know about before or didn’t think about using in that way before. I find that they really stretch my understanding of the scope and ability of a lot of the MATLAB functions, which effectively makes MATLAB more powerful to me.

Q: Do you have any favorite problems or favorite answers you’d like to call out?

A: My favorite Cody problems are those that address an interesting topic in an elegant fashion. Not to toot my own horn, but my abacus problem is one of my favorites; the soroban abacus is an iconic but not well-understood math tool, and reading one is a very simple task. I’ve been surprised at how plentiful and varied the solutions are. My simple maze-solving problem is another of my favorites that I’ve generated since it’s a well-explored topic with solid graph theory behind it (and it comes in handy when you need to solve a maze!). I also tend to like any string manipulation problems because I find regular expressions to be cryptic, strange, and beautiful.

My favorite answers are anything that Alfonso Nieto-Castanon has ever submitted. His work is elegant and refined, and I learn a lot by figuring out and copying what he has done.

Q: What are some of your favorite ways to turn a short answer into a really short answer? Do you have any “guilty pleasures” where you know the code won’t win a beauty contest, but it’s great from a Cody point of view?

A: Well the most obvious of these is to eliminate concatenation; str2num is probably the quickest way to really cut down on the size of a program. Another one that comes in handy for me is using interp1 to do indexing since you can do it in one line with few arguments.

Q: Have you learned anything playing Cody that’s useful to you in your “real world” coding?

A: The skills I’ve gotten from Cody mostly extend to my knowledge of the way that MATLAB works as well as the breadth of functions that I’m familiar with. My coding style itself has remained fairly consistent.

Q: The most useful MATLAB function that nobody knows about is _______ .

A: bsxfun. also, matrix multiply – it’s surprising how few people can recognize a matrix multiply in their numerical algorithms, and it’s blazing fast in MATLAB.

Q: If I were a MATLAB function, I’d be _______ .

A: profile – I’m obsessed with optimizing my code at work.

### 7 Responses to “The Master Speaks: An Interview with Cody Champion @bmtran”

1. Aurélien replied on :

Nice article. Another trick to decrease the score is to use ans as output of the function. It allows to save 2 points ;-)

A nice feature in Cody would be to receive an email when someone has submitted a leader solution. A watch listbutton like in the FEx would be nice.

I have a question : when we rescore the solution, the solution map is updated but does the score of CODY players is also updated? I mean if you have submitted a solution which is no more good after rescoring, do you lose 10 points?
Maybe CODY players could also receive an alert if their previous correct solution now fail after a rescoring or after someone has added more test suites.

Me the feature that I have learned with CODY is to use num2str-’0′ to transform a number into in a vector:

>> num2str(3249)-’0′

ans =

3 2 4 9

Aurélien

2. Santosh Kasula replied on :

@Aurélien, thank you for your valuable feedback.

Regarding your question about Cody score, we do update the score if a player’s solution becomes incorrect after the rescore, and player loses 10 points if he has no other correct solution to that problem.

3. Aurélien replied on :

CODY workflow:
@Santosh thanks for your answer. So if my previous solution fails after someones has rescored a problem , does this problem appear again in My Cody as unresolved?
If yes , it is cool (no user action required except to retry later another solution) , otherwise I would like to receive an email.

CODY issue:
James (Cody player rank 13) and I found an issue with Cody: we cannot delete our comments : A window asks us if we really want to delete the comment, and then nothing happen once we click “Yes.”. We tried on different machines without sucess.

Thanks

Aurélien

4. Santosh C Kasula replied on :

@Aurélien, if your previous solution fails, that problem appears in the unsolved problems list.

Regarding deleting the comment, it is bug and we are working on a fix for it.

5. Aurélien replied on :

super . Thanks for everything.

6. Aurélien replied on :

Just one side note deleting a comment in Trendy (not Cody) works fine.

you explain the error message about “the server has encountered a problem…” which generally occurs when our solution is too long to evaluate.

I also notice in this page that the URL link “Give it a try!” does not work. The new page displayed is : BAD REQUEST
Grizzly/1.9.36

Best,

Aurélien

7. Helen Chen replied on :

@Aurélien – Thanks for both reports. We will look into these messages.

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 2 + 7 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

News from the intersection of MATLAB, Community, and the web.

These postings are the author's and don't necessarily represent the opinions of MathWorks.