Back to General discussions forum
Like others who have posted about this task, my results match the expected results most of the time, with a few random ones that do not. In looking at why, it turns out that in EVERY case when we don't match it is because the expected result sent partial pages to the printers. This doesn't make sense to me - i.e. you don't send 2.24689 pages to a printer, you send 3. And in every case, the difference between the expected answer and mine is the difference in time for a full page, and the partial. Here are a couple of actual test cases that illustrate the problem:
334 488 1940685 (Expected answer: 384812888 - 1,152,134.395209580... pages; Mine: 384813090 - 1,152,135 pages) 12949 8873 63714 (Expected answer: 335469743 - 37,807.92775836... pages; Mine: 335470384 - 37,808 pages)
Am I missing something? Thanks!
I don't think the correct solution ever involves partial pages.
In the first example (334 488 1940685), 384812888 is certainly correct: the first printer prints 384812888 // 334 = 1152134 pages, while the second printer prints 384812888 // 488 = 788551 pages. Together, they print 1152134 + 788551 = 1940685 pages, which is the exact number requested and is faster than your answer of 384813090.
The problem is, 384812888 / 334 does NOT = 1152134 pages, it equals 1152134.39520958... pages.
If you sent 1152134 pages to the first printer then the time to print that should be 1152134 * 334 = 384812756. Which is also not the expected answer. The difference, 132, is the partial page (the extra .39520958... * 334) assigned to the first printer in the expected answer. I still think the first printer should have been assigned 1152135 pages and not 1152134.39520958...
You misunderstand the problem. Forget about partial pages. In your example, if you use printer 1 for 334 seconds, you get 1 page, the same for 335 seconds, 336 seconds, up to 667 seconds, and then when you get to 668 seconds you get a second page, and so on.
OP, please notice I never wrote 384812888 / 334
, but 384812888 // 334
; there is a difference. Here's how I think of this: you send X pages to printer A and Y pages to printer B. X + Y is the required amount. As soon as ALL PAGES are printed, you are done.
Perhaps you think that both printers must finish at the same time? This is absolutely not a requirement.