Explanation First off, the 'day6_input'.IO.slurp.chomp bit reads the entire 'day6_input' file into a string and chomps off the trailing newlines. Then, a regex match is performed, which is where the real magic happens. The . ** 4 part matches any 4 characters, and then <?{...}> is used to evaluate a Boolean predicate in the middle of the regex—if the check fails, the current match is thrown out. $/ refers to the text matched so far, so to check if all characters are unique, I use .comb to split it into a list of characters, .unique to remove duplicates, and .join to turn the list back into a string - and finally ~~ to check if it's equal to the original string.
Afterwards it just obtains the index immediately after the end of the final match and prints that out.