Target sorting
Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...

Spot the outlier
All points except for one lie on a line. Which one is the outlier? Example: You are given a list of x-y pairs in a column ...

Miles to go before I sleep
Recently, my car's odometer passed 56789. Given an odometer reading, output how many miles need to be driven to get the next mi...

How long is the longest prime diagonal?
Stanislaw Ulam once observed that if the counting numbers are <http://en.wikipedia.org/wiki/Ulam_spiral arranged in a spiral>, t...

unique with nan
input x = [2 NaN 3 5 NaN; 1 NaN 4 9 NaN; 8 -2 7 6 -2; 7 4 8 5 4]; output y_correct = [2 ...

Solitaire Cipher
Implement the <http://en.wikipedia.org/wiki/Solitaire_(cipher) solitaire cipher>. Since this is from Wikipedia, I am capturin...

Bullseye Matrix
Given n (always odd), return output a that has concentric rings of the numbers 1 through (n+1)/2 around the center point. Exampl...

Simple equation: Annual salary
Given an hourly wage, compute an annual salary

Knight's Tour Checker
Given a matrix a, determine whether or not a legal <http://en.wikipedia.org/wiki/Knight's_tour knight's tour> is present. The kn...

Calculate the Levenshtein distance between two strings
This problem description is lifted from <http://en.wikipedia.org/wiki/Levenshtein_distance>. The Levenshtein distance betwee...

Counting in Finnish
Sort a vector of single digit whole numbers alphabetically by their name, in Finnish. See the Wikipedia page for <http://en.wik...

Renaming a field in a structure array
MATLAB has a <http://www.mathworks.com/help/techdoc/ref/setfield.html setfield> and a <http://www.mathworks.com/help/techdoc/ref...

Implement a ROT13 cipher
Replace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if neces...

Clean the List of Names
Given a list of names in a cell array, remove any duplications that result from different capitalizations of the same string. So...

Remove the polynomials that have positive real elements of their roots.
The characteristic equation for a dynamic system is a polynomial whose roots indicate its behavior. If any of the roots of the p...

Find the palindrome
Given the string a, find the longest palindromic sub-string b. So when a = 'xkayakyy'; you should return b = 'kayak';

Balanced number
Given a positive integer find whether it is a balanced number. For a balanced number the sum of first half of digits is equal to...

Replace NaNs with the number that appears to its left in the row.
Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

Elapsed Time
Given two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, ...

Kaprekar Steps
6174 is the <http://en.wikipedia.org/wiki/6174_%28number%29 Kaprekar constant>. All natural numbers less than 10,000 (except som...

Word Counting and Indexing
You are given a list of strings, each being a list of words divided by spaces. Break the strings into words, then return a maste...

Encode Roman Numerals
Create a function taking a non-negative integer as its parameter and returning a string containing the Roman Numeral representat...

The Goldbach Conjecture
The <http://en.wikipedia.org/wiki/Goldbach's_conjecture Goldbach conjecture> asserts that every even integer greater than 2 can ...

Scrabble Scores
Given a word, determine its score in <http://en.wikipedia.org/wiki/Scrabble Scrabble>. The input string will always be provi...

Prime factor digits
Consider the following number system. Calculate the prime factorization for each number n, then represent the prime factors in a...

Counting Sequence
Given a vector x, find the "counting sequence" y. A counting sequence is formed by "counting" the entries in a given sequence...

Making change
Given an amount of currency, return a vector of this form: [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01] Example: Input a = ...

QWERTY coordinates
Given a lowercase letter or a digit as input, return the row where that letter appears on a standard U.S. QWERTY keyboard and it...

Sums with Excluded Digits
Add all the integers from 1 to n in which the digit m does not appear. m will always be a single digit integer from 0 to 9. no...

What is the next step in Conway's Life?
Given a matrix A that represents the state of <http://en.wikipedia.org/wiki/Conway's_Game_of_Life Conway's game of Life> at one ...