Challenge - Medicine dosage 01-10-2016, 12:06 AM
#1
So I participated in a programming challenge by a company specializing in medical software recently.
You have 30 minutes to solve a challenge, and you're not allowed to see the challenge text before the timer starts running. Obviously you don't have the actual time limit I had when solving this challenge, but be honest and do your best in 30 minutes. You can use any language you want. (I used C, because why not? It's a challenge, goddammit!)
Start the timer NOW. The challenge includes the time taken to read and understand the challenge text!
The challenge is as follows:
(I finished the challenge with about 250 seconds to spare. I've also had an entire bottle of Hungarian Olaszrizling white wine. This challenge was thrown at me by a colleague who wants to start a business with me. I was also given a 5 second penalty every time the program was run.).
You have 30 minutes to solve a challenge, and you're not allowed to see the challenge text before the timer starts running. Obviously you don't have the actual time limit I had when solving this challenge, but be honest and do your best in 30 minutes. You can use any language you want. (I used C, because why not? It's a challenge, goddammit!)
Start the timer NOW. The challenge includes the time taken to read and understand the challenge text!
The challenge is as follows:
Spoiler:
In 30 minutes, create a program that takes an arbitrary string as input after the program has started.
Let X and Y be whole decimal numerics, and apply the following rules:
When the input is "X", print "X units per day."
When the input is "X*Y", print "X units Y times a day."
When the input is "X+Y", print "X units morning, Y units night."
Example:
Given the input "5", the corresponding output should be "5 units per day."
(Command line arguments are ignored. E.g. running the program as "./program 5" would be insufficient.)
Let X and Y be whole decimal numerics, and apply the following rules:
When the input is "X", print "X units per day."
When the input is "X*Y", print "X units Y times a day."
When the input is "X+Y", print "X units morning, Y units night."
Example:
Given the input "5", the corresponding output should be "5 units per day."
(Command line arguments are ignored. E.g. running the program as "./program 5" would be insufficient.)
(I finished the challenge with about 250 seconds to spare. I've also had an entire bottle of Hungarian Olaszrizling white wine. This challenge was thrown at me by a colleague who wants to start a business with me. I was also given a 5 second penalty every time the program was run.).



![[Image: LocMEDM.png]](http://i.imgur.com/LocMEDM.png)
![[+]](https://sinister.li/images/modern/collapse_collapsed.png)



















![[Image: CDUAq9d.png]](http://i.imgur.com/CDUAq9d.png)








![[Image: 7ajmN5P.jpg]](https://i.imgur.com/7ajmN5P.jpg)