Like most developers, Will has to deal with the problems of having a sedentary career. Sitting on his butt on all, he finds that it’s easier than he’d like to grow a big belly and to have pain from the way he sits. As part of a larger regimen of diet and exercise, he wants to start lifting heavy weights again.
However, like all grouchy people of a certain age, Will needs to warm up before exercising. Failing to do so really hurts and he just doesn’t recover like he used to. He needs to start with lighter weights and work upward to his goal weight before actually trying to lift something heavy. Each step up in weight should be a reasonable amount, until he reaches his goal weight.
Will also (being cranky) doesn’t particularly want to try and do math in between weight sets. He’d rather just listen to music. Towards that end, he wants an application that can figure out what his warmup sets should be.
For this challenge, create an application that takes in the name of the exercise, a minimum weight, and a target ending weight. The warmup weight amounts are determined by the following rules:
- The minimum weight is the minimum amount that you can start with. For instance, for the deadlift, Will might start at 135 lbs, because the bar weighs 45 pounds and the big plates on each side weigh 45 pounds.
- Increment the weight by up to 30 lbs at a time, starting with the minimum weight and ending with the final weight.
- If there is less than 30 lbs between a weight and the final weight, increase by 15lbs instead before doing the final weight.
- If the difference is less than 15 lbs, proceed directly to the final weight.
- Display the results.
We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.
Upon thinking about it, Will needs a couple other things for this to work well.
- First of all, he needs the program to output the weight sets in a way that allows them to quickly be imported into the task tracking application he uses so that he can quickly see the weights he needs to use on his phone.
- He also needs to know the number of reps to use, so that will need to be added.
- He also likes to plan a week’s worth of workouts at a time, so the date will need to be taken into account.
Thankfully these can be emailed in to the task tracker (Nozbe). A sample resulting email looks like the following (just output on the console for now):
If you want to take the challenge even further, consider what would be required to do any/all of the following:
- Allow multiple exercises in one run of the application.
- Store configuration data about the exercises for things like the minimum weight, and goal weights.
- Allow updating of stored configuration
- Allow the exercises to be divided into “Leg day”, “Arm day”, and “Cardio” categories, and allow the user to pick what kind of day they are planning, then walk them through all the available exercises, and then build up the email.