Raw ruby code solving problems from HackerRank and Kattis.
Sock Merchant
John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are.
Repeated String
Lilah has a string of lowercase English letters that she repeated infinitely many times. Given an integer n find and print the number of letter a's in the first n letters of Lilah's infinite string.
Jumping On The Clouds
The first line contains an integer n, the total number of clouds. The second line contains n space-separated binary integers describing clouds. Print the minimum number of jumps needed to win the game.
Counting Valleys
The first line contains an integer n, the number of steps in Gary's hike. The second line contains a single string s, of n characters that describe his path. Print a single integer that denotes the number of valleys Gary walked through during his hike.