Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Habit Tracker


Habit Tracker

  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}


Home Report An Issue Card CountingMad Libs

Habit Tracker

You are going to build some logic for a habit tracking app. Habit tracking apps such as Habitica help users develop healthy habits.

Each habit is assigned a size such as small, medium, or large. Each size is assigned a different point value. Users earn points based on the habits they complete.

  • A large habit is worth 30 points
  • A medium habit is worth 20 points
  • A small habit is worth 5 points.
  A["Large (30 points)"]
  B["Medium (20 points)"]
  C["Small (5 points)"]

Bind Habit Variables

Bind a variable small, medium, and large to represent the point value as an integer (see above) for each habit. You will use these variables in further solutions.

Example solution

large = 30
medium = 20
small = 5

Enter your solution below.

Small, Medium, Large

Given a user has completed one small habit, one medium habit, and one large habit, use arithmetic operators and your previously bound variables small, medium, and large to determine how many points they have in total.

flowchart LR
  A["Large (30 points)"]
  B["Medium (20 points)"]
  C["Small (5 points)"]
  A --+--> B
  B --+--> C
  C --+--> T

Example solution

small + medium + large

Enter your answer in the code cell below.


Given a user has completed ten small habits, five medium habits, and three large habits, use arithmetic operators to determine how many points they have in total.

Example solution

small * 10 + medium * 5 + large * 3

Enter your answer below.

Progress Bar

Users define a a goal number of points to earn each day. Determine what percentage progress have they made if they would like to earn 40 points and have completed a small and a medium habit.

Remember that you can calculate percentage with $\frac{points}{goal} * 100$

Example solution

goal = 40
((small + medium) / goal) * 100

Or you might consider binding points as a variable.

goal = 40
points = small + medium 
(points / goal) * 100

Enter your answer below.

Penalties And Rewards

To motivate users to complete their habits quickly, we add a time-limit feature where users will receive a 60% point bonus if they complete their habit early, and a 50% point penalty if they complete their habit late.

Determine the users total point score when they complete:

  • three early small habits
  • two normal medium habits
  • two late large habits

Example solution

goal = 40

small * 1.6 * 3 + medium * 2 + large * 2 * 0.5

Enter your answer below.

Bonus: Add Your Own Feature

Add your own feature to the habit tracking app. Use comments to describe your feature and show how it would affect calculating the total score and/or the total percentage of completed habits.

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish Habit Tracker exercise"
$ git push

We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.


Home Report An Issue Card CountingMad Libs