MATLAB Community

MATLAB, community & more

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.

|
  • print

Comments

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