Cody^{™}
Cody™ is a MATLAB Central game that challenges and expands your knowledge of MATLAB and Simulink^{®}. As a web service provided to the community, Cody helps you sharpen your programming skills by solving problems and interacting with other members of the community. With Cody, you can:
To play, you need a Community Profile.
Your use of Cody is subject to the MATLAB Central Terms of Use.
When you see an interesting problem, select it. After the problem opens, click the Solve button and submit your solution. Don't worry about hurting your score or your pride by submitting an incorrect solution. Other players do not see your name with an incorrect solution, nor does an incorrect solution affect your score.
Suppose you choose to solve this problem:
Given an input number x, return the output value x+1.
The author of the problem always provides a starting point, the function template. For our example, the function template is
function y = plus_one(x) y = x; end
The function template does not return the correct solution. In the example, the player edits the function template by adding + 1 to make the code work, as shown below.
function y = plus_one(x) y = x + 1; end
Writing succinct code earns you a better result. Cody uses a nodecount calculation to determine the solution size based on the number of nodes in the parse tree. Think of size as code length. Comments do not contribute to code size.
To illustrate how Cody determines size, here are two solutions to the plusone problem.
function y = plus_one(x) y = x+1; end
function y = plus_one(x) z = x; y = z+1; end
Both functions return the correct solution, but the first solution provides the better score due to its smaller size.
For the Modeling and Simulation Challenge problems, solution size is a function of the number of elements in your model, including blocks, signals and signal branches.
Cody evaluates each solution against a number of tests. Cody determines whether your solution passes these tests and measures the size of your code. Measuring the solution based on code size provides a simple, objective, consistent, and smooth distribution of code sizes for any given problem, as opposed to large, uniform clusters.
The leading solution is the first solution submitted that has the smallest size. When a solution is too long to evaluate, Cody returns the message:
The server has encountered a problem.
To try out the official scoring code yourself, check out calculating size on File Exchange.
To improve your score, solve problems correctly and contribute problems. You earn:
Initially, you see only three Cody Challenge problems. Each time you solve one, Cody unlocks three more. The more you solve, the more Cody reveals to you.
Cody calculates a size for each solution. When you submit a correct solution to a problem, you can see other solutions of the same size (that is, the same length or longer), but not shorter solutions.
Each time you solve a new problem, you unlock all solutions to your previously solved problems in the same group.
You can find content based on defined categories, such as Problems, Solutions, Players, and Comments. After you select a category, Cody also provides options to quickly find what you need.
From the Problems page, you can find problems by filtering your search using the Problems category, a problem group, and search directives you type in the search box.
Filter Options for Finding Problems
Cody provides several defined problem groups.
After you select a problem, Cody provides options to filter solutions using a solution map or a solution list. Cody also provides a Status filter in the left navigational pane to find correct or incorrect solutions from the Solutions page.
Solution Map for Problem 2.
The Solution Map plots solutions as points against two axes: order of arrival (horizontally) and code size (vertically). Correct solutions are green circles. Incorrect answers are red X. Rails of solid green indicate a single obvious answer. More than one rail indicates more than one straightforward answer.
You can find problems, solutions, or players by specifying search directives in the search box or by editing the URL.
From the Search Problems page, specify these directives in the search box.  

Problem Search 
Directive 
Examples 
Problem identified by this number  id:  id:2 
Problems with this group name  group:  group:"Cody Challenge" 
Problems with these specific tags  tag:  tag:"matlab 101" tag:vectors 
Author with this name  author:  author:Doug 
Author identified by this number  author_id:  author_id:869436 
Solver with this name  solver:  solver:Doug 
Solver identified by with this identification number  solver_id:  solver_id:869436 
Problem that supports the use of this toolbox  Product:  product:aerospace product:"Control System Toolbox" 
From the Search Solutions page, specify these directives in the search box.  
Solution Result 
Directive 
Examples 
Player with this name  player:  player:Ned 
Player with this ID number  player_id:  player_id:140947 
Problem with this ID number  problem_id:  problem_id:1 
Solution with this size  size:  size:20 
Solution size with this range  size_range:  size_range:1020 
From the Search Players page, specify these directives in the search box.  
Player Result 
Directive 
Examples 
Player with this ID number 
id: 

Player with this name 
name: 

Player with this email address 
email: 

Players with a public profile in which the Company/Organization field contains this string 
organization: 
player:"Ned Gulley"
.player:"Ned Gulley"
size_range:1020
finds all solutions by players with the name Ned Gulley and a solution size between 10 and 20. player:"Ned"
finds solutions from all players except those with the name Ned.Any Cody player, with a score of 100 or more, can challenge others by adding problems to the Community group. If you have a problem without a solution in mind or are looking for a better way to solve it, post the problem in the Community group to learn what other players can offer.
Follow these guidelines for adding problems:
As you contribute to Cody, you'll earn badges and points that increase your standing in the Cody community.
What badges can I earn?  How can I earn this badge?  Points Awarded 

Solver  Solve a problem for the first time.  10 
Promoter  Like a problem or solution.  10 
Commenter  Add a comment to a problem or solution.  10 
Creator  Create a problem.  20 
Leader  Solve a problem with a best solution.  20 
Quiz Master  50 solvers must solve a problem you created.  20 
Likeable  Must receive 10 likes for a problem you created.  20 
Renowned  Must receive 10 likes for a solution you submitted.  20 
Famous  Must receive 25 total likes for the problems you created.  20 
Celebrity  Must receive 50 total likes for the solutions you submitted.  20 
Puzzler  Create 10 problems.  50 
Speed Demon  Solve a problem first.  50 
Cody Challenge Master  Solve all the problems in the Cody Challenge problem group.  50 
Tiles Challenge Master  Solve all the problems in the Tiles Challenge problem group.  50 
ASEE Challenge Master  Solve all the problems in the ASEE Challenge problem group.  50 
CUP Challenge Master  Solve all the problems in CUP Challenge problem group.  50 
Magic Numbers Master  Solve all the problems in Magic Numbers problem group.  50 
Modeling and Simulation Challenger Master  Solve all the problems in the Modeling and Simulation Challenge problem group.  50 
Scholar  Solve 500 problems.  50 