Cody

Problem 2260. GJam 2011 Africa Qual A: Maximum Loop Size

This Challenge is derived from GJam 2011 Africa: Closing the Loop. Small Case Google Code Jam 2014 Kicks Off its Qualifier round April 11. GJam Registration. The Test Suite, at the bottom, contains a full GJam file input read, process, and Output example.

Create the maximum length Loop of alternating Segment types (0 or 1). Return Maximum Length. Segment connection Knots reduce the Length by 1, including the end to the start knot. If no valid loop can be created then return 0.

Input: M, 2xN matrix of [Lengths(1:N);Types(1:N)], Types are 0 or 1

Output: L, maximum Loop Length of valid alternating segment types

Example: M=[6 1 7 3;1 0 1 0], L=13

Additional GJam solutions can be found at Example GJam Matlab solutions. Select Find Solutions, change Language to Matlab. There were only 50 Qualifier Matlab entrants in 2013 and a mere 2 Matlab users achieved round 2.

Solution Stats

83.33% Correct | 16.67% Incorrect
Last Solution submitted on Nov 24, 2018

Solution Comments

Problem Recent Solvers13

Suggested Problems

More from this Author236

Problem Tags