File tree 1 file changed +67
-0
lines changed
1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ x = []
2
+ def bre1 (x ):
3
+ l = len (x )
4
+ inp = ""
5
+ count = 0
6
+ for i in range (l ):
7
+ count += 1
8
+ if (x [i ]== "~" ):
9
+ break
10
+ else :
11
+ inp += x [i ]
12
+ return (inp ,x [count :])
13
+ def bre2 (v ):
14
+ (v1 ,v2 )= (bre1 (v ))
15
+ (v2 ,v3 )= bre1 (v2 )
16
+ return (v1 ,v2 ,v3 )
17
+ conhead = ["Books" ,"Borrowers" ,"Checkouts" ]
18
+ books = []
19
+ borrowers = []
20
+ checkout = []
21
+ m = " "
22
+ while (m != "EndOfInput" ):
23
+ m = str (input ())
24
+ if (m in conhead ):
25
+ if (m == conhead [0 ]):
26
+ m = str (input ())
27
+ while (m != conhead [1 ]and m != conhead [2 ] and m != "EndOfInput" ):
28
+ (an ,t )= (bre1 (m ))
29
+ books .append ([an ,t ])
30
+ m = str (input ())
31
+ if (m == conhead [1 ]):
32
+ m = str (input ())
33
+ while (m != conhead [0 ] and m != conhead [2 ]and m != "EndOfInput" ):
34
+ (u ,fn ) = (bre1 (m ))
35
+ borrowers .append ([u , fn ])
36
+ m = str (input ())
37
+ if (m == conhead [2 ]):
38
+ m = str (input ())
39
+ while (m != conhead [0 ] and m != conhead [1 ] and m != "EndOfInput" ):
40
+ (u1 ,an1 ,dd ) = (bre2 (m ))
41
+ checkout .append ([dd ,u1 ,an1 ])
42
+ m = str (input ())
43
+ AN = []
44
+ T = []
45
+ U = []
46
+ FN = []
47
+ DD = []
48
+ checkout .sort ()
49
+ for i1 in range (len (books )):
50
+ T .append (books [i1 ][1 ])
51
+ AN .append (books [i1 ][0 ])
52
+ for i2 in range (len (borrowers )):
53
+ FN .append (borrowers [i2 ][1 ])
54
+ U .append (borrowers [i2 ][0 ])
55
+ for i3 in range (len (checkout )):
56
+ DD .append (checkout [i3 ][0 ])
57
+ DD .sort ()
58
+ for j in range (len (checkout )):
59
+ for k in range (len (FN )):
60
+ if (checkout [j ][1 ]== U [k ]):
61
+ checkout [j ][1 ]= FN [k ]
62
+ for l in range (len (AN )):
63
+ if (checkout [j ][2 ]== AN [l ]):
64
+ checkout [j ].extend ([T [l ]])
65
+ checkout .sort ()
66
+ for z in range (len (checkout )):
67
+ print (checkout [z ][0 ]+ "~" + checkout [z ][1 ]+ "~" + checkout [z ][2 ]+ "~" + checkout [z ][3 ])
You can’t perform that action at this time.
0 commit comments