diff --git a/PlaylistChallenge.iml b/PlaylistChallenge.iml new file mode 100644 index 0000000..0ddf51c --- /dev/null +++ b/PlaylistChallenge.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..891bfeb 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -9,6 +9,16 @@ public Music(String[] playList){ } public Integer selection(Integer startIndex, String selection){ - return null; + int count = 0; + int upCount = 0; + + for (int i = 0; i < playList.length; i++) { + if(selection.equals(playList[i])){ + count = Math.abs(startIndex - i); + upCount = Math.abs(startIndex + playList.length - i); + } + + } + return Math.min(count,upCount); } }