Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 11 additions & 11 deletions exercises/practice/grains/test.fut
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
import "grains"

-- Grains on square 1
-- grains on square 1
-- ==
-- entry: test_square
-- input { 1 }
-- output { 1u64 }

-- Grains on square 2
-- grains on square 2
-- ==
-- entry: test_square
-- input { 2 }
-- output { 2u64 }

-- Grains on square 3
-- grains on square 3
-- ==
-- entry: test_square
-- input { 3 }
-- output { 4u64 }

-- Grains on square 4
-- grains on square 4
-- ==
-- entry: test_square
-- input { 4 }
-- output { 8u64 }

-- Grains on square 16
-- grains on square 16
-- ==
-- entry: test_square
-- input { 16 }
-- output { 32768u64 }

-- Grains on square 32
-- grains on square 32
-- ==
-- entry: test_square
-- input { 32 }
-- output { 2147483648u64 }

-- Grains on square 64
-- grains on square 64
-- ==
-- entry: test_square
-- input { 64 }
-- output { 9223372036854775808u64 }

-- Square 0 is invalid
-- square 0 is invalid
-- ==
-- entry: test_square
-- input { 0 }
-- error: Error*

-- Negative square is invalid
-- negative square is invalid
-- ==
-- entry: test_square
-- input { -1 }
-- error: Error*

-- Square greater than 64 is invalid
-- square greater than 64 is invalid
-- ==
-- entry: test_square
-- input { 65 }
-- error: Error*

-- Returns the total number of grains on the board
-- returns the total number of grains on the board
-- ==
-- entry: test_total
-- input { 42 }
Expand Down
18 changes: 9 additions & 9 deletions exercises/practice/hamming/test.fut
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import "hamming"

-- Empty strands
-- empty strands
-- ==
-- input { "" "" }
-- output { 0 }

-- Single letter identical strands
-- single letter identical strands
-- ==
-- input { "A" "A" }
-- output { 0 }

-- Single letter different strands
-- single letter different strands
-- ==
-- input { "G" "T" }
-- output { 1 }

-- Long identical strands
-- long identical strands
-- ==
-- input { "GGACTGAAATCTG" "GGACTGAAATCTG" }
-- output { 0 }

-- Long different strands
-- long different strands
-- ==
-- input { "GGACGGATTCTG" "AGGACGGATTCT" }
-- output { 9 }

-- Disallow first strand longer
-- disallow first strand longer
-- ==
-- input { "AATG" "AAA" }
-- error: Error*

-- Disallow second strand longer
-- disallow second strand longer
-- ==
-- input { "ATA" "AGTG" }
-- error: Error*

-- Disallow empty first strand
-- disallow empty first strand
-- ==
-- input { "" "G" }
-- error: Error*

-- Disallow empty second strand
-- disallow empty second strand
-- ==
-- input { "G" "" }
-- error: Error*
Expand Down
4 changes: 4 additions & 0 deletions exercises/practice/high-scores/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ include = false

[2df075f9-fec9-4756-8f40-98c52a11504f]
description = "Top 3 scores -> Latest score after personal top scores"
include = false

[809c4058-7eb1-4206-b01e-79238b9b71bc]
description = "Top 3 scores -> Scores after personal top scores"
include = false

[ddb0efc0-9a86-4f82-bc30-21ae0bdc6418]
description = "Top 3 scores -> Latest score after personal best"
include = false

[6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364]
description = "Top 3 scores -> Scores after personal best"
include = false
28 changes: 14 additions & 14 deletions exercises/practice/isogram/test.fut
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
import "isogram"

-- Empty string
-- empty string
-- ==
-- input { "" }
-- output { true }

-- Isogram with only lower case characters
-- isogram with only lower case characters
-- ==
-- input { "isogram" }
-- output { true }

-- Word with one duplicated character
-- word with one duplicated character
-- ==
-- input { "eleven" }
-- output { false }

-- Word with one duplicated character from the end of the alphabet
-- word with one duplicated character from the end of the alphabet
-- ==
-- input { "zzyzx" }
-- output { false }

-- Longest reported english isogram
-- longest reported english isogram
-- ==
-- input { "subdermatoglyphic" }
-- output { true }

-- Word with duplicated character in mixed case
-- word with duplicated character in mixed case
-- ==
-- input { "Alphabet" }
-- output { false }

-- Word with duplicated character in mixed case, lowercase first
-- word with duplicated character in mixed case, lowercase first
-- ==
-- input { "alphAbet" }
-- output { false }

-- Hypothetical isogrammic word with hyphen
-- hypothetical isogrammic word with hyphen
-- ==
-- input { "thumbscrew-japingly" }
-- output { true }

-- Hypothetical word with duplicated character following hyphen
-- hypothetical word with duplicated character following hyphen
-- ==
-- input { "thumbscrew-jappingly" }
-- output { false }

-- Isogram with duplicated hyphen
-- isogram with duplicated hyphen
-- ==
-- input { "six-year-old" }
-- output { true }

-- Made-up name that is an isogram
-- made-up name that is an isogram
-- ==
-- input { "Emily Jung Schwartzkopf" }
-- output { true }

-- Duplicated character in the middle
-- duplicated character in the middle
-- ==
-- input { "accentor" }
-- output { false }

-- Same first and last characters
-- same first and last characters
-- ==
-- input { "angola" }
-- output { false }

-- Word with duplicated character and with two hyphens
-- word with duplicated character and with two hyphens
-- ==
-- input { "up-to-date" }
-- output { false }
Expand Down
18 changes: 9 additions & 9 deletions exercises/practice/leap/test.fut
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import "leap"

-- Year not divisible by 4 in common year
-- year not divisible by 4 in common year
-- ==
-- input { 2015 }
-- output { false }

-- Year divisible by 2, not divisible by 4 in common year
-- year divisible by 2, not divisible by 4 in common year
-- ==
-- input { 1970 }
-- output { false }

-- Year divisible by 4, not divisible by 100 in leap year
-- year divisible by 4, not divisible by 100 in leap year
-- ==
-- input { 1996 }
-- output { true }

-- Year divisible by 4 and 5 is still a leap year
-- year divisible by 4 and 5 is still a leap year
-- ==
-- input { 1960 }
-- output { true }

-- Year divisible by 100, not divisible by 400 in common year
-- year divisible by 100, not divisible by 400 in common year
-- ==
-- input { 2100 }
-- output { false }

-- Year divisible by 100 but not by 3 is still not a leap year
-- year divisible by 100 but not by 3 is still not a leap year
-- ==
-- input { 1900 }
-- output { false }

-- Year divisible by 400 is leap year
-- year divisible by 400 is leap year
-- ==
-- input { 2000 }
-- output { true }

-- Year divisible by 400 but not by 125 is still a leap year
-- year divisible by 400 but not by 125 is still a leap year
-- ==
-- input { 2400 }
-- output { true }

-- Year divisible by 200, not divisible by 400 in common year
-- year divisible by 200, not divisible by 400 in common year
-- ==
-- input { 1800 }
-- output { false }
Expand Down
22 changes: 11 additions & 11 deletions exercises/practice/pangram/test.fut
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import "pangram"

-- Empty sentence
-- empty sentence
-- ==
-- input { "" }
-- output { false }

-- Perfect lower case
-- perfect lower case
-- ==
-- input { "abcdefghijklmnopqrstuvwxyz" }
-- output { true }

-- Only lower case
-- only lower case
-- ==
-- input { "the quick brown fox jumps over the lazy dog" }
-- output { true }

-- Missing the letter 'x'
-- missing the letter 'x'
-- ==
-- input { "a quick movement of the enemy will jeopardize five gunboats" }
-- output { false }

-- Missing the letter 'h'
-- missing the letter 'h'
-- ==
-- input { "five boxing wizards jump quickly at it" }
-- output { false }

-- With underscores
-- with underscores
-- ==
-- input { "the_quick_brown_fox_jumps_over_the_lazy_dog" }
-- output { true }

-- With numbers
-- with numbers
-- ==
-- input { "the 1 quick brown fox jumps over the 2 lazy dogs" }
-- output { true }

-- Missing letters replaced by numbers
-- missing letters replaced by numbers
-- ==
-- input { "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog" }
-- output { false }

-- Mixed case and punctuation
-- mixed case and punctuation
-- ==
-- input { "\"Five quacking Zephyrs jolt my wax bed.\"" }
-- output { true }

-- A-m and A-M are 26 different characters but not a pangram
-- a-m and A-M are 26 different characters but not a pangram
-- ==
-- input { "abcdefghijklm ABCDEFGHIJKLM" }
-- output { false }

let main (sentence: []u8): bool =
is_pangram sentence
is_pangram sentence
28 changes: 28 additions & 0 deletions generators/exercises/grains.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MAIN = """\
entry test_square (n: i32): u64 =
square n

entry test_total (_n: i32): u64 =
total ()
"""


def gen_test_case(prop, description, inp, expected, f):
if prop == "total":
square = 42
else:
square = inp["square"]

f.write(f"-- {description}\n")
f.write("-- ==\n")
f.write(f"-- entry: test_{prop}\n")
f.write(f"-- input {{ {square} }}\n")

if isinstance(expected, dict):
f.write("-- error: Error*\n\n")
else:
f.write(f"-- output {{ {expected}u64 }}\n\n")


def gen_main(f):
f.write(MAIN)
Loading