From 8fbf44fecbd0950c481fd862f44d86cd18847e3b Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Sun, 4 Aug 2024 12:29:44 -0400 Subject: [PATCH] Zig: completed Pangram, Scrabble Score, and Armstrong Numbers --- zig/armstrong-numbers/.exercism/config.json | 19 +++++ zig/armstrong-numbers/.exercism/metadata.json | 1 + zig/armstrong-numbers/HELP.md | 53 ++++++++++++++ zig/armstrong-numbers/README.md | 29 ++++++++ zig/armstrong-numbers/armstrong_numbers.zig | 17 +++++ .../test_armstrong_numbers.zig | 56 +++++++++++++++ zig/pangram/.exercism/config.json | 19 +++++ zig/pangram/.exercism/metadata.json | 1 + zig/pangram/HELP.md | 53 ++++++++++++++ zig/pangram/README.md | 40 +++++++++++ zig/pangram/pangram.zig | 18 +++++ zig/pangram/test_pangram.zig | 48 +++++++++++++ zig/scrabble-score/.exercism/config.json | 19 +++++ zig/scrabble-score/.exercism/metadata.json | 1 + zig/scrabble-score/HELP.md | 53 ++++++++++++++ zig/scrabble-score/README.md | 48 +++++++++++++ zig/scrabble-score/scrabble_score.zig | 18 +++++ zig/scrabble-score/test_scrabble_score.zig | 70 +++++++++++++++++++ 18 files changed, 563 insertions(+) create mode 100644 zig/armstrong-numbers/.exercism/config.json create mode 100644 zig/armstrong-numbers/.exercism/metadata.json create mode 100644 zig/armstrong-numbers/HELP.md create mode 100644 zig/armstrong-numbers/README.md create mode 100644 zig/armstrong-numbers/armstrong_numbers.zig create mode 100644 zig/armstrong-numbers/test_armstrong_numbers.zig create mode 100644 zig/pangram/.exercism/config.json create mode 100644 zig/pangram/.exercism/metadata.json create mode 100644 zig/pangram/HELP.md create mode 100644 zig/pangram/README.md create mode 100644 zig/pangram/pangram.zig create mode 100644 zig/pangram/test_pangram.zig create mode 100644 zig/scrabble-score/.exercism/config.json create mode 100644 zig/scrabble-score/.exercism/metadata.json create mode 100644 zig/scrabble-score/HELP.md create mode 100644 zig/scrabble-score/README.md create mode 100644 zig/scrabble-score/scrabble_score.zig create mode 100644 zig/scrabble-score/test_scrabble_score.zig diff --git a/zig/armstrong-numbers/.exercism/config.json b/zig/armstrong-numbers/.exercism/config.json new file mode 100644 index 0000000..017cd77 --- /dev/null +++ b/zig/armstrong-numbers/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "ee7" + ], + "files": { + "solution": [ + "armstrong_numbers.zig" + ], + "test": [ + "test_armstrong_numbers.zig" + ], + "example": [ + ".meta/example.zig" + ] + }, + "blurb": "Determine if a number is an Armstrong number.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" +} diff --git a/zig/armstrong-numbers/.exercism/metadata.json b/zig/armstrong-numbers/.exercism/metadata.json new file mode 100644 index 0000000..169de0b --- /dev/null +++ b/zig/armstrong-numbers/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"zig","exercise":"armstrong-numbers","id":"1ca0d9a30cd74f64a84eb3638bbd3ef3","url":"https://exercism.org/tracks/zig/exercises/armstrong-numbers","handle":"Chomp1295","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/zig/armstrong-numbers/HELP.md b/zig/armstrong-numbers/HELP.md new file mode 100644 index 0000000..8d9c458 --- /dev/null +++ b/zig/armstrong-numbers/HELP.md @@ -0,0 +1,53 @@ +# Help + +## Running the tests + +Write your code in `.zig`. + +To run the tests for an exercise, run: + +```bash +zig test test_exercise_name.zig +``` + +in the exercise's root directory (replacing `exercise_name` with the name of the exercise). + +## Submitting your solution + +You can submit your solution using the `exercism submit armstrong_numbers.zig` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Zig track's documentation](https://exercism.org/docs/tracks/zig) +- The [Zig track's programming category on the forum](https://forum.exercism.org/c/programming/zig) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +- [The Zig Programming Language Documentation][documentation] is a great overview of all of the language features that Zig provides to those who use it. +- [Zig Guide][zig-guide] is an excellent primer that explains the language features that Zig has to offer. +- [Ziglings][ziglings] is highly recommended. + Learn Zig by fixing tiny broken programs. +- [The Zig Programming Language Discord][discord-zig] is the main [Discord][discord]. + It provides a great way to get in touch with the Zig community at large, and get some quick, direct help for any Zig related problem. +- [#zig][irc] on irc.freenode.net is the main Zig IRC channel. +- [/r/Zig][reddit] is the main Zig subreddit. +- [Stack Overflow][stack-overflow] can be used to discover code snippets and solutions to problems that may have already asked and maybe solved by others. + +[discord]: https://discordapp.com +[discord-zig]: https://discord.com/invite/gxsFFjE +[documentation]: https://ziglang.org/documentation/master +[irc]: https://webchat.freenode.net/?channels=%23zig +[reddit]: https://www.reddit.com/r/Zig +[stack-overflow]: https://stackoverflow.com/questions/tagged/zig +[zig-guide]: https://zig.guide/ +[ziglings]: https://codeberg.org/ziglings/exercises \ No newline at end of file diff --git a/zig/armstrong-numbers/README.md b/zig/armstrong-numbers/README.md new file mode 100644 index 0000000..9001029 --- /dev/null +++ b/zig/armstrong-numbers/README.md @@ -0,0 +1,29 @@ +# Armstrong Numbers + +Welcome to Armstrong Numbers on Exercism's Zig Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. + +For example: + +- 9 is an Armstrong number, because `9 = 9^1 = 9` +- 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1` +- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` +- 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` + +Write some code to determine whether a number is an Armstrong number. + +[armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number + +## Source + +### Created by + +- @ee7 + +### Based on + +Wikipedia - https://en.wikipedia.org/wiki/Narcissistic_number \ No newline at end of file diff --git a/zig/armstrong-numbers/armstrong_numbers.zig b/zig/armstrong-numbers/armstrong_numbers.zig new file mode 100644 index 0000000..a34e67b --- /dev/null +++ b/zig/armstrong-numbers/armstrong_numbers.zig @@ -0,0 +1,17 @@ +const std = @import("std"); + +pub fn isArmstrongNumber(num: u128) bool { + var digits: u8 = 0; + var digits_rem = num; + while (digits_rem != 0) : (digits_rem /= 10) { + digits += 1; + } + + var sum: u128 = 0; + var num_rem = num; + while (num_rem != 0) : (num_rem /= 10) { + sum += std.math.pow(u128, num_rem % 10, digits); + } + + return num == sum; +} diff --git a/zig/armstrong-numbers/test_armstrong_numbers.zig b/zig/armstrong-numbers/test_armstrong_numbers.zig new file mode 100644 index 0000000..4e8f05f --- /dev/null +++ b/zig/armstrong-numbers/test_armstrong_numbers.zig @@ -0,0 +1,56 @@ +const std = @import("std"); +const testing = std.testing; + +const isArmstrongNumber = @import("armstrong_numbers.zig").isArmstrongNumber; + +test "zero is an armstrong number" { + try testing.expect(isArmstrongNumber(0)); +} + +test "single-digit numbers are armstrong numbers" { + try testing.expect(isArmstrongNumber(5)); +} + +test "there are no two-digit armstrong numbers" { + try testing.expect(!isArmstrongNumber(10)); +} + +test "three-digit number that is an armstrong number" { + try testing.expect(isArmstrongNumber(153)); +} + +test "three-digit number that is not an armstrong number" { + try testing.expect(!isArmstrongNumber(100)); +} + +test "four-digit number that is an armstrong number" { + try testing.expect(isArmstrongNumber(9_474)); +} + +test "four-digit number that is not an armstrong number" { + try testing.expect(!isArmstrongNumber(9_475)); +} + +test "seven-digit number that is an armstrong number" { + try testing.expect(isArmstrongNumber(9_926_315)); +} + +test "seven-digit number that is not an armstrong number" { + try testing.expect(!isArmstrongNumber(9_926_314)); +} + +test "33-digit number that is an armstrong number" { + try testing.expect(isArmstrongNumber(186_709_961_001_538_790_100_634_132_976_990)); +} + +test "38-digit number that is not an armstrong number" { + try testing.expect(!isArmstrongNumber(99_999_999_999_999_999_999_999_999_999_999_999_999)); +} + +test "the largest and last armstrong number" { + try testing.expect(isArmstrongNumber(115_132_219_018_763_992_565_095_597_973_971_522_401)); +} + +test "the largest 128-bit unsigned integer value is not an armstrong number" { + try testing.expect(!isArmstrongNumber(340_282_366_920_938_463_463_374_607_431_768_211_455)); +} diff --git a/zig/pangram/.exercism/config.json b/zig/pangram/.exercism/config.json new file mode 100644 index 0000000..6911952 --- /dev/null +++ b/zig/pangram/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "massivelivefun" + ], + "files": { + "solution": [ + "pangram.zig" + ], + "test": [ + "test_pangram.zig" + ], + "example": [ + ".meta/example.zig" + ] + }, + "blurb": "Determine if a sentence is a pangram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Pangram" +} diff --git a/zig/pangram/.exercism/metadata.json b/zig/pangram/.exercism/metadata.json new file mode 100644 index 0000000..5bb87f3 --- /dev/null +++ b/zig/pangram/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"zig","exercise":"pangram","id":"8ca6b789549d4f8fb857e7b5d0ecb09f","url":"https://exercism.org/tracks/zig/exercises/pangram","handle":"Chomp1295","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/zig/pangram/HELP.md b/zig/pangram/HELP.md new file mode 100644 index 0000000..ab79554 --- /dev/null +++ b/zig/pangram/HELP.md @@ -0,0 +1,53 @@ +# Help + +## Running the tests + +Write your code in `.zig`. + +To run the tests for an exercise, run: + +```bash +zig test test_exercise_name.zig +``` + +in the exercise's root directory (replacing `exercise_name` with the name of the exercise). + +## Submitting your solution + +You can submit your solution using the `exercism submit pangram.zig` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Zig track's documentation](https://exercism.org/docs/tracks/zig) +- The [Zig track's programming category on the forum](https://forum.exercism.org/c/programming/zig) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +- [The Zig Programming Language Documentation][documentation] is a great overview of all of the language features that Zig provides to those who use it. +- [Zig Guide][zig-guide] is an excellent primer that explains the language features that Zig has to offer. +- [Ziglings][ziglings] is highly recommended. + Learn Zig by fixing tiny broken programs. +- [The Zig Programming Language Discord][discord-zig] is the main [Discord][discord]. + It provides a great way to get in touch with the Zig community at large, and get some quick, direct help for any Zig related problem. +- [#zig][irc] on irc.freenode.net is the main Zig IRC channel. +- [/r/Zig][reddit] is the main Zig subreddit. +- [Stack Overflow][stack-overflow] can be used to discover code snippets and solutions to problems that may have already asked and maybe solved by others. + +[discord]: https://discordapp.com +[discord-zig]: https://discord.com/invite/gxsFFjE +[documentation]: https://ziglang.org/documentation/master +[irc]: https://webchat.freenode.net/?channels=%23zig +[reddit]: https://www.reddit.com/r/Zig +[stack-overflow]: https://stackoverflow.com/questions/tagged/zig +[zig-guide]: https://zig.guide/ +[ziglings]: https://codeberg.org/ziglings/exercises \ No newline at end of file diff --git a/zig/pangram/README.md b/zig/pangram/README.md new file mode 100644 index 0000000..d7b41f8 --- /dev/null +++ b/zig/pangram/README.md @@ -0,0 +1,40 @@ +# Pangram + +Welcome to Pangram on Exercism's Zig Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +You work for a company that sells fonts through their website. +They'd like to show a different sentence each time someone views a font on their website. +To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. + +They're running a competition to get suggestions for sentences that they can use. +You're in charge of checking the submissions to see if they are valid. + +~~~~exercism/note +Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". + +The best known English pangram is: + +> The quick brown fox jumps over the lazy dog. +~~~~ + +## Instructions + +Your task is to figure out if a sentence is a pangram. + +A pangram is a sentence using every letter of the alphabet at least once. +It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). + +For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. + +## Source + +### Created by + +- @massivelivefun + +### Based on + +Wikipedia - https://en.wikipedia.org/wiki/Pangram \ No newline at end of file diff --git a/zig/pangram/pangram.zig b/zig/pangram/pangram.zig new file mode 100644 index 0000000..1c7a9b3 --- /dev/null +++ b/zig/pangram/pangram.zig @@ -0,0 +1,18 @@ +const ascii = @import("std").ascii; + +pub fn isPangram(str: []const u8) bool { + var alphabet = [_]u8{0} ** 26; + + for (str) |c| { + if (!ascii.isAlphabetic(c)) { + continue; + } + alphabet[ascii.toLower(c) - 97] += 1; + } + + for (alphabet) |count| { + if (count == 0) return false; + } + + return true; +} diff --git a/zig/pangram/test_pangram.zig b/zig/pangram/test_pangram.zig new file mode 100644 index 0000000..02d402a --- /dev/null +++ b/zig/pangram/test_pangram.zig @@ -0,0 +1,48 @@ +const std = @import("std"); +const testing = std.testing; + +const pangram = @import("pangram.zig"); + +test "empty sentence" { + try testing.expect(!pangram.isPangram("")); +} + +test "perfect lower case" { + try testing.expect(pangram.isPangram("abcdefghijklmnopqrstuvwxyz")); +} + +test "only lower case" { + try testing.expect(pangram.isPangram("the quick brown fox jumps over the lazy dog")); +} + +test "missing the letter 'x'" { + try testing.expect(!pangram.isPangram("a quick movement of the enemy will jeopardize five gunboats")); +} + +test "missing the letter 'h'" { + try testing.expect(!pangram.isPangram("five boxing wizards jump quickly at it")); +} + +test "with underscores" { + try testing.expect(pangram.isPangram("the_quick_brown_fox_jumps_over_the_lazy_dog")); +} + +test "with numbers" { + try testing.expect(pangram.isPangram("the 1 quick brown fox jumps over the 2 lazy dogs")); +} + +test "missing letters replaced by numbers" { + try testing.expect(!pangram.isPangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")); +} + +test "mixed case and punctuation" { + try testing.expect(pangram.isPangram("\"Five quacking Zephyrs jolt my wax bed.\"")); +} + +test "a-m and A-M are 26 different characters but not a pangram" { + try testing.expect(!pangram.isPangram("abcdefghijklm ABCDEFGHIJKLM")); +} + +test "non-alphanumeric printable ASCII" { + try testing.expect(!pangram.isPangram(" !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")); +} diff --git a/zig/scrabble-score/.exercism/config.json b/zig/scrabble-score/.exercism/config.json new file mode 100644 index 0000000..d33eacc --- /dev/null +++ b/zig/scrabble-score/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "ee7" + ], + "files": { + "solution": [ + "scrabble_score.zig" + ], + "test": [ + "test_scrabble_score.zig" + ], + "example": [ + ".meta/example.zig" + ] + }, + "blurb": "Given a word, compute the Scrabble score for that word.", + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/zig/scrabble-score/.exercism/metadata.json b/zig/scrabble-score/.exercism/metadata.json new file mode 100644 index 0000000..b84fa62 --- /dev/null +++ b/zig/scrabble-score/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"zig","exercise":"scrabble-score","id":"bb07d3f27fd543c2875b5f72e0b0316e","url":"https://exercism.org/tracks/zig/exercises/scrabble-score","handle":"Chomp1295","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/zig/scrabble-score/HELP.md b/zig/scrabble-score/HELP.md new file mode 100644 index 0000000..9df4623 --- /dev/null +++ b/zig/scrabble-score/HELP.md @@ -0,0 +1,53 @@ +# Help + +## Running the tests + +Write your code in `.zig`. + +To run the tests for an exercise, run: + +```bash +zig test test_exercise_name.zig +``` + +in the exercise's root directory (replacing `exercise_name` with the name of the exercise). + +## Submitting your solution + +You can submit your solution using the `exercism submit scrabble_score.zig` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Zig track's documentation](https://exercism.org/docs/tracks/zig) +- The [Zig track's programming category on the forum](https://forum.exercism.org/c/programming/zig) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +- [The Zig Programming Language Documentation][documentation] is a great overview of all of the language features that Zig provides to those who use it. +- [Zig Guide][zig-guide] is an excellent primer that explains the language features that Zig has to offer. +- [Ziglings][ziglings] is highly recommended. + Learn Zig by fixing tiny broken programs. +- [The Zig Programming Language Discord][discord-zig] is the main [Discord][discord]. + It provides a great way to get in touch with the Zig community at large, and get some quick, direct help for any Zig related problem. +- [#zig][irc] on irc.freenode.net is the main Zig IRC channel. +- [/r/Zig][reddit] is the main Zig subreddit. +- [Stack Overflow][stack-overflow] can be used to discover code snippets and solutions to problems that may have already asked and maybe solved by others. + +[discord]: https://discordapp.com +[discord-zig]: https://discord.com/invite/gxsFFjE +[documentation]: https://ziglang.org/documentation/master +[irc]: https://webchat.freenode.net/?channels=%23zig +[reddit]: https://www.reddit.com/r/Zig +[stack-overflow]: https://stackoverflow.com/questions/tagged/zig +[zig-guide]: https://zig.guide/ +[ziglings]: https://codeberg.org/ziglings/exercises \ No newline at end of file diff --git a/zig/scrabble-score/README.md b/zig/scrabble-score/README.md new file mode 100644 index 0000000..358e002 --- /dev/null +++ b/zig/scrabble-score/README.md @@ -0,0 +1,48 @@ +# Scrabble Score + +Welcome to Scrabble Score on Exercism's Zig Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +[Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. +Each letter has a value. +A word's score is the sum of its letters' values. + +[wikipedia]: https://en.wikipedia.org/wiki/Scrabble + +## Instructions + +Your task is to compute a word's Scrabble score by summing the values of its letters. + +The letters are valued as follows: + +| Letter | Value | +| ---------------------------- | ----- | +| A, E, I, O, U, L, N, R, S, T | 1 | +| D, G | 2 | +| B, C, M, P | 3 | +| F, H, V, W, Y | 4 | +| K | 5 | +| J, X | 8 | +| Q, Z | 10 | + +For example, the word "cabbage" is worth 14 points: + +- 3 points for C +- 1 point for A +- 3 points for B +- 3 points for B +- 1 point for A +- 2 points for G +- 1 point for E + +## Source + +### Created by + +- @ee7 + +### Based on + +Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup \ No newline at end of file diff --git a/zig/scrabble-score/scrabble_score.zig b/zig/scrabble-score/scrabble_score.zig new file mode 100644 index 0000000..1edce14 --- /dev/null +++ b/zig/scrabble-score/scrabble_score.zig @@ -0,0 +1,18 @@ +const std = @import("std"); + +pub fn score(s: []const u8) u32 { + var total: u32 = 0; + for (s) |c| { + total += switch (std.ascii.toLower(c)) { + 'a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't' => 1, + 'd', 'g' => 2, + 'b', 'c', 'm', 'p' => 3, + 'f', 'h', 'v', 'w', 'y' => 4, + 'k' => 5, + 'j', 'x' => 8, + 'q', 'z' => 10, + else => unreachable, + }; + } + return total; +} diff --git a/zig/scrabble-score/test_scrabble_score.zig b/zig/scrabble-score/test_scrabble_score.zig new file mode 100644 index 0000000..f22d4b9 --- /dev/null +++ b/zig/scrabble-score/test_scrabble_score.zig @@ -0,0 +1,70 @@ +const std = @import("std"); +const testing = std.testing; + +const score = @import("scrabble_score.zig").score; + +test "lowercase letter" { + const expected: u32 = 1; + const actual = score("a"); + try testing.expectEqual(expected, actual); +} + +test "uppercase letter" { + const expected: u32 = 1; + const actual = score("A"); + try testing.expectEqual(expected, actual); +} + +test "valuable letter" { + const expected: u32 = 4; + const actual = score("f"); + try testing.expectEqual(expected, actual); +} + +test "short word" { + const expected: u32 = 2; + const actual = score("at"); + try testing.expectEqual(expected, actual); +} + +test "short, valuable word" { + const expected: u32 = 12; + const actual = score("zoo"); + try testing.expectEqual(expected, actual); +} + +test "medium word" { + const expected: u32 = 6; + const actual = score("street"); + try testing.expectEqual(expected, actual); +} + +test "medium, valuable word" { + const expected: u32 = 22; + const actual = score("quirky"); + try testing.expectEqual(expected, actual); +} + +test "long, mixed-case word" { + const expected: u32 = 41; + const actual = score("OxyphenButazone"); + try testing.expectEqual(expected, actual); +} + +test "english-like word" { + const expected: u32 = 8; + const actual = score("pinata"); + try testing.expectEqual(expected, actual); +} + +test "empty input" { + const expected: u32 = 0; + const actual = score(""); + try testing.expectEqual(expected, actual); +} + +test "entire alphabet available" { + const expected: u32 = 87; + const actual = score("abcdefghijklmnopqrstuvwxyz"); + try testing.expectEqual(expected, actual); +}