Discover MakerZone

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

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!

Problem 1440. USC Spring 2013 ACM: Snow Cones

Created by Richard Zapor

This Challenge is to solve the USC Spring 2013 ACM Contest Problem F, Snow Cones.

Summary of Challenge is to Swap the Snow Cones in the minimal number of swaps so the children all have their selected flavor. There are only two flavors, X and O. Input is the string of distributed Cone flavors and a string of desired Cone flavors. Adjacent children may exchange cones but in any one round a child may only swap with one other child.

Determine minimum number of Swap rounds to convert the Distributed to the Desired Cone flavor sequence.

Input: From XXO to OXX Output: 2

Input: From OXOX to XOXO Output: 1

Only two competitors solved this challenge.

A little complex requiring a Matlab 3-Liner solution versus Cao's C solution


Problem Group

Solution Statistics

12 correct solutions 2 incorrect solutions
Last solution submitted on Dec 15, 2014

Solution Comments