# THE "SOCK LAUNDRY" SOLUTION

As simple as it may sound ,sock laundry can be a pain in the ass.
knowing what to do first ,when to do it ,and when next to make a move.
This laundry takes a lot of thinking or maybe not so much,take a deep breath ,relax you are about to do this .
In this sock Laundry Solution,a function is required to take three arguments

1. An array of Cleans socks
2. An array of Dirty socks
3. The maximum number of washes

Pretty clear right ?
let's start with a case where number of washes is equal to zero ,this means that the dirty socks will not be washed.In this case we return only the possible number of pairs in the clean socks array.

## A CASE WHERE NUMBER OF WASHES IS EQUAL TO 0

The first step is to check for the possible number of washes
if the number of washes is less than 1,pair the array of clean socks and return count,which is equal is number of pairs .

## A CASE WHERE NUMBER OF WASHES IS GREATER THAN DIRTYSOCKS.length

if the number of washes is greater than 0.check if the number of washes is greater than the length of the DIRTYSOCKS array.
In this case where number of washes is greater than the length of the dirty sock array,we pair the clean and dirty socks array and return the combined pair .

## GET PAIRS FROM THE ARRAYS

Create a function to get the number of paired and unpaired socks.

## CHECK FOR UMATCHED CLEAN SOCKS AGAINST THE DIRTY SOCKS

The Sock Laundry Solution requires two functions

One that returns the number of pairs in a given array
and another that takes two arrays and checks for matching pairs while it increments the number of washes.

Easy right ?

## Now let's do some laundry !

Posted on by:

### Discussion

Very good write up.