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
Problem Comments
-
2 Comments
You need to explain these problems better. It's not always clear what we are supposed to do. I guess that at Google Jam they've explained it better, but the link is currently broken. For instance if you give me two types and ask me to alternate between them I can create an infinite sequence...so why should we stop at some point?
I guess that this is the official description https://open.kattis.com/problems/closingtheloop (found it at a blog.) Please copy from there if that's the case. Basically, Each number represents a length of rope that we are tying in a loop, and each knot consumes 1 unit (1/2 unit from each different type). We must answer what the maximum length of rope is possible for this loop. For instance, if we have 1 unit of red rope (type 0) and tie it with one piece of blue rope (type 1), we end up with a loop of zero units (due to the two knots that should not be taken into account for the length).
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
Determine whether a vector is monotonically increasing
20226 Solvers
-
Convert a numerical matrix into a cell array of strings
1768 Solvers
-
9448 Solvers
-
498 Solvers
-
481 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!