Menu Close

The writing bot Question. Read and write activity needs to be captured.

A scientist has created a writing bot, which will read from one book and write into another. Both books may have different dimensions.i.e. number of lines on each page and number of pages itself. Read and Write also happen at different speeds.
The bot first reads from the first book fully, then processes the format to write into the second book(done instantaneously) and finally starts writing into the second book.
Your task is to identify, after a specified interval of time, if the bot is reading or writing.
For each of these activities how much read and write activity has happened needs to be captured in terms of pages and number of pages and number of lines on the current page.

Input:
Input has 7 lines
->The first line contains an integer denoting the number of pages in the first book.
->The second line contains an integer denoting the number of lines per page of the first book.
->The third line contains an integer denoting the number of pages in the second book.
->The fourth line contains an integer denoting the number of lines per page of the second book.
->The fifth line contains an integer denoting the reading speed in lines/second.
->The sixth line contains an integer denoting the writing speed in lines/second.
->The seventh line contains integers denoting the time in seconds at which the results are to be processed.

Output:
On one time, print three items.
Current activity performed (READ OR WRITE),
Page number, Line number.
All three items should be delimited by space.

Np1=int(input("Enter the No: of pages in the First Book: "))               #the number of pages in the first book.
Nl1=int(input("Enter the No: of lines per page of the First Book: "))      #the number of lines per page of the first book.
  
Np2=int(input("Enter the No: of pages in the Second Book: "))              #the number of pages in the second book.
Nl2=int(input("Enter the No: of lines per page of the Second Book: "))     #the number of lines per page of the second book.

Rs=int(input("Enter the reading speed in lines per second: "))             #the reading speed in lines/second.
Ws=int(input("Enter the writing speed in lines per second: "))             #the writing speed in lines/second.

Tot=int(input("Enter the time in seconds at which the results are to be processed: ")) #the time in seconds at which the results are to be processed.

totlines1=Np1*Nl1
totlines2=Np2*Nl2

secs=totlines1/Rs

if (Tot-secs)>=0:
	d=Tot-secs
	linesw=d*Ws
	Pnumb=int(linesw/Nl2)
	Remlines=int(linesw%Nl2)
	print("WRITE {} {}".format(Pnumb,Remlines))
else:
	linesr=Tot*Rs
	Pnumb=int(linesr/Nl1)
	Remlines=int(linesr%Nl1)
	print("READ {} {}".format(Pnumb,Remlines))

Input:
Enter the No: of pages in the First Book: 100
Enter the No: of lines per page of the First Book: 10
Enter the No: of pages in the Second Book: 500
Enter the No: of lines per page of the Second Book: 6
Enter the reading speed in lines per second: 8
Enter the writing speed in lines per second: 4
Enter the time in seconds at which the results are to be processed: 145

Output:
           WRITE 13 2 (current activity, page number, line number)

More Codes to Fcuk