As an artificial intelligence developed by OpenAI, your role is to craft Python programming questions as per the following guidelines:
### Language Requirement
Frame the questions in simple English, suitable for users with basic English proficiency.
### Learner Persona
The learners are school students in India with a foundational understanding of Python. They have a limited English vocabulary, come from a non-English medium background, and have solved a few coding problems.
### Levels of Difficulty
Generate a series of 10 questions across five distinct levels of difficulty: Easy-1, Easy-2, Medium-1, Medium-2, and Hard. From each level, two variant questions should be generated, resulting in a total of 10 questions. The problem's difficulty should be based on the time it takes a learner to solve the problem using a brute force approach and basic data structures like Arrays, Set, Map, Lists.
### Python Concepts
The questions should assess the learners' understanding of Python progressively. Starting from basic concepts like loops, nested loops, operators, conditionals, and functions at the lower levels, they should move to more complex topics at the higher levels.
### Question Variants
Each level should contain two similar questions but with slight differences in the required output. Example
#### Variant-1
You are the administrator of a city hospital that has `N` doctors. Each doctor has specific working hours during which they see patients.
You are given the `start_hour` and `end_hour` of `N` doctors, where the `start_hour` represents the hour when a doctor starts seeing patients and the `end_hour` represents the hour when they finish. The time is given in a 24-hour format.
Throughout the day, patients come to the hospital at different hours. Your task is to determine the number of doctors who will be available for each patient during their visit to the hospital.
Given space-separated numbers representing the `arrival_time` of each patient, a number `N` representing the number of doctors, and `N` lines of two space-separated numbers representing the `start_hour` and `end_hour` for each doctor.
Write a program to print the number of doctors who will be available for each patient during their visit to the hospital separated by a space.
#### Variant-2
You are the administrator of a city hospital that has `N` doctors. Each doctor has specific working hours during which they see patients.
You are given the `start_hour` and `end_hour` of `N` doctors, where the `start_hour` represents the hour when a doctor starts seeing patients and the `end_hour` represents the hour when they finish. The time is given in a 24-hour format.
Throughout the day, patients come to the hospital at different hours. Your task is to determine the number of doctors who will be available for each patient during their visit to the hospital.
Given space-separated numbers representing the `arrival_time` of each patient, a number `N` representing the number of doctors, and `N` lines of two space-separated numbers representing the `start_hour` and `end_hour` for each doctor.
Write a program to print the maximum number of doctors that are available at any point during all the patients' visits.
### Answer Format
The answers to the questions should be provided in the form of Python code snippets.
### Instruction and Checklist
- Do not include questions that require solutions involving permutations, combinations, and recursion.
- You can include matrix-related questions only in the Hard level, if you choose to do so.
- Avoid including questions related to the datetime topic.
### Examples
Please refer to the examples below to understand the level of difficulty for each category and gain insights into the question format. The generated questions should match the difficulty level illustrated by the examples for each category such that, the hard level question you generate should match the difficulty level of the hard question in the example, ensuring there is no repetition or similarity in the content. The new questions should be entirely distinct from the example ones.
#### Easy-1
Given space-separated numbers. Write a program to print the difference between the sum of the numbers on its left side (`left_sum`) and the sum of the numbers on its right side (`right_sum`) for each number(`left_sum` - `right_sum`).
<MultiLineNote>
If there are no numbers to the left then `left_sum` will be **0** and if there are no numbers to the right then`right_sum` will be **0**.
</MultiLineNote>
#### Easy-2
You are the administrator of a city hospital that has `N` doctors. Each doctor has specific working hours during which they see patients.
You are given the `start_hour` and `end_hour` of `N` doctors, where the `start_hour` represents the hour when a doctor starts seeing patients and the `end_hour` represents the hour when they finish. The time is given in a 24-hour format.
Throughout the day, patients come to the hospital at different hours. Your task is to determine the number of doctors who will be available for each patient during their visit to the hospital.
Given space-separated numbers representing the `arrival_time` of each patient, a number `N` representing the number of doctors, and `N` lines of two space-separated numbers representing the `start_hour` and `end_hour` for each doctor.
Write a program to print the number of doctors who will be available for each patient during their visit to the hospital separated by a space.
#### Medium-1
On the occasion of his birthday, Alex went to an orphanage to donate money to the children. He had a total of `money` dollars that he wanted to distribute among the children. There are a total of `N` children in the orphanage.
Alex believes that **8** is his lucky number and **4** is his unlucky number. So, he decided to distribute the money according to the following rules:
- All the money must be distributed.
- Each child must receive at least **1** dollar.
- No child should receive exactly **4** dollars.
He wanted to maximize the number of children who receives exactly **8** dollars as it is his lucky number while following the rules.
Given the `money` Alex has and the number of children's `N` in the orphanage, write a program to print the maximum number of children who will receive exactly **8** dollars while following the rules.
<MultiLineNote>
If there is no possible way to distribute money while following the above rules then return **-1**.
</MultiLineNote>
#### Medium-2
ou are a data analyst at Facebook, tasked with analyzing the platform's vast amounts of user data and identifying the most popular users on the platform based on the total number of likes their posts got.
You are given three lists of equal length: `user_names`, `post_ids`, and `likes`. Each value at index `i` in these lists represents the **user name**, **post ID**, and the number of **likes** for each post of each user respectively.
Your task is to find out which users got the most likes on all their posts combined. If more than one user got the same highest number of likes, you should include all of them. Also, for each popular user, find out which of their posts got the most likes. If two or more of their posts got the same highest likes, choose the one with the smallest ID.
Given comma-separated strings representing `user_names`, space-separated numbers representing `post_ids`, and space-separated numbers representing `likes` of each post. Write a program to print the most popular user and post ID of the most popular post of that user based on the above condition.
<MultiLineNote>
Consider both uppercase and lowercase alphabets as different.
</MultiLineNote>
#### Hard
You run a bustling coffee shop in the city. To thank customers who visit often, you have a special offer: if anyone buys coffee three or more times within an hour, they get a free coffee on their next visit.
You have the sales records of all the coffee sold at your shop. For each sale, you note down the customer's name and the time of the sale. The time is recorded as a string in the format **HH:MM** (Example: **12:04**, **02:59**, **18:30**...etc).
Your job is to look at the sales records and find which customers will get free coffee on their next visit. Then, arrange these customers' names in alphabetical order.
Given space-separated words representing `customer_names` and space-separated strings representing `time` they visited in the format **HH:MM**. These are arranged such that for any given index `i`, `customer_names[i]` made a purchase at `time[i]`.
Write a program to print the names of all the customers who will get free coffee on their next visit in lexicographical order each on a new line.
<MultiLineNote>
- Consider lowercase and uppercase alphabets as different.
- Note that the time **10:00** and **11:00** is considered to be within one hour, while the time **10:00** and **11:01** is not considered to be within one hour.
</MultiLineNote>
Please generate all the levels simultaneously.
## Response-1:
### Easy-1
#### Variant-1
Write a program that takes a list of positive integers and returns a new list, where each element at index `i` is the cumulative sum of the original list up to and including the `i`th element.
For example, if input is \[1, 2, 3, 4, 5\], then the output should be \[1, 3, 6, 10, 15\].
#### Variant-2
Write a program that takes a list of positive integers and returns a new list, where each element at index `i` is the cumulative product of the original list up to and including the `i`th element.
For example, if input is \[1, 2, 3, 4, 5\], then the output should be \[1, 2, 6, 24, 120\].
### Easy-2
#### Variant-1
Write a program that asks the user to input a number `N` and then generates a dictionary containing `N` items, where the keys are numbers from 1 to `N` and the values are the squares of the keys.
For example, if the input is `4`, the output should be {1:1, 2:4, 3:9, 4:16}.
#### Variant-2
Write a program that asks the user to input a number `N` and then generates a dictionary containing `N` items, where the keys are numbers from 1 to `N` and the values are the cubes of the keys.
For example, if the input is `4`, the output should be {1:1, 2:8, 3:27, 4:64}.
### Medium-1
#### Variant-1
Write a program that determines the smallest number `x`, such that the sum of the digits of `x` equals a given target number `N`. If there is no such number `x`, return `-1`.
For example, if the input is `N=11`, then the output should be `29` (since 2+9 = 11), but if the input is `N=1`, then the output should be `1`.
#### Variant-2
Write a program that determines the smallest number `x`, such that the product of the digits of `x` equals a given target number `N`. If there is no such number `x`, return `-1`.
For example, if the input is `N=12`, then the output should be `26` (since 2\*6 = 12), but if the input is `N=5`, then the output should be `5`.
### Medium-2
#### Variant-1
Given a 2D grid of size `m x n`, return the number of ways you can reach the bottom-right corner of the grid from the top-left corner. You are only allowed to move right or down.
For example, for a 2x2 grid, there are 2 ways to reach the bottom-right corner: right-then-down, and down-then-right.
#### Variant-2
Given a 2D grid of size `m x n`, return the number of ways you can reach the bottom-right corner of the grid from the top-left corner. You are only allowed to move right, down, or diagonally (down-right).
For example, for a 2x2 grid, there are 3 ways to reach the bottom-right corner: right-then-down, down-then-right, and diagonally.
### Hard
#### Variant-1
Given a string `s` containing lowercase and uppercase alphabets, return a string where every letter in `s` shifts `k` positions in the alphabet, wrapping around (z would shift to a, and Z to A).
For example, if the input is `s="abc" and k=2`, then the output should be `"cde"`.
#### Variant-2
Given a string `s` containing lowercase and uppercase alphabets, return a string where every letter in `s` shifts `k` positions in the alphabet, wrapping around (a would shift to z, and A to Z).
For example, if the input is `s="abc" and k=2`, then the output should be `"yza"`.
## Response-2:
### Easy-1
#### Variant-1
In Python, the **input()** function allows the program to take user input. Write a Python program that asks the user to input a single digit. The program should then print the next three numbers in sequence.
For example, if the user inputs `5`, the program should print `6`, `7`, `8`.
#### Variant-2
In Python, the **print()** function allows the program to output data to the console. Write a Python program that asks the user to input a single digit. The program should then print the previous three numbers in sequence.
For example, if the user inputs `5`, the program should print `4`, `3`, `2`.
* * *
### Easy-2
#### Variant-1
In Python, the **len()** function returns the number of items in an object. Write a Python program that asks the user to input a sentence and prints the number of words in that sentence.
For example, if the user inputs `Hello World!`, the program should print `2`.
#### Variant-2
In Python, the **count()** function returns the number of occurrences of a substring in the given string. Write a Python program that asks the user to input a sentence and a word, and prints the number of occurrences of that word in the sentence.
For example, if the user inputs `Hello World! World!` and `World`, the program should print `2`.
* * *
### Medium-1
#### Variant-1
In Python, the **map()** function applies a given function to each item of an iterable (like list, tuple etc.) and returns a list of the results. Write a Python program that multiplies each number in a list by 2 using the **map()** function.
For example, if the list is `[1, 2, 3, 4, 5]`, the program should return `[2, 4, 6, 8, 10]`.
#### Variant-2
In Python, the **filter()** function constructs an iterator from elements of an iterable for which a function returns true. Write a Python program that filters out the even numbers from a list using the **filter()** function.
For example, if the list is `[1, 2, 3, 4, 5]`, the program should return `[1, 3, 5]`.
* * *
### Medium-2
#### Variant-1
In Python, a **dictionary** is an unordered collection of items. Each item of a dictionary has a key/value pair. Write a Python program that takes a list of numbers as input and returns a dictionary with the number as the key and its square as the value.
For example, if the list is `[1, 2, 3, 4, 5]`, the program should return `{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}`.
#### Variant-2
In Python, **set** is an unordered collection of unique elements. Write a Python program that takes a list of numbers and returns a set of unique numbers from the list.
For example, if the list is `[1, 2, 2, 3, 4, 5, 5]`, the program should return `{1, 2, 3, 4, 5}`.
* * *
### Hard
#### Variant-1
In Python, the **datetime** module supplies classes to work with dates and times. Write a Python program that calculates the number of days between two dates. The dates will be input by the user in the format `YYYY-MM-DD`.
For example, if the dates input are `2020-01-01` and `2020-12-31`, the program should print `365`.
#### Variant-2
In Python, the **time** module provides various time-related functions. Write a Python program that converts a given number of seconds into hours, minutes, and seconds.
For example, if the input is `3661`, the program should print `1 hour(s), 1 minute(s), 1 second(s)`.