From 6960c8aa8005a009c3d4317ab7a658bd62763cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:25:45 -0700 Subject: [PATCH] Add pop-count exercise --- config.json | 151 +++++++----------- .../practice/pop-count/.docs/instructions.md | 8 + .../practice/pop-count/.docs/introduction.md | 47 ++++++ exercises/practice/pop-count/.gitignore | 4 + .../practice/pop-count/.meta/config.json | 23 +++ .../practice/pop-count/.meta/example.gleam | 19 +++ exercises/practice/pop-count/.meta/tests.toml | 22 +++ exercises/practice/pop-count/gleam.toml | 11 ++ exercises/practice/pop-count/gleam.toml-e | 11 ++ exercises/practice/pop-count/manifest.toml | 25 +++ .../practice/pop-count/src/pop_count.gleam | 3 + .../pop-count/test/pop_count_test.gleam | 27 ++++ 12 files changed, 259 insertions(+), 92 deletions(-) create mode 100644 exercises/practice/pop-count/.docs/instructions.md create mode 100644 exercises/practice/pop-count/.docs/introduction.md create mode 100644 exercises/practice/pop-count/.gitignore create mode 100644 exercises/practice/pop-count/.meta/config.json create mode 100644 exercises/practice/pop-count/.meta/example.gleam create mode 100644 exercises/practice/pop-count/.meta/tests.toml create mode 100644 exercises/practice/pop-count/gleam.toml create mode 100644 exercises/practice/pop-count/gleam.toml-e create mode 100644 exercises/practice/pop-count/manifest.toml create mode 100644 exercises/practice/pop-count/src/pop_count.gleam create mode 100644 exercises/practice/pop-count/test/pop_count_test.gleam diff --git a/config.json b/config.json index 9f1451374..227c50eea 100644 --- a/config.json +++ b/config.json @@ -560,8 +560,7 @@ "name": "Forth", "uuid": "8176ac78-d4fd-475f-ac8b-e205ca7b3a77", "difficulty": 9, - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "strings", @@ -645,8 +644,7 @@ "slug": "protein-translation", "name": "Protein Translation", "uuid": "612395a5-238e-4be0-8ce0-4ac66f57056e", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1012,8 +1010,7 @@ "slug": "alphametics", "name": "Alphametics", "uuid": "5aef7d9d-3939-4014-8102-a7262fdde754", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "sets", @@ -1062,8 +1059,7 @@ "slug": "acronym", "name": "Acronym", "uuid": "21946b94-c304-4a10-a6b6-b9fd5bbe9966", - "practices": [ - ], + "practices": [], "prerequisites": [ "labelled-arguments", "regular-expressions", @@ -1204,8 +1200,7 @@ "slug": "prime-factors", "name": "Prime Factors", "uuid": "00d1a428-99c4-4175-bee2-e05fc034528f", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "lists", @@ -1218,8 +1213,7 @@ "slug": "run-length-encoding", "name": "Run-Length Encoding", "uuid": "22298714-cc36-49b7-8e70-cfb91ff42112", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "strings", @@ -1233,8 +1227,7 @@ "slug": "grains", "name": "Grains", "uuid": "b5b9be18-9141-4176-8f8c-3dd14d14bed5", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "case-expressions", @@ -1247,8 +1240,7 @@ "slug": "nucleotide-count", "name": "Nucleotide count", "uuid": "3b7e1bbf-08b2-4e0e-ba5d-5a887deb4817", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "results", @@ -1262,8 +1254,7 @@ "slug": "hamming", "name": "Hamming", "uuid": "64a40995-c380-4233-a7af-98498dbc5c2d", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "strings", @@ -1277,8 +1268,7 @@ "slug": "proverb", "name": "Proverb", "uuid": "d2288ce0-3ef4-4a79-8e21-bf5624b5ab27", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "strings", @@ -1290,8 +1280,7 @@ "slug": "high-scores", "name": "High Scores", "uuid": "af720091-1352-4e07-96d2-0868588601f2", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "ints", @@ -1303,8 +1292,7 @@ "slug": "allergies", "name": "Allergies", "uuid": "f829a1af-0eaf-4880-b1d8-cd2cb3753fb0", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "lists", @@ -1318,8 +1306,7 @@ "name": "Twelve Days", "uuid": "583b74dc-2c5c-48f8-85c2-c90623507682", "difficulty": 3, - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1331,8 +1318,7 @@ "slug": "etl", "name": "ETL", "uuid": "1655d9f6-6199-4462-85bd-a5da5f25d30a", - "practices": [ - ], + "practices": [], "prerequisites": [ "maps", "lists", @@ -1345,8 +1331,7 @@ "slug": "queen-attack", "name": "Queen Attack", "uuid": "9caa195e-2273-4096-9aee-26ab5658e7f7", - "practices": [ - ], + "practices": [], "prerequisites": [ "custom-types", "case-expressions", @@ -1359,8 +1344,7 @@ "slug": "sublist", "name": "Sublist", "uuid": "6d4933cc-0845-4992-93ee-54f79a79fc5a", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "case-expressions", @@ -1374,8 +1358,7 @@ "slug": "rotational-cipher", "name": "Rotational Cipher", "uuid": "2e7fdb4d-3e75-4dc2-9fb7-ee1a9e1950f9", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "ints", @@ -1387,8 +1370,7 @@ "slug": "change", "name": "Change", "uuid": "8dc8aceb-fe74-415c-bf4b-956840155272", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "results", @@ -1401,8 +1383,7 @@ "slug": "flatten-array", "name": "Flatten Array", "uuid": "efdf70a3-57e6-474a-9fc2-09f26bb609b6", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "custom-types", @@ -1415,8 +1396,7 @@ "slug": "all-your-base", "name": "All Your Base", "uuid": "e9332e6f-a7e5-4f30-825c-64af0a278a70", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "lists", @@ -1430,8 +1410,7 @@ "slug": "knapsack", "name": "Knapsack", "uuid": "6e889724-656e-4f0c-aba1-08f103490e9d", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "custom-types", @@ -1460,8 +1439,7 @@ "slug": "dnd-character", "name": "D&D Character", "uuid": "65d80b55-02f0-4d40-a530-79843553252f", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "custom-types", @@ -1473,8 +1451,7 @@ "slug": "isbn-verifier", "name": "ISBN Verifier", "uuid": "d12ac283-8ca4-4b40-919a-9588e1e52d50", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "ints", @@ -1504,8 +1481,7 @@ "slug": "atbash-cipher", "name": "Atbash Cipher", "uuid": "3c850415-92fa-4019-b776-aaab30675680", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1518,8 +1494,7 @@ "slug": "square-root", "name": "Square Root", "uuid": "700f44e5-13a3-4e97-aad5-d383e25f9f9b", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "bools", @@ -1547,8 +1522,7 @@ "slug": "simple-cipher", "name": "Simple Cipher", "uuid": "37dd415b-1d67-434d-8705-19295d1438b8", - "practices": [ - ], + "practices": [], "prerequisites": [ "iterators", "strings", @@ -1562,8 +1536,7 @@ "slug": "crypto-square", "name": "Crypto Square", "uuid": "5bf01e81-b30a-4210-b1ed-1edbf3d28ab1", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "lists", @@ -1576,8 +1549,7 @@ "slug": "affine-cipher", "name": "Affine Cipher", "uuid": "594b6c1a-0a4c-4463-9535-62056c71404e", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1593,8 +1565,7 @@ "slug": "house", "name": "House", "uuid": "21421905-a33c-4040-9f09-78726b5d1167", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1607,8 +1578,7 @@ "slug": "connect", "name": "Connect", "uuid": "89c6bf7a-5cd8-4254-b3e0-1457a5390b46", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "maps", @@ -1624,8 +1594,7 @@ "slug": "clock", "name": "Clock", "uuid": "ad9cc1bd-d99b-4f43-941c-8e09b43801af", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "strings", @@ -1638,8 +1607,7 @@ "slug": "killer-sudoku-helper", "name": "Killer Sudoku Helper", "uuid": "4c6ed017-a02b-4826-a111-ef9733b7d315", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "ints", @@ -1651,8 +1619,7 @@ "slug": "luhn", "name": "Luhn", "uuid": "a66bbefd-db5a-44d0-ab4b-73d871756f08", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1667,8 +1634,7 @@ "slug": "wordy", "name": "Wordy", "uuid": "5031033b-bd21-4563-ae18-59ad02f4c489", - "practices": [ - ], + "practices": [], "prerequisites": [ "results", "strings", @@ -1684,8 +1650,7 @@ "slug": "largest-series-product", "name": "Largest Series Product", "uuid": "34293b12-1d94-43d9-a9cb-27b8bff92d67", - "practices": [ - ], + "practices": [], "prerequisites": [ "case-expressions", "ints", @@ -1698,8 +1663,7 @@ "slug": "minesweeper", "name": "Minesweeper", "uuid": "abbeeb8f-6ec1-4f57-86fc-2e18b3a62e29", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1713,8 +1677,7 @@ "slug": "say", "name": "Say", "uuid": "753fff04-5a64-4c3f-afd2-beee7e27efe8", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "case-expressions", @@ -1728,8 +1691,7 @@ "slug": "saddle-points", "name": "Saddle Points", "uuid": "e1103441-9391-4760-829b-1ec412762fab", - "practices": [ - ], + "practices": [], "prerequisites": [ "custom-types", "lists", @@ -1742,18 +1704,15 @@ "slug": "secret-handshake", "name": "Secret Handshake", "uuid": "22461f35-684d-4f75-9399-d07a4f483bdd", - "practices": [ - ], - "prerequisites": [ - ], + "practices": [], + "prerequisites": [], "difficulty": 2 }, { "slug": "matrix", "name": "Matrix", "uuid": "6fc59193-bc31-40af-902a-b13ad926bbb3", - "practices": [ - ], + "practices": [], "prerequisites": [ "lists", "strings", @@ -1766,8 +1725,7 @@ "slug": "grade-school", "name": "Grade School", "uuid": "836dddea-2a02-434f-a886-c8e1c429268f", - "practices": [ - ], + "practices": [], "prerequisites": [ "maps", "results", @@ -1783,8 +1741,7 @@ "slug": "variable-length-quantity", "name": "Variable Length Quantity", "uuid": "f7e33664-ea30-4885-8961-4aa984a1341d", - "practices": [ - ], + "practices": [], "prerequisites": [ "bit-strings", "case-expressions", @@ -1798,8 +1755,7 @@ "slug": "ocr-numbers", "name": "OCR Numbers", "uuid": "0ac6ba02-b2c0-4c81-8ca0-31c49a340e23", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "lists", @@ -1813,8 +1769,7 @@ "slug": "pig-latin", "name": "Pig Latin", "uuid": "dbc455de-1845-49f9-b5b5-082350e12811", - "practices": [ - ], + "practices": [], "prerequisites": [ "strings", "case-expressions", @@ -1826,8 +1781,7 @@ "slug": "nth-prime", "name": "Nth Prime", "uuid": "fda0001e-51b5-4041-a08a-2cb7dfef0f1c", - "practices": [ - ], + "practices": [], "prerequisites": [ "ints", "iterators", @@ -1852,6 +1806,19 @@ "case-expressions" ], "difficulty": 5 + }, + { + "slug": "pop-count", + "name": "Pop Count", + "uuid": "2af8d672-a825-4699-a77e-771d5d48a5d1", + "practices": [ + "ints" + ], + "prerequisites": [ + "basics", + "ints" + ], + "difficulty": 2 } ] }, diff --git a/exercises/practice/pop-count/.docs/instructions.md b/exercises/practice/pop-count/.docs/instructions.md new file mode 100644 index 000000000..b0c2df593 --- /dev/null +++ b/exercises/practice/pop-count/.docs/instructions.md @@ -0,0 +1,8 @@ +# Instructions + +Your task is to count the number of 1 bits in the binary representation of a number. + +## Restrictions + +Keep your hands off that bit-count functionality provided by your standard library! +Solve this one yourself using other basic tools instead. diff --git a/exercises/practice/pop-count/.docs/introduction.md b/exercises/practice/pop-count/.docs/introduction.md new file mode 100644 index 000000000..49eaffd8b --- /dev/null +++ b/exercises/practice/pop-count/.docs/introduction.md @@ -0,0 +1,47 @@ +# Introduction + +Your friend Eliud inherited a farm from her grandma Tigist. +Her granny was an inventor and had a tendency to build things in an overly complicated manner. +The chicken coop has a digital display showing an encoded number representing the positions of all eggs that could be picked up. + +Eliud is asking you to write a program that shows the actual number of eggs in the coop. + +The position information encoding is calculated as follows: + +1. Scan the potential egg-laying spots and mark down a `1` for an existing egg or a `0` for an empty spot. +2. Convert the number from binary to decimal. +3. Show the result on the display. + +Example 1: + +```text +Chicken Coop: + _ _ _ _ _ _ _ +|E| |E|E| | |E| + +Resulting Binary: + 1 0 1 1 0 0 1 + +Decimal number on the display: +89 + +Actual eggs in the coop: +4 +``` + +Example 2: + +```text +Chicken Coop: + _ _ _ _ _ _ _ _ +| | | |E| | | | | + +Resulting Binary: + 0 0 0 1 0 0 0 0 + +Decimal number on the display: +16 + +Actual eggs in the coop: +1 +``` diff --git a/exercises/practice/pop-count/.gitignore b/exercises/practice/pop-count/.gitignore new file mode 100644 index 000000000..170cca981 --- /dev/null +++ b/exercises/practice/pop-count/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +build +erl_crash.dump diff --git a/exercises/practice/pop-count/.meta/config.json b/exercises/practice/pop-count/.meta/config.json new file mode 100644 index 000000000..2ebdd1e92 --- /dev/null +++ b/exercises/practice/pop-count/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "BNAndras" + ], + "files": { + "solution": [ + "src/pop_count.gleam" + ], + "test": [ + "test/pop_count_test.gleam" + ], + "example": [ + ".meta/example.gleam" + ], + "invalidator": [ + "gleam.toml", + "manifest.toml" + ] + }, + "blurb": "Count the 1 bits in a number", + "source": "Christian Willner, Eric Willigers", + "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" +} diff --git a/exercises/practice/pop-count/.meta/example.gleam b/exercises/practice/pop-count/.meta/example.gleam new file mode 100644 index 000000000..e5c8f6eea --- /dev/null +++ b/exercises/practice/pop-count/.meta/example.gleam @@ -0,0 +1,19 @@ +import gleam/int +import gleam/result + +pub fn egg_count(number: Int) -> Int { + recurse(number, 0) +} + +fn recurse(number: Int, eggs: Int) -> Int { + case number { + 0 -> eggs + _ -> { + let new_number = result.unwrap(int.floor_divide(number, 2), 0) + case int.is_odd(number) { + True -> recurse(new_number, eggs + 1) + _ -> recurse(new_number, eggs) + } + } + } +} diff --git a/exercises/practice/pop-count/.meta/tests.toml b/exercises/practice/pop-count/.meta/tests.toml new file mode 100644 index 000000000..e11683c2e --- /dev/null +++ b/exercises/practice/pop-count/.meta/tests.toml @@ -0,0 +1,22 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[559e789d-07d1-4422-9004-3b699f83bca3] +description = "0 eggs" + +[97223282-f71e-490c-92f0-b3ec9e275aba] +description = "1 egg" + +[1f8fd18f-26e9-4144-9a0e-57cdfc4f4ff5] +description = "4 eggs" + +[0c18be92-a498-4ef2-bcbb-28ac4b06cb81] +description = "13 eggs" diff --git a/exercises/practice/pop-count/gleam.toml b/exercises/practice/pop-count/gleam.toml new file mode 100644 index 000000000..55487aefb --- /dev/null +++ b/exercises/practice/pop-count/gleam.toml @@ -0,0 +1,11 @@ +name = "pop_count" +version = "0.1.0" + +[dependencies] +gleam_bitwise = "~> 1.2" +gleam_otp = "~> 0.7" +gleam_stdlib = "~> 0.30" +simplifile = "~> 0.1" + +[dev-dependencies] +exercism_test_runner = "~> 1.4" diff --git a/exercises/practice/pop-count/gleam.toml-e b/exercises/practice/pop-count/gleam.toml-e new file mode 100644 index 000000000..a740fe17d --- /dev/null +++ b/exercises/practice/pop-count/gleam.toml-e @@ -0,0 +1,11 @@ +name = "packages" +version = "0.1.0" + +[dependencies] +gleam_bitwise = "~> 1.2" +gleam_otp = "~> 0.7" +gleam_stdlib = "~> 0.30" +simplifile = "~> 0.1" + +[dev-dependencies] +exercism_test_runner = "~> 1.4" diff --git a/exercises/practice/pop-count/manifest.toml b/exercises/practice/pop-count/manifest.toml new file mode 100644 index 000000000..a8cdf8b1d --- /dev/null +++ b/exercises/practice/pop-count/manifest.toml @@ -0,0 +1,25 @@ +# This file was generated by Gleam +# You typically do not need to edit this file + +packages = [ + { name = "exercism_test_runner", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "glance", "gleam_json", "gleam_community_ansi", "gleam_stdlib", "simplifile", "gap"], otp_app = "exercism_test_runner", source = "hex", outer_checksum = "336FBF790841C2DC25EB77B35E76A09EFDB9771D7D813E0FDBC71A50CB79711D" }, + { name = "gap", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_stdlib"], otp_app = "gap", source = "hex", outer_checksum = "AF290C27B3FAE5FE64E1B7E9C70A9E29AA0F42429C0592D375770C1C51B79D36" }, + { name = "glance", version = "0.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "B646A08970990D9D7A103443C5CD46F9D4297BF05F188767777FCC14ADF395EA" }, + { name = "gleam_bitwise", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "E2A46EE42E5E9110DAD67E0F71E7358CBE54D5EC22C526DD48CBBA3223025792" }, + { name = "gleam_community_ansi", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_bitwise", "gleam_community_colour"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "6E4E0CF2B207C1A7FCD3C21AA43514D67BC7004F21F82045CDCCE6C727A14862" }, + { name = "gleam_community_colour", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_bitwise"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "D27CE357ECB343929A8CEC3FBA0B499943A47F0EE1F589EE16AFC2DC21C61E5B" }, + { name = "gleam_erlang", version = "0.22.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "367D8B41A7A86809928ED1E7E55BFD0D46D7C4CF473440190F324AFA347109B4" }, + { name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" }, + { name = "gleam_otp", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "ED7381E90636E18F5697FD7956EECCA635A3B65538DC2BE2D91A38E61DCE8903" }, + { name = "gleam_stdlib", version = "0.31.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6D1BC5B4D4179B9FEE866B1E69FE180AC2CE485AD90047C0B32B2CA984052736" }, + { name = "glexer", version = "0.6.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "703D2347F5180B2BCEA4D258549B0D91DACD0905010892BAC46D04D913B84D1F" }, + { name = "simplifile", version = "0.1.14", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "10EA0207796F20488A3A166C50A189C9385333F3C9FAC187729DE7B9CE4ADDBC" }, + { name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" }, +] + +[requirements] +exercism_test_runner = { version = "~> 1.4" } +gleam_bitwise = { version = "~> 1.2" } +gleam_otp = { version = "~> 0.7" } +gleam_stdlib = { version = "~> 0.30" } +simplifile = { version = "~> 0.1" } diff --git a/exercises/practice/pop-count/src/pop_count.gleam b/exercises/practice/pop-count/src/pop_count.gleam new file mode 100644 index 000000000..ddf0fc0c6 --- /dev/null +++ b/exercises/practice/pop-count/src/pop_count.gleam @@ -0,0 +1,3 @@ +pub fn egg_count(number: Int) -> Int { + todo +} diff --git a/exercises/practice/pop-count/test/pop_count_test.gleam b/exercises/practice/pop-count/test/pop_count_test.gleam new file mode 100644 index 000000000..d50e7de3f --- /dev/null +++ b/exercises/practice/pop-count/test/pop_count_test.gleam @@ -0,0 +1,27 @@ +import exercism/test_runner +import exercism/should +import pop_count + +pub fn main() { + test_runner.main() +} + +pub fn zero_eggs_test() { + pop_count.egg_count(0) + |> should.equal(0) +} + +pub fn one_egg_test() { + pop_count.egg_count(16) + |> should.equal(1) +} + +pub fn four_eggs_test() { + pop_count.egg_count(89) + |> should.equal(4) +} + +pub fn thirteen_eggs_test() { + pop_count.egg_count(2_000_000_000) + |> should.equal(13) +}