This Python script is designed to simulate a shoe selling scenario. The user inputs the number of shoes available, the sizes of each shoe, and the number of customers. Each customer specifies the shoe size they want to buy and the price they are willing to pay. If the requested shoe size is available, the sale is made and the earnings are added to the total.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The script uses a simple for loop to iterate over each customer's request. It checks if the requested shoe size is available in the list of shoe sizes. If it is, the price offered by the customer is added to the total earnings and the shoe size is removed from the list. This process continues until all customer requests have been processed. The total earnings are then printed out.
x = int(input())
shoe_size = list(map(int, input().split()))
n = int(input())
sell = 0
for _ in range(n):
s, p = map(int, input().split())
if s in shoe_size:
sell = sell + p
shoe_size.remove(s)
print(sell)
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.