Last active
January 4, 2022 01:35
-
-
Save rkr35/16297e7530f959bf7218e89e269bc561 to your computer and use it in GitHub Desktop.
Recovery runs weekly progression
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
| use std::fmt::{self, Display, Formatter}; | |
| #[derive(Copy, Clone)] | |
| struct Seconds(f64); | |
| impl Seconds { | |
| pub fn compound(self) -> Self { | |
| Self(self.0 * 1.1) | |
| } | |
| pub fn halfway_point(self) -> Self { | |
| Self(self.0 / 2.0) | |
| } | |
| } | |
| impl Display for Seconds { | |
| fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { | |
| const SECONDS_PER_MIN: f64 = 60.0; | |
| let mut minutes = self.0.div_euclid(SECONDS_PER_MIN); | |
| let mut seconds = self.0.rem_euclid(SECONDS_PER_MIN).round(); | |
| if seconds == 60.0 { | |
| seconds = 0.0; | |
| minutes += 1.0; | |
| } | |
| write!(f, "{}:{:02}", minutes, seconds) | |
| } | |
| } | |
| fn main() { | |
| let mut total_run_time = Seconds(15.0 * 60.0); | |
| for i in 0..10 { | |
| println!("[{}] {} ({})", i, total_run_time, total_run_time.halfway_point()); | |
| total_run_time = total_run_time.compound(); | |
| } | |
| } |
Author
Author
[0] 24:12 (12:06)
[1] 26:37 (13:19)
[2] 29:17 (14:38)
[3] 32:13 (16:06)
[4] 35:26 (17:43)
[5] 38:58 (19:29)
[6] 42:52 (21:26)
[7] 47:10 (23:35)
[8] 51:52 (25:56)
[9] 57:04 (28:32
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[0] 15:00 (7:30)
[1] 16:30 (8:15)
[2] 18:09 (9:05)
[3] 19:58 (9:59)
[4] 21:58 (10:59)
[5] 24:09 (12:05)
[6] 26:34 (13:17)
[7] 29:14 (14:37)
[8] 32:09 (16:05)
[9] 35:22 (17:41)