Loading...
gina78 avatar gina78 4 Точки

Radio Crystals

Здравейта, може ли малко помощ за тая задача 

28/100

моя код https://pastebin.com/bPTnfU6p

 

Radio Crystals

It’s time to put your skills to work for the war effort – creating management software for a radio transmitter factory. Radios require a finely tuned quartz crystal in order to operate at the correct frequency. The resource used to produce them is quartz ore that comes in big chunks and needs to undergo several processes, before it reaches the desired properties.

You need to write a program that monitors the current thickness of the crystal and recommends the next procedure that will bring it closer to the desired frequency. To reduce waste and the time it takes to make each crystal your program needs to complete the process with the least number of operations. Each operation takes the same amount of time, but since they are done at different parts of the factory, the crystals have to be transported and thoroughly washed every time an operation different from the previous must be performed, so this must also be taken into account. When determining the order, always attempt to start from the operation that removes the largest amount of material.

The different operations you can perform are the following:

Cut – cuts the crystal in 4

Lap – removes 20% of the crystal’s thickness

Grind – removes 20 microns of thickness

Etch – removes 2 microns of thickness

X-ray – increases the thickness of the crystal by 1 micron; this operation can only be done once!

Transporting and washing – removes any imperfections smaller than 1 micron (round down the number); do this after every batch of operations that remove material

At the beginning of your program, you will receive a number representing the desired final thickness and a series of numbers, representing the thickness of crystal ore in microns. Process each chunk and print to the console the order of operations and number of times they need to be repeated to bring them to the desired thickness.

The input comes as a string  with a variable number of elements separated by “, “ that must be parsed to numbers. The first number is the target thickness and all following numbers are the thickness of different chunks of quartz ore.

The output is the order of operation and how many times they are repeated, every operation on a new line. See the examples for more information.

Examples

Input

Output

1375, 50000

Processing chunk 50000 microns

Cut x2

Transporting and washing

Lap x3

Transporting and washing

Grind x11

Transporting and washing

Etch x3

Transporting and washing

X-ray x1

Finished crystal 1375 microns

Explanation

The operation that would remove the most material is always cutting – it removes three quarters of the chunk. Starting from 50000, if we perform it twice, we bring the chunk down to 3125. If we cut again, the chunk will be 781.25, which is less than the desired thickness, so we move to the next operation, but we first round down the number (transporting & washing). Next, we lap the chunk – after three operations, the crystal reaches 1600 microns. One more lapping would take it to 1280, so we move on to the next operation instead. We do the same check with grinding, and finally by etching 2 times, the crystal has reached 1376 microns, which is one more than desired. We don’t have an operation which only takes away 1 micron, so instead we etch once more to get to 1374, wash and then x-ray to add 1 micron, which brings us to the desired thickness.

Input

Output

1000, 4000, 8100

Processing chunk 4000 microns

Cut x1

Transporting and washing

Finished crystal 1000 microns

Processing chunk 8100 microns

Cut x1

Transporting and washing

Lap x3

Transporting and washing

Grind x1

Transporting and washing

Etch x8

Transporting and washing

Finished crystal 1000 microns

Тагове:
0
PHP Web
Kizzata avatar Kizzata 12 Точки

Без да съм тествал и влизал много в детайли според мен не трябва да хардкодваш "X-ray x1", защото може да приема и други параметри освен х1, но все пак трябва да се изпълни само веднъж.

0
gina78 avatar gina78 4 Точки

Благодаря

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.