Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/exercises/space-age/.meta/example.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / exercises / space-age / .meta / example.om` 61 lines ยท 1323 bytes Raw Blame History 1 note Exercism-style exercise "space-age": https://exercism.org/tracks/python/exercises/space-age 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note age is how old someone of the given seconds is in years of planet: one Earth year is `31557600` 4 note seconds; orbital periods in Earth years are Mercury 0.`2408467`, Venus 0.`61519726`, Earth 1.0, 5 note Mars 1.`8808158`, Jupiter 11.862615, Saturn 29.447498, Uranus 84.016846, Neptune 164.79132. 6 note age is -1.0 when planet is not one of these names. 7 note Check it with: sh exercise.sh exercises/space-age 8 om2 9 text pl0 "Mercury" 10 text pl1 "Venus" 11 text pl2 "Earth" 12 text pl3 "Mars" 13 text pl4 "Jupiter" 14 text pl5 "Saturn" 15 text pl6 "Uranus" 16 text pl7 "Neptune" 17 fn same a view uchar * b view uchar * to bool 18 if ne len a len b 19 ret false 20 end 21 for i ulong len a 22 if ne get a i get b i 23 ret false 24 end 25 end 26 ret true 27 end 28 fn period planet view uchar * to f64 29 if same planet pl0 30 ret 0.`2408467` 31 end 32 if same planet pl1 33 ret 0.`61519726` 34 end 35 if same planet pl2 36 ret 1.0 37 end 38 if same planet pl3 39 ret 1.`8808158` 40 end 41 if same planet pl4 42 ret 11.862615 43 end 44 if same planet pl5 45 ret 29.447498 46 end 47 if same planet pl6 48 ret 84.016846 49 end 50 if same planet pl7 51 ret 164.79132 52 end 53 ret -1.0 54 end 55 fn age planet view uchar * seconds f64 to f64 56 p = period planet 57 if lt p 0.0 58 ret -1.0 59 end 60 ret div div seconds `31557600`.0 p 61 end