Skip to content

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 33 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e77b12
Add `split-second-stopwatch` exercise
ErikSchierboom Mar 11, 2025
4a4b8cd
Update instructions.md
ErikSchierboom Mar 28, 2025
e04156c
Update instructions.md
ErikSchierboom Mar 28, 2025
b9ad75b
Update instructions.md
ErikSchierboom Mar 28, 2025
09fb9b1
Update introduction.md
ErikSchierboom Mar 28, 2025
45e8721
Update introduction.md
ErikSchierboom Mar 28, 2025
6ba2dc4
Update introduction.md
ErikSchierboom Mar 28, 2025
75ec01c
Minor changes
ErikSchierboom Mar 30, 2025
c2dde7b
Tweak introduction
ErikSchierboom Mar 30, 2025
9f60c46
Update introduction.md
ErikSchierboom Mar 31, 2025
4c038c8
Update instructions.md
ErikSchierboom Mar 31, 2025
31f0e40
Clarify instructions
ErikSchierboom Apr 5, 2025
c325d0f
Explain time format
ErikSchierboom Apr 5, 2025
3bbfb6a
Add stop state
ErikSchierboom Apr 6, 2025
653ada6
Add more test cases
ErikSchierboom Apr 6, 2025
432b543
Remove nesting
ErikSchierboom Apr 6, 2025
93cd3f4
Add state diagram
ErikSchierboom Apr 6, 2025
c801dbb
Start improving instructions
ErikSchierboom Apr 8, 2025
ded5b17
More simple
ErikSchierboom Apr 9, 2025
0f8be5a
Spice up intro
ErikSchierboom Apr 9, 2025
948fe9c
Update exercises/split-second-stopwatch/metadata.toml
ErikSchierboom Apr 9, 2025
f02d447
Fix canonical data
ErikSchierboom Apr 9, 2025
e6e7d9c
Fix uuids
ErikSchierboom Apr 9, 2025
10a7c15
Fix source url
ErikSchierboom Apr 9, 2025
76afe8d
Fix time
ErikSchierboom Apr 9, 2025
20911be
Update exercises/split-second-stopwatch/canonical-data.json
ErikSchierboom Apr 10, 2025
65f7f72
lowercase commands
ErikSchierboom Apr 10, 2025
d942dbd
Add more explanations to canonical data
ErikSchierboom Apr 10, 2025
8276e71
Remove trailing spaces from comments
ErikSchierboom Apr 11, 2025
4f1d130
Update canonical-data.json
ErikSchierboom Apr 13, 2025
3570883
Update canonical-data.json
ErikSchierboom Apr 13, 2025
4e0afd1
Improve stop previouslaps case
ErikSchierboom Apr 14, 2025
e09f643
Update introduction.md
ErikSchierboom Apr 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 194 additions & 0 deletions exercises/split-second-stopwatch/canonical-data.json
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'."],
Copy link
Member

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.

Copy link
Member Author

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

"cases": [
{
"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": {}
}
]
}
]
}
11 changes: 11 additions & 0 deletions exercises/split-second-stopwatch/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Instructions

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: the time tracked for the current lap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Current lap: the time tracked for the current lap
- Current lap: display the time tracked for the current lap

The other list items use a verb to indicate what we're doing with the tracked time.

- 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
5 changes: 5 additions & 0 deletions exercises/split-second-stopwatch/introduction.md
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 allow for more precise time tracking, you've decided to get a _split-second stopwatch_.
4 changes: 4 additions & 0 deletions exercises/split-second-stopwatch/metadata.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "Split-second Stopwatch"
blurb = "Keep track of time through a digital stopwatch."
source = "Erik Schierboom"
source_url = "https://github.com/exercism/problem-specifications/pull/TODO"
Loading