Cody

Problem 1290. A different counting method

Given an array (x) of integers, the "counting" array (y) is showing the number of identical consecutive integers in x in front of the integer itself. For example, if

  • x = 1
  • y = [1 1],

because there is one "1". If then

  • x = [1 1]
  • y = [2 1],

because there are now two "1"s. Finally, a more complex example:

  • x = [1 2 2 4 4 3 0 0 1]
  • y = [1 1 2 2 2 4 1 3 2 0 1 1].

So y gets two elements for each series of identical integers in x. (I hope this problem does not exist already)

Solution Stats

66.15% Correct | 33.85% Incorrect
Last solution submitted on Apr 30, 2016

Problem Comments

Solution Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more