List of Orders |Programming_info || python_problem_17

 List of orders from amazon are given along with the departure date. The Amazon are adding features to their delivery management system in iterations. The Support desk is finding it difficult to filter the Trains with the departure dates from the data available.

Can you please implement a date filter to help the Support desk with this regard?
 
Input Format :
The first line of input is an integer that corresponds to the number of records, 'n'.
The next 'n' line corresponds to the records.
The last line of input consists of the date to be filtered.
 
Output format :
The first line of the output is a set of comma seperated string containing the cargo name and date. 
The next lines consists of the names of the cargos printed one next to  other seperated by new line.
 
Refer to sample input and output for formatting specifications and more details.
 
Sample Input 1:
5
Sparx_Shoes,11-12-2013
Suits,29-12-2016
SAMSUNG Mobiles,27-03-2017
Tissot Watchs,10-04-2014
Levis Denim,27-03-2017
27-03-2016
 
Sample Output 1:
[('Sparx_Shoes', '11-12-2013'), ('Suits', '29-12-2016'), ('SAMSUNG Mobiles', '27-03-2017'), ('Tissot Watchs', '10-04-2014'), ('Levis Denim', '27-03-2017')]
Suits
SAMSUNG Mobiles
Levis Denim
 
Explanation for Sample:
First line of the output contains the cargo details in the form of list of tuples.
The next 3 lines are the cargo names, whose departure date is greater than the filter date.
 
Solution:
import datetime
n=int(input())
l=[]
for i in range(n):
    ls=[]
    x,y=input().split(",")
    ls.extend((x,y))
    ls=tuple(ls)
    l.append(ls)
d=input()
day,month,year=map(int,d.split("-"))
date=datetime.date(year,month,day)
print(l)
for i in l:
    day,month,year=map(int,i[1].split("-"))
    date1=datetime.date(year,month,day)
    if date1>date:
        print(i[0])

Share:

No comments:

Post a Comment

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support