<p>Alice and Bob are traveling to Rome for separate business meetings.</p>

<p>You are given 4 strings <code>arriveAlice</code>, <code>leaveAlice</code>, <code>arriveBob</code>, and <code>leaveBob</code>. Alice will be in the city from the dates <code>arriveAlice</code> to <code>leaveAlice</code> (<strong>inclusive</strong>), while Bob will be in the city from the dates <code>arriveBob</code> to <code>leaveBob</code> (<strong>inclusive</strong>). Each will be a 5-character string in the format <code>&quot;MM-DD&quot;</code>, corresponding to the month and day of the date.</p>

<p>Return<em> the total number of days that Alice and Bob are in Rome together.</em></p>

<p>You can assume that all dates occur in the <strong>same</strong> calendar year, which is <strong>not</strong> a leap year. Note that the number of days per month can be represented as: <code>[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> arriveAlice = &quot;08-15&quot;, leaveAlice = &quot;08-18&quot;, arriveBob = &quot;08-16&quot;, leaveBob = &quot;08-19&quot;
<strong>Output:</strong> 3
<strong>Explanation:</strong> Alice will be in Rome from August 15 to August 18. Bob will be in Rome from August 16 to August 19. They are both in Rome together on August 16th, 17th, and 18th, so the answer is 3.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> arriveAlice = &quot;10-01&quot;, leaveAlice = &quot;10-31&quot;, arriveBob = &quot;11-01&quot;, leaveBob = &quot;12-31&quot;
<strong>Output:</strong> 0
<strong>Explanation:</strong> There is no day when Alice and Bob are in Rome together, so we return 0.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li>All dates are provided in the format <code>&quot;MM-DD&quot;</code>.</li>
	<li>Alice and Bob&#39;s arrival dates are <strong>earlier than or equal to</strong> their leaving dates.</li>
	<li>The given dates are valid dates of a <strong>non-leap</strong> year.</li>
</ul>

class Solution:
    def countDaysTogether(self, arriveAlice: str, leaveAlice: str, arriveBob: str, leaveBob: str) -> int:
        # months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
        arrive_alice = arriveAlice
        arrive_bob = arriveBob
        leave_alice = leaveAlice
        leave_bob = leaveBob
        later_arrival = max(arrive_alice, arrive_bob)
      
        # Retrieve the earlier departure date between Alice and Bob
        earlier_departure = min(leave_alice, leave_bob)
      
        # Tuple containing the number of days in each month
        days_in_months = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
      
        # Calculate the day of the year for the later arrival date
        arrival_day_of_year = sum(days_in_months[:int(later_arrival[:2]) - 1]) + int(later_arrival[3:])
      
        # Calculate the day of the year for the earlier departure date
        departure_day_of_year = sum(days_in_months[:int(earlier_departure[:2]) - 1]) + int(earlier_departure[3:])
      
        # Calculate and return the number of shared days between Alice and Bob
        # Add 1 because if they arrive and leave on the same day, they have spent 1 day together
        shared_days = max(departure_day_of_year - arrival_day_of_year + 1, 0)
        return shared_days
            
            



        return 10
27