You work for a school, and you need to help the teachers come up with some analytics about their students.
You are given an array of grades. You need to process this array, and return an array that describes whether each grade was higher, lower or even to the previous grade.
So given the following array:
[6,3,5,4,3,4,4,5]
Your code would produce:
[:down,:up,:down,:down,:up,:even,:up]
When given an empty array, it returns an empty array.
NOTE: your array tracks the differences between grades, so it will be one item shorter than the given array.
A student is considered in decline if they have 3 grades lower than previous grades, even if there are some steady grades in there. For example:
[10, 10, 10, 9, 9, 8, 8, 8, 8, 7] # => [:even, :even, :down, :even, :down, :even, :even, :even, :down]
[10, 10, 10, 9, 9, 8, 8, 8, 8, 7] # => in decline
[10, 9, 8, 7] # => [:down, :down, :down]
[10, 9, 8, 7] # => in decline
[10, 9, 8, 7, 8] # => [:down, :down, :down, :up]
[10, 9, 8, 7, 8] # => not in decline
[10, 9, 8] # => [:down, :down]
[10, 9, 8] # => not in decline
There are 27 students in decline in the data/grades.json
files, and 73 students not in decline.
Run you code against this dataset, and make sure that the results match.
- Fork
- Clone
- Turn on TravisCI for the fork by visiting https://travis-ci.org/profile/, clicking the "Sync now" button and scrolling down to find the repository to build.
- Create a new branch for your work using
git checkout -b v1
- Implement specs and code
- Push using
git push -u origin v1
This warmup can be completed multiple times to increase your comfort level with the material. To work on this from scratch, you can:
- Add an upstream remote that points to the original repo
git remote add upstream git@github.com:gSchool/THIS-REPO.git
- Fetch the latest from the upstream remote using
git fetch upstream
- Create a new branch from the master branch of the upstream remote
git checkout -b v2 upstream/master
- Implement specs and code
- Push using
git push -u origin v2
Each time you do the exercise, create a new branch. For example the 3rd time you do the exercise the branch name will be v3 instead of v2.