Codyssi - Supplies in Surplus! Part 1 Difficulty Rating: 1 After a refreshing night of sleep, you’ve arrived at the seaside! There: a wooden Greek warship, complete with masts and sails. That must be the vessel you’ll use for your journey. Oddly, there seem to be very few technological devices on the ship… “Ah, you must be the team from the lab! I’m the captain of the vessel ODC-US. My crew will be at your service for your journey to Atlantis. We’ll be setting sail soon, but we’ve received a surplus of supplies from the lab—there’s no way we could load all this onto the ship.” Sure enough, there are clearly too many piles of boxes to load onto the ship. You’ll probably only have enough space for essentials, especially since the captain’s crew is also on the ship. One of the crewmates hands you an inventory list, and he explains the situation to you. Each box has one number label. Boxes with the same number label contain the same items. Each line in the list contains two ranges of numbers. Each range of numbers represents the numbers on the boxes in each pile. For example, 3-5 represents a pile with 3 boxes, labelled 3, 4, and 5 respectively. First, you’ll have to figure out the total number of boxes in all of the piles combined. For example, consider the (smaller) inventory list below: 8-9 9-10 7-8 8-10 9-10 5-10 3-10 9-10 4-8 7-9 9-10 2-7 The first range, 8-9, contains 2 boxes. The second range, 9-10, contains 2 boxes. The third range, 7-8, contains 2 boxes. The fourth range, 8-10, contains 3 boxes. By continuing this process, we can determine that the total number of boxes (for this file) is 43. Considering your file, what is the total number of boxes in all of the piles? Part 2 Difficulty Rating: 2 The calculation was correct, but there are noticeably fewer piles than expected… You’ll just ask the captain about this. “Oh, he must’ve misremembered. Each line in the file actually represents one pile.” Ah, a miscommunication. Apparently, both ranges on a line represent one pile. That’s alright, as you still have some time. The captain tells you that if a number is in any of the ranges on a line, then that pile contains one box labelled with that number. For example: A pile represented by 6-8 8-10 contains 5 boxes (labelled 6, 7, 8, 9, and 10). A pile represented by 5-6 7-8 contains 4 boxes (labelled 5, 6, 7, and 8). A pile represented by 3-4 7-8 contains 4 boxes (labelled 3, 4, 7, and 8). You’ll still have to figure out the total number of boxes in all of the piles combined. For example, consider the same sample inventory list: 8-9 9-10 7-8 8-10 9-10 5-10 3-10 9-10 4-8 7-9 9-10 2-7 The first pile, represented by 8-9 9-10, will contain 3 boxes (labelled 8, 9, and 10). The second pile contains 4 boxes (labelled 7, 8, 9, and 10). The third pile contains 6 boxes, the fourth pile contains 8 boxes, the fifth pile contains 6 boxes, and the sixth pile contains 8 boxes. So, for this file, there will be 35 boxes in total. Considering your file, what is the total number of boxes in all of the piles? Part 3 Difficulty Rating: 3 You send the calculation to the lab, and they confirm that none of the boxes have gone missing in transmission. Great! Due to space constraints, you’ll only be able to load two piles of supply boxes onto the ship. As boxes with the same label contain the same items, you should take as many uniquely labelled boxes as possible. Suddenly, the captain calls out to you. “We’re short on time! We’ll only be able to load two piles that are adjacent to each other!” You observe your surroundings: the piles of boxes are already arranged in a single line. The first line in the file represents the first pile, the second line in the file represents the second pile, and so on. As you are short on time, you’ll have to find the maximum number of uniquely labelled boxes in two adjacent piles. For example, consider the same sample inventory list: 8-9 9-10 7-8 8-10 9-10 5-10 3-10 9-10 4-8 7-9 9-10 2-7 There are 4 uniquely labelled boxes when pile 1 and pile 2 are combined. There are 6 uniquely labelled boxes when pile 2 and pile 3 are combined. Continuing the process, there are 8 when pile 3 and pile 4 are combined, 8 when pile 4 and pile 5 are combined, and 9 when pile 5 and pile 6 are combined. So, the maximum number of uniquely labelled boxes in two adjacent piles (for this file) is 9. Considering your file, what is the maximum number of uniquely labelled boxes in two adjacent piles?