7 kyu

80's Kids #3: Punky Brewster's Socks

394 of 1,371NateBrady23

Description:

Punky loves wearing different colored socks, but Henry can't stand it.

Given an array of different colored socks, return a pair depending on who was picking them out.

Example:

getSocks('Punky', ['red','blue','blue','green']) -> ['red', 'blue']
getSocks('Punky', ['red','blue','blue','green']) -> ['red', 'blue']
get_socks('Punky', ['red','blue','blue','green']) -> ['red', 'blue']
get_socks('Punky', ['red','blue','blue','green']) -> ['red', 'blue']
getSocks("Punky", ["red","blue","blue","green"]) -> ["red", "blue"]

Note that Punky can have any two colored socks, in any order, as long as they are different and both exist. Henry always picks a matching pair.

If there is no possible combination of socks, return an empty array.

Check out my other 80's Kids Katas:
Fundamentals
Algorithms
Arrays

Stats:

CreatedDec 5, 2015
PublishedDec 5, 2015
Warriors Trained2446
Total Skips122
Total Code Submissions8847
Total Times Completed1371
JavaScript Completions394
Ruby Completions140
Python Completions411
Java Completions482
CoffeeScript Completions14
Total Stars25
% of votes with a positive feedback rating86% of 267
Total "Very Satisfied" Votes205
Total "Somewhat Satisfied" Votes47
Total "Not Satisfied" Votes15
Ad
Contributors
  • NateBrady23 Avatar
  • GiacomoSorbi Avatar
  • hilary Avatar
  • alessandrodalbello Avatar
  • Blind4Basics Avatar
  • FArekkusu Avatar
Ad