## Back From Summer '17 P2: Crayola Lightsaber

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 128M

Author:
Problem types

School's back! You're up to no good again already… While your art teacher, Roger, was looking away, you grab his basket of Crayola™ markers and started connecting them together.

This creates a colorful sword that you can use to hit people that you find annoying with. You want to be able to reach quite far with your sword though, so you keep on connecting.

Although you want your crayon lightsaber to be as long as possible, you also care deeply about it being aesthetically pleasing. For that reason, you choose to never connect two crayons of the same color directly together.

Given the colors of the markers in the basket, what is the longest Crayola™ marker sword you can construct?

#### Input Specification

The first line will contain an integer . This will then be followed by a line of strings that represent the colors of the markers. The colors can be: red, orange, yellow, green, blue, black.

#### Output Specification

The only output is an integer representing the maximum length possible for the marker sword.

#### Sample Input 1

4
red blue green black

#### Sample Output 1

4

#### Sample Input 2

5
yellow orange yellow yellow yellow

#### Sample Output 2

3

#### Explanation for Sample Outputs

For the first example, you can use every marker to make a sword such as the one in the image above.

For the second example, the longest sword you can make is using the markers yellow-orange-yellow, resulting in a length of .

Can someone take a look at my code? It works when I test my code in PyCharm, but the first test case always gives me an IR (Name Error). My output(clipped) is 3. Plz, somebody help me!