• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 2. Conditions

Difficulty level:

Task«Time travel»

you & mdash; The chief engineer of the Chronos project, and your team is on the verge of the greatest discovery & mdash; creating a time machine. Everything is ready for the first jump, but there was only one critical aspect of security. The main problem you have to solve, & mdash; This is a prevention of temporary paradoxes. The easiest and most dangerous paradox & mdash; Arrive at a time in time & nbsp; to the moment of departure. This can violate a causal relationship and lead to catastrophic consequences for the whole universe.

rn

Your task & mdash; Write a program for the on -board computer of time machines. The program should request the date of departure (day, month, year) and the date of arrival (day, month, year), and then make the verdict: is it possible to travel, or it will create an unacceptable paradox.

rn the trip is considered possible if the date of arrival coincides With the date of departure or occurs later. If the date of arrival is at least one day of the date of departure, the trip should be blocked.

rn

The on-board computer always requests the data in strict order: first three numbers for the date of departure (day, month, year), and then three numbers for the date of arrival of the arrival of the arrival (Day, month, year).

Input format

six lines in a row. Each line contains one whole number (integer).

rn
    rn
  1. the day of departure
  2. rn
  3. the month of departure
  4. rn
  5. year Sending
  6. rn
  7. arrival day
  8. rn
  9. Month of arrival
  10. rn
  11. the year of arrival
  12. rn

    Output format

    One line (string) containing the verdict of the on-board computer: "Traveling is possible" or "Paradox! Travel is impossible".

    Example

    Input

    15
    5
    2025
    16
    5
    2025

    Output

    Travel is possible

    Hint

    There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution
# Запрашиваем данные для даты отправления
# d1 - день отправления
d1 = int(input()) 
# m1 - месяц отправления
m1 = int(input()) 
# y1 - год отправления
y1 = int(input()) 

# Запрашиваем данные для даты прибытия
# d2 - день прибытия
d2 = int(input())
# m2 - месяц прибытия
m2 = int(input())
# y2 - год прибытия
y2 = int(input())

# Начинаем иерархическую проверку дат
# Сначала проверяем год прибытия относительно года отправления
if y2 > y1:
    # Если год прибытия больше, путешествие точно возможно
    print("Путешествие возможно")
elif y2 < y1:
    # Если год прибытия меньше, путешествие точно невозможно
    print("Парадокс! Путешествие невозможно")
else: # y2 == y1, годы равны, нужно проверять месяц
    # Теперь проверяем месяц прибытия относительно месяца отправления
    if m2 > m1:
        # Если месяц прибытия больше (в том же году), путешествие возможно
        print("Путешествие возможно")
    elif m2 < m1:
        # Если месяц прибытия меньше (в том же году), путешествие невозможно
        print("Парадокс! Путешествие невозможно")
    else: # m2 == m1, и месяцы равны, нужно проверять день
        # Наконец, проверяем день прибытия относительно дня отправления
        if d2 >= d1:
            # Если день прибытия больше или равен (в том же месяце и году), путешествие возможно
            print("Путешествие возможно")
        else: # d2 < d1
            # Если день прибытия меньше, путешествие невозможно
            print("Парадокс! Путешествие невозможно")

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!