At ApplyBoard, we believe that education is a right, not a privilege. We empower people around the world to access the best education available. Our platform streamlines the application process from submission to enrolment assisting thousands of students to pursue their dreams of studying abroad.
At ApplyBoard we utilize event sourcing to store changes in our system so that we can replay, undo or redo some event that happened in the past. The given question is to build a system that supports these functionalities.
To simplify the problem, we need to build it for the given requirements:
Given an initial integer value of 0, we need a system to track, add and subtract the value. Additionally, we need to build upon our event tracking to support undo, redo, bulk_undo and bulk_redo functionalities.
We have created a base EventSourcer class that holds an initial value of 0, alongside function signatures as a base, it will be your job to implement the functions. Feel free to add other functions, however do not change the function signatures or the constructor as it will fail the tests.
If you are looking for more details on how the undo/redo functionality should work, check out this video at the timestamp linked: https://youtu.be/X6NJkWbM1xk?t=173 . The implementation we are looking for is the first simple solution mentioned!
You will have until July 10th 3:00pm to submit your Pull Requests
To complete the challenge, implement the following functions:
add(num: integer)
- add num to the value
subtract(num: integer)
- subtract num from the value
undo()
- revert last event
redo()
- redo next event
bulk_undo(amount: integer)
- undo the given amount of events
bulk_redo(amount: integer)
- redo the given amount of events
initial_value = 0
add(20)
value: 20
add(30)
value: 50
subtract(10)
value: 40
undo()
value: 50
redo()
value: 40
redo()
value: 40 (Nothing to redo)
bulk_undo(2) (The last two actions were subtract(10) and add(30))
value: 20
bulk_redo(2)
value: 40
- Open the
javascript_solution.js
file. - Implement the
add
subtract
undo
redo
bulk_undo
andbulk_redo
functions
- Use the following command to install
jest
testing framework
npm install
- Use the following command to run the tests
npm test
- Open the
solution_ruby.rb
file. - Implement the
add
subtract
undo
redo
bulk_undo
andbulk_redo
functions
- To test your solution locally use the following command:
ruby tests/ruby_solution_test.rb
- Make sure you are using Python 3! (The tests run using python3)
- Open the
python_solution.py
file. - Implement the
add
subtract
undo
redo
bulk_undo
andbulk_redo
functions
- To test your solution first Install pip
- Install
pytest
using the following command:
pip install -r requirements.txt
- Use pytest to run the tests with the following command:
pytest
- Fork the repository
- Make your changes on the master branch in your fork.
- Create a Pull Request. Make sure the base is set to
Applyboard/fallcoop-fall-2020-challenge
Label | Description |
---|---|
Coop Fall 2020 | Tag your PR with this label to be considered for a Fall 2020 coop! |
Coop Winter 2021 | Tag your PR with this label to be considered for a Winter 2021 coop! |
Full Time | Tag your PR with this label if you are applying for fulltime! |
Student | If you are a student you will be eligible for the prizes! Tag your PR with this label to be considered for prizes! |
We will verify your student email address if you are selected for a prize
While anyone is encouraged to attempt the challenge, Only students are eligible for prizes. If you are are a student, add the "Student" tag to your PR to be considered for a prize!
The winner of the challenge will be selected based on:
- Correctness
- Readability
- Efficiency
- Edge-case handling
- You may not use any existing libraries, or copy existing code.
- You should fork this project, and submit your entry by submitting a pull request to
master
. - Your latest commit must be on GitHub no later than the time specified by the engineer running the challenge.
If you run into any issues during the challenge:
- Join the zoom link that was provided to all candidates who signed up
- Submit an issue on Github! (https://github.com/ApplyBoard/coop-fall-2020-challenge/issues) One of our staff will try to help you debug whatever issue you're running into.