diff --git a/exercises/practice/raindrops/test.fut b/exercises/practice/raindrops/test.fut index a126d26..01b9ef4 100644 --- a/exercises/practice/raindrops/test.fut +++ b/exercises/practice/raindrops/test.fut @@ -1,26 +1,26 @@ import "raindrops" --- The sound for 1 is 1 +-- the sound for 1 is 1 -- == -- input { 1 } -- output { "1" } --- The sound for 3 is Pling +-- the sound for 3 is Pling -- == -- input { 3 } -- output { "Pling" } --- The sound for 5 is Plang +-- the sound for 5 is Plang -- == -- input { 5 } -- output { "Plang" } --- The sound for 7 is Plong +-- the sound for 7 is Plong -- == -- input { 7 } -- output { "Plong" } --- The sound for 6 is Pling as it has a factor 3 +-- the sound for 6 is Pling as it has a factor 3 -- == -- input { 6 } -- output { "Pling" } @@ -30,65 +30,65 @@ import "raindrops" -- input { 8 } -- output { "8" } --- The sound for 9 is Pling as it has a factor 3 +-- the sound for 9 is Pling as it has a factor 3 -- == -- input { 9 } -- output { "Pling" } --- The sound for 10 is Plang as it has a factor 5 +-- the sound for 10 is Plang as it has a factor 5 -- == -- input { 10 } -- output { "Plang" } --- The sound for 14 is Plong as it has a factor of 7 +-- the sound for 14 is Plong as it has a factor of 7 -- == -- input { 14 } -- output { "Plong" } --- The sound for 15 is PlingPlang as it has factors 3 and 5 +-- the sound for 15 is PlingPlang as it has factors 3 and 5 -- == -- input { 15 } -- output { "PlingPlang" } --- The sound for 21 is PlingPlong as it has factors 3 and 7 +-- the sound for 21 is PlingPlong as it has factors 3 and 7 -- == -- input { 21 } -- output { "PlingPlong" } --- The sound for 25 is Plang as it has a factor 5 +-- the sound for 25 is Plang as it has a factor 5 -- == -- input { 25 } -- output { "Plang" } --- The sound for 27 is Pling as it has a factor 3 +-- the sound for 27 is Pling as it has a factor 3 -- == -- input { 27 } -- output { "Pling" } --- The sound for 35 is PlangPlong as it has factors 5 and 7 +-- the sound for 35 is PlangPlong as it has factors 5 and 7 -- == -- input { 35 } -- output { "PlangPlong" } --- The sound for 49 is Plong as it has a factor 7 +-- the sound for 49 is Plong as it has a factor 7 -- == -- input { 49 } -- output { "Plong" } --- The sound for 52 is 52 +-- the sound for 52 is 52 -- == -- input { 52 } -- output { "52" } --- The sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7 +-- the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7 -- == -- input { 105 } -- output { "PlingPlangPlong" } --- The sound for 3125 is Plang as it has a factor 5 +-- the sound for 3125 is Plang as it has a factor 5 -- == -- input { 3125 } -- output { "Plang" } -let main (number: i32): []u8 = +let main (number: i32): []u8 = convert number diff --git a/exercises/practice/reverse-string/.meta/tests.toml b/exercises/practice/reverse-string/.meta/tests.toml index 0c313cc..52fda99 100644 --- a/exercises/practice/reverse-string/.meta/tests.toml +++ b/exercises/practice/reverse-string/.meta/tests.toml @@ -29,9 +29,12 @@ description = "an even-sized word" [1bed0f8a-13b0-4bd3-9d59-3d0593326fa2] description = "wide characters" +include = false [93d7e1b8-f60f-4f3c-9559-4056e10d2ead] description = "grapheme cluster with pre-combined form" +include = false [1028b2c1-6763-4459-8540-2da47ca512d9] description = "grapheme clusters" +include = false diff --git a/exercises/practice/reverse-string/test.fut b/exercises/practice/reverse-string/test.fut index 545113b..70a46cf 100644 --- a/exercises/practice/reverse-string/test.fut +++ b/exercises/practice/reverse-string/test.fut @@ -1,31 +1,31 @@ import "reverse_string" --- An empty string +-- an empty string -- == -- input { "" } -- output { "" } --- A word +-- a word -- == -- input { "robot" } -- output { "tobor" } --- A capitalized word +-- a capitalized word -- == -- input { "Ramen" } -- output { "nemaR" } --- A sentence with punctuation +-- a sentence with punctuation -- == -- input { "I'm hungry!" } -- output { "!yrgnuh m'I" } --- A palindrome +-- a palindrome -- == -- input { "racecar" } -- output { "racecar" } --- An even-sized word +-- an even-sized word -- == -- input { "drawer" } -- output { "reward" } diff --git a/exercises/practice/roman-numerals/test.fut b/exercises/practice/roman-numerals/test.fut index a413553..9d7f375 100644 --- a/exercises/practice/roman-numerals/test.fut +++ b/exercises/practice/roman-numerals/test.fut @@ -125,6 +125,11 @@ import "roman_numerals" -- input { 3001 } -- output { "MMMI" } +-- 3888 is MMMDCCCLXXXVIII +-- == +-- input { 3888 } +-- output { "MMMDCCCLXXXVIII" } + -- 3999 is MMMCMXCIX -- == -- input { 3999 } diff --git a/exercises/practice/scrabble-score/test.fut b/exercises/practice/scrabble-score/test.fut index bf58ae4..3f7ce42 100644 --- a/exercises/practice/scrabble-score/test.fut +++ b/exercises/practice/scrabble-score/test.fut @@ -1,56 +1,56 @@ import "scrabble_score" --- Lowercase letter +-- lowercase letter -- == -- input { "a" } -- output { 1 } --- Uppercase letter +-- uppercase letter -- == -- input { "A" } -- output { 1 } --- Valuable letter +-- valuable letter -- == -- input { "f" } -- output { 4 } --- Short word +-- short word -- == -- input { "at" } -- output { 2 } --- Short, valuable word +-- short, valuable word -- == -- input { "zoo" } -- output { 12 } --- Medium word +-- medium word -- == -- input { "street" } -- output { 6 } --- Medium, valuable word +-- medium, valuable word -- == -- input { "quirky" } -- output { 22 } --- Long, mixed-case word +-- long, mixed-case word -- == -- input { "OxyphenButazone" } -- output { 41 } --- English-like word +-- english-like word -- == -- input { "pinata" } -- output { 8 } --- Empty input +-- empty input -- == -- input { "" } -- output { 0 } --- Entire alphabet available +-- entire alphabet available -- == -- input { "abcdefghijklmnopqrstuvwxyz" } -- output { 87 } diff --git a/exercises/practice/secret-handshake/test.fut b/exercises/practice/secret-handshake/test.fut index f702be9..b5d3c43 100644 --- a/exercises/practice/secret-handshake/test.fut +++ b/exercises/practice/secret-handshake/test.fut @@ -1,56 +1,56 @@ import "secret_handshake" --- Wink for 1 +-- wink for 1 -- == -- input { 1 } -- output { "wink" } --- Double blink for 10 +-- double blink for 10 -- == -- input { 2 } -- output { "double blink" } --- Close your eyes for 100 +-- close your eyes for 100 -- == -- input { 4 } -- output { "close your eyes" } --- Jump for 1000 +-- jump for 1000 -- == -- input { 8 } -- output { "jump" } --- Combine two actions +-- combine two actions -- == -- input { 3 } -- output { "wink, double blink" } --- Reverse two actions +-- reverse two actions -- == -- input { 19 } -- output { "double blink, wink" } --- Reversing one action gives the same action +-- reversing one action gives the same action -- == -- input { 24 } -- output { "jump" } --- Reversing no actions still gives no actions +-- reversing no actions still gives no actions -- == -- input { 16 } -- output { "" } --- All possible actions +-- all possible actions -- == -- input { 15 } -- output { "wink, double blink, close your eyes, jump" } --- Reverse all possible actions +-- reverse all possible actions -- == -- input { 31 } -- output { "jump, close your eyes, double blink, wink" } --- Do nothing for zero +-- do nothing for zero -- == -- input { 0 } -- output { "" } diff --git a/exercises/practice/space-age/.meta/tests.toml b/exercises/practice/space-age/.meta/tests.toml index 7957bb7..a62017e 100644 --- a/exercises/practice/space-age/.meta/tests.toml +++ b/exercises/practice/space-age/.meta/tests.toml @@ -35,3 +35,4 @@ description = "age on Neptune" [57b96e2a-1178-40b7-b34d-f3c9c34e4bf4] description = "invalid planet causes error" +include = false diff --git a/exercises/practice/space-age/test.fut b/exercises/practice/space-age/test.fut index ce4f73d..1151b29 100644 --- a/exercises/practice/space-age/test.fut +++ b/exercises/practice/space-age/test.fut @@ -1,41 +1,41 @@ import "space_age" --- Age on Earth +-- age on Earth -- == -- input { "Earth" 1000000000i64 } -- output { 31.69 } --- Age on Mercury +-- age on Mercury -- == -- input { "Mercury" 2134835688i64 } -- output { 280.88 } --- Age on Venus +-- age on Venus -- == -- input { "Venus" 189839836i64 } -- output { 9.78 } --- Age on Mars +-- age on Mars -- == -- input { "Mars" 2129871239i64 } -- output { 35.88 } --- Age on Jupiter +-- age on Jupiter -- == -- input { "Jupiter" 901876382i64 } -- output { 2.41 } --- Age on Saturn +-- age on Saturn -- == -- input { "Saturn" 2000000000i64 } -- output { 2.15 } --- Age on Uranus +-- age on Uranus -- == -- input { "Uranus" 1210123456i64 } -- output { 0.46 } --- Age on Neptune +-- age on Neptune -- == -- input { "Neptune" 1821023456i64 } -- output { 0.35 } diff --git a/exercises/practice/sum-of-multiples/test.fut b/exercises/practice/sum-of-multiples/test.fut index c56b468..87fd3dd 100644 --- a/exercises/practice/sum-of-multiples/test.fut +++ b/exercises/practice/sum-of-multiples/test.fut @@ -1,81 +1,81 @@ import "sum_of_multiples" --- No multiples within limit +-- no multiples within limit -- == -- input { [3, 5] 1 } -- output { 0 } --- One factor has multiples within limit +-- one factor has multiples within limit -- == -- input { [3, 5] 4 } -- output { 3 } --- More than one multiple within limit +-- more than one multiple within limit -- == -- input { [3] 7 } -- output { 9 } --- More than one factor with multiples within limit +-- more than one factor with multiples within limit -- == -- input { [3, 5] 10 } -- output { 23 } --- Each multiple is only counted once +-- each multiple is only counted once -- == -- input { [3, 5] 100 } -- output { 2318 } --- A much larger limit +-- a much larger limit -- == -- input { [3, 5] 1000 } -- output { 233168 } --- Three factors +-- three factors -- == -- input { [7, 13, 17] 20 } -- output { 51 } --- Factors not relatively prime +-- factors not relatively prime -- == -- input { [4, 6] 15 } -- output { 30 } --- Some pairs of factors relatively prime and some not +-- some pairs of factors relatively prime and some not -- == -- input { [5, 6, 8] 150 } -- output { 4419 } --- One factor is a multiple of another +-- one factor is a multiple of another -- == -- input { [5, 25] 51 } -- output { 275 } --- Much larger factors +-- much larger factors -- == -- input { [43, 47] 10000 } -- output { 2203160 } --- All numbers are multiples of 1 +-- all numbers are multiples of 1 -- == -- input { [1] 100 } -- output { 4950 } --- No factors means an empty sum +-- no factors means an empty sum -- == -- input { empty([0]i32) 10000 } -- output { 0 } --- The only multiple of 0 is 0 +-- the only multiple of 0 is 0 -- == -- input { [0] 1 } -- output { 0 } --- The factor 0 does not affect the sum of multiples of other factors +-- the factor 0 does not affect the sum of multiples of other factors -- == -- input { [3, 0] 4 } -- output { 3 } --- Solutions using include-exclude must extend to cardinality greater than 3 +-- solutions using include-exclude must extend to cardinality greater than 3 -- == -- input { [2, 3, 5, 7, 11] 10000 } -- output { 39614537 } diff --git a/exercises/practice/triangle/test.fut b/exercises/practice/triangle/test.fut index 0efba06..d07c9ca 100644 --- a/exercises/practice/triangle/test.fut +++ b/exercises/practice/triangle/test.fut @@ -1,126 +1,126 @@ import "triangle" --- Equilateral returns all sides are equal +-- equilateral returns all sides are equal -- == -- entry: test_is_equilateral -- input { [2.0, 2.0, 2.0] } -- output { true } --- Equilateral returns any side is unequal +-- equilateral returns any side is unequal -- == -- entry: test_is_equilateral -- input { [2.0, 3.0, 2.0] } -- output { false } --- Equilateral returns no sides are equal +-- equilateral returns no sides are equal -- == -- entry: test_is_equilateral -- input { [5.0, 4.0, 6.0] } -- output { false } --- Equilateral returns all zero sides is not a triangle +-- equilateral returns all zero sides is not a triangle -- == -- entry: test_is_equilateral -- input { [0.0, 0.0, 0.0] } -- output { false } --- Equilateral returns sides may be floats +-- equilateral returns sides may be floats -- == -- entry: test_is_equilateral -- input { [0.5, 0.5, 0.5] } -- output { true } --- Isosceles returns last two sides are equal +-- isosceles returns last two sides are equal -- == -- entry: test_is_isosceles -- input { [3.0, 4.0, 4.0] } -- output { true } --- Isosceles returns first two sides are equal +-- isosceles returns first two sides are equal -- == -- entry: test_is_isosceles -- input { [4.0, 4.0, 3.0] } -- output { true } --- Isosceles returns first and last sides are equal +-- isosceles returns first and last sides are equal -- == -- entry: test_is_isosceles -- input { [4.0, 3.0, 4.0] } -- output { true } --- Equilateral triangles are also isosceles +-- equilateral triangles are also isosceles -- == -- entry: test_is_isosceles -- input { [4.0, 4.0, 4.0] } -- output { true } --- Isosceles returns no sides are equal +-- isosceles returns no sides are equal -- == -- entry: test_is_isosceles -- input { [2.0, 3.0, 4.0] } -- output { false } --- Isosceles returns first triangle inequality violation +-- isosceles returns first triangle inequality violation -- == -- entry: test_is_isosceles -- input { [1.0, 1.0, 3.0] } -- output { false } --- Isosceles returns second triangle inequality violation +-- isosceles returns second triangle inequality violation -- == -- entry: test_is_isosceles -- input { [1.0, 3.0, 1.0] } -- output { false } --- Isosceles returns third triangle inequality violation +-- isosceles returns third triangle inequality violation -- == -- entry: test_is_isosceles -- input { [3.0, 1.0, 1.0] } -- output { false } --- Isosceles returns sides may be floats +-- isosceles returns sides may be floats -- == -- entry: test_is_isosceles -- input { [0.5, 0.4, 0.5] } -- output { true } --- Scalene returns no sides are equal +-- scalene returns no sides are equal -- == -- entry: test_is_scalene -- input { [5.0, 4.0, 6.0] } -- output { true } --- Scalene returns all sides are equal +-- scalene returns all sides are equal -- == -- entry: test_is_scalene -- input { [4.0, 4.0, 4.0] } -- output { false } --- Scalene returns first and second sides are equal +-- scalene returns first and second sides are equal -- == -- entry: test_is_scalene -- input { [4.0, 4.0, 3.0] } -- output { false } --- Scalene returns first and third sides are equal +-- scalene returns first and third sides are equal -- == -- entry: test_is_scalene -- input { [3.0, 4.0, 3.0] } -- output { false } --- Scalene returns second and third sides are equal +-- scalene returns second and third sides are equal -- == -- entry: test_is_scalene -- input { [4.0, 3.0, 3.0] } -- output { false } --- Scalene returns may not violate triangle inequality +-- scalene returns may not violate triangle inequality -- == -- entry: test_is_scalene -- input { [7.0, 3.0, 2.0] } -- output { false } --- Scalene returns sides may be floats +-- scalene returns sides may be floats -- == -- entry: test_is_scalene -- input { [0.5, 0.4, 0.6] } diff --git a/exercises/practice/two-fer/test.fut b/exercises/practice/two-fer/test.fut index d3d19f3..c222bd9 100644 --- a/exercises/practice/two-fer/test.fut +++ b/exercises/practice/two-fer/test.fut @@ -1,16 +1,16 @@ import "two_fer" --- No name given +-- no name given -- == -- input { "" } -- output { "One for you, one for me." } --- A name given +-- a name given -- == -- input { "Alice" } -- output { "One for Alice, one for me." } --- Another name given +-- another name given -- == -- input { "Bob" } -- output { "One for Bob, one for me." } diff --git a/generators/exercises/raindrops.py b/generators/exercises/raindrops.py new file mode 100644 index 0000000..8c4ae14 --- /dev/null +++ b/generators/exercises/raindrops.py @@ -0,0 +1,11 @@ +def gen_test_case(prop, description, inp, expected, f): + number = inp["number"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f"-- input {{ {number} }}\n") + f.write(f'-- output {{ "{expected}" }}\n\n') + + +def gen_main(f): + f.write("let main (number: i32): []u8 =\n") + f.write(" convert number\n") diff --git a/generators/exercises/reverse_string.py b/generators/exercises/reverse_string.py new file mode 100644 index 0000000..610e57f --- /dev/null +++ b/generators/exercises/reverse_string.py @@ -0,0 +1,11 @@ +def gen_test_case(prop, description, inp, expected, f): + str = inp["value"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f'-- input {{ "{str}" }}\n') + f.write(f'-- output {{ "{expected}" }}\n\n') + + +def gen_main(f): + f.write("let main (str: []u8): []u8 =\n") + f.write(" reverse str\n") diff --git a/generators/exercises/roman_numerals.py b/generators/exercises/roman_numerals.py new file mode 100644 index 0000000..602120d --- /dev/null +++ b/generators/exercises/roman_numerals.py @@ -0,0 +1,11 @@ +def gen_test_case(prop, description, inp, expected, f): + number = inp["number"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f"-- input {{ {number} }}\n") + f.write(f'-- output {{ "{expected}" }}\n\n') + + +def gen_main(f): + f.write("let main (number: i32): []u8 =\n") + f.write(" to_roman number\n") diff --git a/generators/exercises/scrabble_score.py b/generators/exercises/scrabble_score.py new file mode 100644 index 0000000..e5ef3c9 --- /dev/null +++ b/generators/exercises/scrabble_score.py @@ -0,0 +1,11 @@ +def gen_test_case(prop, description, inp, expected, f): + letters = inp["word"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f'-- input {{ "{letters}" }}\n') + f.write(f"-- output {{ {expected} }}\n\n") + + +def gen_main(f): + f.write("let main (letters: []u8): i32 =\n") + f.write(" score letters\n") diff --git a/generators/exercises/secret_handshake.py b/generators/exercises/secret_handshake.py new file mode 100644 index 0000000..5516a0a --- /dev/null +++ b/generators/exercises/secret_handshake.py @@ -0,0 +1,13 @@ +def gen_test_case(prop, description, inp, expected, f): + code = inp["number"] + expected = ", ".join(expected) + + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f"-- input {{ {code} }}\n") + f.write(f'-- output {{ "{expected}" }}\n\n') + + +def gen_main(f): + f.write("let main (code: i32): []u8 =\n") + f.write(" commands code\n") diff --git a/generators/exercises/space_age.py b/generators/exercises/space_age.py new file mode 100644 index 0000000..ef37492 --- /dev/null +++ b/generators/exercises/space_age.py @@ -0,0 +1,12 @@ +def gen_test_case(prop, description, inp, expected, f): + planet = inp["planet"] + seconds = inp["seconds"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f'-- input {{ "{planet}" {seconds}i64 }}\n') + f.write(f"-- output {{ {expected} }}\n\n") + + +def gen_main(f): + f.write("let main (planet: []u8) (seconds: i64): f64 =\n") + f.write(" age planet seconds\n") diff --git a/generators/exercises/sum_of_multiples.py b/generators/exercises/sum_of_multiples.py new file mode 100644 index 0000000..412e0c6 --- /dev/null +++ b/generators/exercises/sum_of_multiples.py @@ -0,0 +1,14 @@ +def gen_test_case(prop, description, inp, expected, f): + factors = inp["factors"] + if factors == []: + factors = "empty([0]i32)" + limit = inp["limit"] + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f"-- input {{ {factors} {limit} }}\n") + f.write(f"-- output {{ {expected} }}\n\n") + + +def gen_main(f): + f.write("let main (numbers: []i32) (upper_bound: i32): i32 =\n") + f.write(" sum_of_multiples numbers upper_bound\n") diff --git a/generators/exercises/triangle.py b/generators/exercises/triangle.py new file mode 100644 index 0000000..928cd21 --- /dev/null +++ b/generators/exercises/triangle.py @@ -0,0 +1,26 @@ +MAIN = """\ +entry test_is_equilateral (sides: [3]f64): bool = + is_equilateral sides + +entry test_is_isosceles (sides: [3]f64): bool = + is_isosceles sides + +entry test_is_scalene (sides: [3]f64): bool = + is_scalene sides +""" + + +def gen_test_case(prop, description, inp, expected, f): + expected = str(expected).lower() + sides = list(map(float, inp["sides"])) + if "also" not in description: + description = f"{prop} returns {description}" + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f"-- entry: test_is_{prop}\n") + f.write(f"-- input {{ {sides} }}\n") + f.write(f"-- output {{ {expected} }}\n\n") + + +def gen_main(f): + f.write(MAIN) diff --git a/generators/exercises/two_fer.py b/generators/exercises/two_fer.py new file mode 100644 index 0000000..74310a7 --- /dev/null +++ b/generators/exercises/two_fer.py @@ -0,0 +1,11 @@ +def gen_test_case(prop, description, inp, expected, f): + name = inp["name"] or "" + f.write(f"-- {description}\n") + f.write("-- ==\n") + f.write(f'-- input {{ "{name}" }}\n') + f.write(f'-- output {{ "{expected}" }}\n\n') + + +def gen_main(f): + f.write("let main (name: []u8): []u8 =\n") + f.write(" two_fer name\n")