-
-
Notifications
You must be signed in to change notification settings - Fork 553
Add split-second-stopwatch
exercise
#2547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
6e77b12
Add `split-second-stopwatch` exercise
ErikSchierboom 4a4b8cd
Update instructions.md
ErikSchierboom e04156c
Update instructions.md
ErikSchierboom b9ad75b
Update instructions.md
ErikSchierboom 09fb9b1
Update introduction.md
ErikSchierboom 45e8721
Update introduction.md
ErikSchierboom 6ba2dc4
Update introduction.md
ErikSchierboom 75ec01c
Minor changes
ErikSchierboom c2dde7b
Tweak introduction
ErikSchierboom 9f60c46
Update introduction.md
ErikSchierboom 4c038c8
Update instructions.md
ErikSchierboom 31f0e40
Clarify instructions
ErikSchierboom c325d0f
Explain time format
ErikSchierboom 3bbfb6a
Add stop state
ErikSchierboom 653ada6
Add more test cases
ErikSchierboom 432b543
Remove nesting
ErikSchierboom 93cd3f4
Add state diagram
ErikSchierboom c801dbb
Start improving instructions
ErikSchierboom ded5b17
More simple
ErikSchierboom 0f8be5a
Spice up intro
ErikSchierboom 948fe9c
Update exercises/split-second-stopwatch/metadata.toml
ErikSchierboom f02d447
Fix canonical data
ErikSchierboom e6e7d9c
Fix uuids
ErikSchierboom 10a7c15
Fix source url
ErikSchierboom 76afe8d
Fix time
ErikSchierboom 20911be
Update exercises/split-second-stopwatch/canonical-data.json
ErikSchierboom 65f7f72
lowercase commands
ErikSchierboom d942dbd
Add more explanations to canonical data
ErikSchierboom 8276e71
Remove trailing spaces from comments
ErikSchierboom 4f1d130
Update canonical-data.json
ErikSchierboom 3570883
Update canonical-data.json
ErikSchierboom 4e0afd1
Improve stop previouslaps case
ErikSchierboom e09f643
Update introduction.md
ErikSchierboom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
{ | ||
"exercise": "split-second-stopwatch", | ||
"comments": ["Times are formatted as 'HH:mm:ss'."], | ||
"cases": [ | ||
IsaacG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"description": "new stopwatch", | ||
"cases": [ | ||
{ | ||
"uuid": "ddb238ea-99d4-4eaa-a81d-3c917a525a23", | ||
"description": "starts in ready state", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "state", | ||
"expected": "ready" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "8a892c1e-9ef7-4690-894e-e155a1fe4484", | ||
"description": "new stopwatch does not have previous laps", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "previousLaps", | ||
"expected": [] | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "b19635d4-08ad-4ac3-b87f-aca10e844071", | ||
"description": "current lap has no elapsed time", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "currentLap", | ||
"expected": "00:00:00" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "492eb532-268d-43ea-8a19-2a032067d335", | ||
"description": "total has no time elapsed", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "total", | ||
"expected": "00:00:00" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "start", | ||
"cases": [ | ||
{ | ||
"uuid": "5b2705b6-a584-4042-ba3a-4ab8d0ab0281", | ||
"description": "changes state to running", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "state", | ||
"expected": "running" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "748235ce-1109-440b-9898-0a431ea179b6", | ||
"description": "does not change previous laps", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "previousLaps", | ||
"expected": [] | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "491487b1-593d-423e-a075-aa78d449ff1f", | ||
"description": "starts time tracking in current lap", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "advanceTime", | ||
"seconds": 5 | ||
}, | ||
{ | ||
"command": "currentLap", | ||
"expected": "00:00:05" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "a0a7ba2c-8db6-412c-b1b6-cb890e9b72ed", | ||
"description": "starts time tracking in total", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "advanceTime", | ||
"seconds": 23 | ||
}, | ||
{ | ||
"command": "total", | ||
"expected": "00:00:23" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "7f558a17-ef6d-4a5b-803a-f313af7c41d3", | ||
"description": "cannot be called from running state", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "start", | ||
"expected": { | ||
"error": "cannot start an already running stopwatch" | ||
} | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Instructions | ||
ErikSchierboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Your task is to build a stopwatch that can be used to keep track of lap times. | ||
The stopwatch has the following functionality: | ||
|
||
- Start: start/resume time tracking | ||
- Stop: stop (pause) time tracking | ||
- Current lap: retrieve the time tracked for the current lap | ||
- Previous laps: retrieve the previously recorded lap times | ||
- Reset: stop time tracking, reset the current lap, and clear all previously recorded laps | ||
- Lap: add the current lap time to the previous laps, then reset the current lap time and continue tracking time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Introduction | ||
|
||
As an amateur runner, you've never really felt the need to track your time precisely. | ||
However, having just enrolled in a local running team, you're now following precisely timed training sessions, each one tuned to the second. | ||
To keep up, you've bought the _split-second stopwatch_, a state-of-the-art tool for time tracking. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title = "Split-second Stopwatch" | ||
ErikSchierboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
blurb = "Keep track of time through a digital stopwatch." | ||
source = "Erik Schierboom" | ||
source_url = "https://github.com/exercism/problem-specifications/pull/TODO" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not be clear in terms of "What do these letters mean". I mean to say that it may be intuitive that it is hour, minutes, seconds, but why the change in case for hours?
It can be useful to show a time where the
HH
is put in place, such as 13:14:15, to show the difference from a 12 hour clock to a twenty four hour clock. To others, it will be clear, but via experience rather than inherent knowledge.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point! I'll update