hello so im a new programmer and i want to blog my journy of learning in probleme solving and apps development today i will talk about La Grande Braderie
Problem Description
Imagine a series of shops opening side by side. Each shop occupies an identical space, and we need to compute the starting and ending points of each shop's allocated space along a line.
The program takes in three inputs:
Starting Position: The initial point of the line where the first shop begins.
Shop Width: The width of space each shop occupies.
Number of Shops: The total number of shops lined up.
For example, if our starting position is 10, each shop takes up 5 units of space, and there are 3 shops, our program should output:
Shop 1: starts from 10 and ends at 15
Shop 2: starts from 15 and ends at 20
Shop 3: starts from 20 and ends at 25
So, our expected output is: 10, 15, 20, 25.
Solution Explanation
To solve this, we start with the initial position. For each shop, we calculate the new position by adding the width of each space to the previous position.
Code Example
Here's the Python code to achieve this:
Inputs
position_depart = int(input("Enter the starting position: ")) # Starting position
largeur_emplacement = int(input("Enter the width of each shop: ")) # Width of each shop space
nb_vendeurs = int(input("Enter the number of shops: ")) # Number of shops
Initialize the position for the first shop
resultat = position_depart
print(f"Shop 1: starts from {resultat}")
Calculate and print each subsequent shop's position
for i in range(1, nb_vendeurs):
resultat += largeur_emplacement
print(f"Shop {i + 1}: starts from {resultat}")
Output Breakdown
With the inputs provided:
Starting Position: 10
Shop Width: 5
Number of Shops: 3
Shop 1: starts from 10
Shop 2: starts from 15
Shop 3: starts from 20
Top comments (0)