Skip to content

Commit 3955dad

Browse files
sync space-age (#560)
We exclude the new test case - invalid planet causes error (57b96e2a-1178-40b7-b34d-f3c9c34e4bf4) [no important files changed]
1 parent bc32b76 commit 3955dad

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
# Instructions
22

3-
Given an age in seconds, calculate how old someone would be on:
3+
Given an age in seconds, calculate how old someone would be on a planet in our Solar System.
44

5-
- Mercury: orbital period 0.2408467 Earth years
6-
- Venus: orbital period 0.61519726 Earth years
7-
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds
8-
- Mars: orbital period 1.8808158 Earth years
9-
- Jupiter: orbital period 11.862615 Earth years
10-
- Saturn: orbital period 29.447498 Earth years
11-
- Uranus: orbital period 84.016846 Earth years
12-
- Neptune: orbital period 164.79132 Earth years
5+
One Earth year equals 365.25 Earth days, or 31,557,600 seconds.
6+
If you were told someone was 1,000,000,000 seconds old, their age would be 31.69 Earth-years.
137

14-
So if you were told someone were 1,000,000,000 seconds old, you should
15-
be able to say that they're 31.69 Earth-years old.
8+
For the other planets, you have to account for their orbital period in Earth Years:
169

17-
If you're wondering why Pluto didn't make the cut, go watch [this YouTube video][pluto-video].
10+
| Planet | Orbital period in Earth Years |
11+
| ------- | ----------------------------- |
12+
| Mercury | 0.2408467 |
13+
| Venus | 0.61519726 |
14+
| Earth | 1.0 |
15+
| Mars | 1.8808158 |
16+
| Jupiter | 11.862615 |
17+
| Saturn | 29.447498 |
18+
| Uranus | 84.016846 |
19+
| Neptune | 164.79132 |
1820

19-
Note: The actual length of one complete orbit of the Earth around the sun is closer to 365.256 days (1 sidereal year).
21+
~~~~exercism/note
22+
The actual length of one complete orbit of the Earth around the sun is closer to 365.256 days (1 sidereal year).
2023
The Gregorian calendar has, on average, 365.2425 days.
2124
While not entirely accurate, 365.25 is the value used in this exercise.
2225
See [Year on Wikipedia][year] for more ways to measure a year.
2326
24-
[pluto-video]: https://www.youtube.com/watch?v=Z_2gbGXzFbs
2527
[year]: https://en.wikipedia.org/wiki/Year#Summary
28+
~~~~
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Introduction
2+
3+
The year is 2525 and you've just embarked on a journey to visit all planets in the Solar System (Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus and Neptune).
4+
The first stop is Mercury, where customs require you to fill out a form (bureaucracy is apparently _not_ Earth-specific).
5+
As you hand over the form to the customs officer, they scrutinize it and frown.
6+
"Do you _really_ expect me to believe you're just 50 years old?
7+
You must be closer to 200 years old!"
8+
9+
Amused, you wait for the customs officer to start laughing, but they appear to be dead serious.
10+
You realize that you've entered your age in _Earth years_, but the officer expected it in _Mercury years_!
11+
As Mercury's orbital period around the sun is significantly shorter than Earth, you're actually a lot older in Mercury years.
12+
After some quick calculations, you're able to provide your age in Mercury Years.
13+
The customs officer smiles, satisfied, and waves you through.
14+
You make a mental note to pre-calculate your planet-specific age _before_ future customs checks, to avoid such mix-ups.
15+
16+
~~~~exercism/note
17+
If you're wondering why Pluto didn't make the cut, go watch [this YouTube video][pluto-video].
18+
19+
[pluto-video]: https://www.youtube.com/watch?v=Z_2gbGXzFbs
20+
~~~~

exercises/practice/space-age/.meta/tests.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[84f609af-5a91-4d68-90a3-9e32d8a5cd34]
613
description = "age on Earth"
@@ -25,3 +32,7 @@ description = "age on Uranus"
2532

2633
[80096d30-a0d4-4449-903e-a381178355d8]
2734
description = "age on Neptune"
35+
36+
[57b96e2a-1178-40b7-b34d-f3c9c34e4bf4]
37+
description = "invalid planet causes error"
38+
include = false

0 commit comments

Comments
 (0)