6 kyu

Masquerade Waiting Line

264 of 418cdsa142

Description:

Your friend has invited you to a party, and tells you to meet them in the line to get in. The one problem is it's a masked party. Everyone in line is wearing a colored mask, including your friend. Find which people in line could be your friend.

Your friend has told you that they will be wearing a RED mask, and has TWO other friends with them, both wearing BLUE masks. Your friend and their friends will be adjacent to one another, and you don't know which order they will be standing in.

Input to the function will be an array of strings, each representing a colored mask. For example:

var line = ['blue','blue','red','red','blue','green'];
line = ['blue','blue','red','red','blue','green']
line = [Blue,Blue,Red,Red,Blue,Green]

The output of the function should be the number of people who could possibly be your friend.

friendFind(['blue','blue','red','red','blue','green','chipmunk'])  // return 1
friend_find(['blue','blue','red','red','blue','green','chipmunk'])  # return 1
friendFind [Blue,Blue,Red,Red,Blue,Green,White] -- returns 1
Algorithms
Arrays
Puzzles

Stats:

CreatedApr 23, 2014
PublishedApr 23, 2014
Warriors Trained856
Total Skips49
Total Code Submissions2836
Total Times Completed418
JavaScript Completions264
Python Completions166
Haskell Completions5
Total Stars13
% of votes with a positive feedback rating90% of 152
Total "Very Satisfied" Votes127
Total "Somewhat Satisfied" Votes20
Total "Not Satisfied" Votes5
Total Rank Assessments23
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • cdsa142 Avatar
  • JohanWiltink Avatar
  • Firefly2002 Avatar
  • FArekkusu Avatar
  • cliffstamp Avatar
  • tobeannouncd Avatar
  • saudiGuy Avatar
Ad