Home > other >  How to use Python
How to use Python

Time:05-13

Seven security personnel of a company: zhao, money, sun, lee, zhou, wu, Chen, because the job needs to dwell system, a day off each week, and let each person chooses in advance oneself think right day off, please prepare a program that prints were rested all possible solutions, certainly must make everyone satisfied, such as choice of each day of rest is as follows: zhao: on Tuesday, Thursday money: Monday, Saturday: sun li on Sunday: on Friday week: Monday, Wednesday, Thursday, Saturday, wu: Tuesday, Friday Chen: Wednesday, Saturday, Sunday,

CodePudding user response:

 import itertools as it 
The import copy

TB=[' on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday,]
D={' zhao: [' Tuesday ', 'Thursday],
'money: [' Monday', 'Saturday],
On Wednesday, 'sun' : [' ' 'Sunday],
'lee' : [' Friday],
'week' : [' Monday ', 'on Thursday,' Saturday],
"Wu" : [' Tuesday ', 'Friday],
On Wednesday, 'Chen' : [' ' 'on Saturday', 'Sunday],
}

The index=0
Key='
For k, v in d.i tems () :
If the index & gt; 0:
Cur=it. The product (cur, v)
CPU=copy. The copy (cur)
If the index & gt; 1:
CPU=[the list (I [0]) + [I [1]] for I in cup]
Cur=cup
The key +=k
The else:
Cur=v
Key=k

Index +=1

For I in cur:
If len (set (I))==7:
Res=[key [i.i ndex (_)] for _ in TB]
Print (res)

CodePudding user response:

refer to the second floor chuifengde response:
 import itertools as it 
The import copy

TB=[' on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday,]
D={' zhao: [' Tuesday ', 'Thursday],
'money: [' Monday', 'Saturday],
On Wednesday, 'sun' : [' ' 'Sunday],
'lee' : [' Friday],
'week' : [' Monday ', 'on Thursday,' Saturday],
"Wu" : [' Tuesday ', 'Friday],
On Wednesday, 'Chen' : [' ' 'on Saturday', 'Sunday],
}

The index=0
Key='
For k, v in d.i tems () :
If the index & gt; 0:
Cur=it. The product (cur, v)
CPU=copy. The copy (cur)
If the index & gt; 1:
CPU=[the list (I [0]) + [I [1]] for I in cup]
Cur=cup
The key +=k
The else:
Cur=v
Key=k

Index +=1

For I in cur:
If len (set (I))==7:
Res=[key [i.i ndex (_)] for _ in TB]
Print (res)


Good as you!

CodePudding user response:

refer to the second floor chuifengde response:
 import itertools as it 
The import copy

TB=[' on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday,]
D={' zhao: [' Tuesday ', 'Thursday],
'money: [' Monday', 'Saturday],
On Wednesday, 'sun' : [' ' 'Sunday],
'lee' : [' Friday],
'week' : [' Monday ', 'on Thursday,' Saturday],
"Wu" : [' Tuesday ', 'Friday],
On Wednesday, 'Chen' : [' ' 'on Saturday', 'Sunday],
}

The index=0
Key='
For k, v in d.i tems () :
If the index & gt; 0:
Cur=it. The product (cur, v)
CPU=copy. The copy (cur)
If the index & gt; 1:
CPU=[the list (I [0]) + [I [1]] for I in cup]
Cur=cup
The key +=k
The else:
Cur=v
Key=k

Index +=1

For I in cur:
If len (set (I))==7:
Res=[key [i.i ndex (_)] for _ in TB]
Print (res)

Thank you, thank you very much
  • Related