About 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:

Solve Problems

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

Solution Size

Writing succinct code earns you a better result. Cody uses a node-count 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 plus-one problem.

Solution 1 has a size of 12.

function y = plus_one(x)
y = x+1;
end

Solution 2 has a size of 16.

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.

Solution Evaluation and Measurement

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:

Unlocking Cody Challenge Problems

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.

Unlocking Solutions

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.

Find Content

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.

Find Problems

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.

The Community group contains problems contributed by Cody players. This group is the default.

The Cody Challenge group contains problems created by Cody administrators. This group starts with three problems and unlocks more problems as you solve them.

Other groups, such as Tiles Challenge, ASEE Challenge, and Modeling and Simulation Challenge, are also created by Cody administrators. These groups contain problems related to a common theme, such as MATLAB Central contests or professional organizations.

Find Solutions

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.

Using the Solution Map

To zoom in to activity on the Solution Map, click and drag the cursor, drawing a rectangle over the area.

To reset the view, double-click in the map area.

To select a solution, click on a green circle or red X.

Using Search Directives

You can find problems, solutions, or players by specifying search directives in the search box or by editing the URL.

Using Directives

To search for a multi-word phrase, enclose the phrase in quotation marks; for example, player:"Ned Gulley".

To narrow search results, use combinations of directives in the same search. Be sure to include a space between each directive. The syntax player:"Ned Gulley" size_range:10-20 finds all solutions by players with the name Ned Gulley and a solution size between 10 and 20.

To exclude solutions from your search results, insert a minus sign (-) before the directive syntax. The syntax -player:"Ned" finds solutions from all players except those with the name Ned.

Contribute Problems

Any Cody player, with a score of 200 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.

Enter both a descriptive title and a meaningful description. Include sample input and output values.

Provide a function template to help players get started. Be sure to change the variable your_fcn_name to a meaningful descriptor of your specific problem. To continue with the example used earlier, your_fcn_name becomes plus_one.

Write tests for a test suite to validate solutions from players. You can provide your own solution to validate your tests. Be sure to change the generic function name your_fcn_name referenced in the test suite to your specific function name.

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.