Oct-20-2018, 03:22 PM
i have an assignment: and basically here it is and i get stuck on this.
write = W,
read = R,
execute= X.
The first line contains the number N — the number of files contained in the filesystem. The following N lines contain the file names and allowed operations with them, separated by spaces. The next line contains an integer M — the number of operations to the files. In the last M lines specify the operations that are requested for files. One file can be requested many times.
You need to recover the control over the access rights to the files. For each request your program should return OK if the requested operation is valid or Access denied if the operation is invalid.
the input is:
4
helloworld.exe R X
pinglog W R
nya R
goodluck X W R
5
read nya
write helloworld.exe
execute nya
read pinglog
write pinglog
the output:
OK
Access denied
Access denied
OK
OK
i am having trouble with making a dictionary. Just making a dictionary, the rest I think i can figure that out.
here is my code so far:
and now i get stuck on how am i going to make it a dictionary. sorry for my last posts with no BB code...
write = W,
read = R,
execute= X.
The first line contains the number N — the number of files contained in the filesystem. The following N lines contain the file names and allowed operations with them, separated by spaces. The next line contains an integer M — the number of operations to the files. In the last M lines specify the operations that are requested for files. One file can be requested many times.
You need to recover the control over the access rights to the files. For each request your program should return OK if the requested operation is valid or Access denied if the operation is invalid.
the input is:
4
helloworld.exe R X
pinglog W R
nya R
goodluck X W R
5
read nya
write helloworld.exe
execute nya
read pinglog
write pinglog
the output:
OK
Access denied
Access denied
OK
OK
i am having trouble with making a dictionary. Just making a dictionary, the rest I think i can figure that out.
here is my code so far:
N = int(input()) lst =[] W = "write" R = "read" X = "execute" for lines in range(N): lines = str(input()).split() print(lst)this is not much. but it prints [['Helloworld', 'W', 'R'], ['pinglog', 'W'], ['data', 'X', 'W', 'R']]
and now i get stuck on how am i going to make it a dictionary. sorry for my last posts with no BB code...