Skip to content

Commit ae9102f

Browse files
Merge branch 'exercism:main' into add-exercise-rational-numbers
2 parents f197d93 + 46b419b commit ae9102f

File tree

144 files changed

+1163
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1163
-442
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: erlef/setup-beam@e3f6ffe2878180f57318bf13febd3933ee81f664
1818
with:
1919
otp-version: "25.2"
20-
gleam-version: "0.26.0"
20+
gleam-version: "0.27.0"
2121

2222
- name: Run tests for all exercises
2323
run: bin/test

config.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,24 @@
11961196
],
11971197
"difficulty": 4
11981198
},
1199+
{
1200+
"slug": "luhn",
1201+
"name": "Luhn",
1202+
"uuid": "a66bbefd-db5a-44d0-ab4b-73d871756f08",
1203+
"practices": [
1204+
"string",
1205+
"list"
1206+
],
1207+
"prerequisites": [
1208+
"string",
1209+
"list",
1210+
"case",
1211+
"bool",
1212+
"int",
1213+
"result"
1214+
],
1215+
"difficulty": 5
1216+
},
11991217
{
12001218
"slug": "wordy",
12011219
"name": "Wordy",
@@ -1301,6 +1319,23 @@
13011319
],
13021320
"difficulty": 2
13031321
},
1322+
{
1323+
"slug": "grade-school",
1324+
"name": "Grade School",
1325+
"uuid": "836dddea-2a02-434f-a886-c8e1c429268f",
1326+
"practices": [
1327+
"map",
1328+
"result"
1329+
],
1330+
"prerequisites": [
1331+
"map",
1332+
"result",
1333+
"string",
1334+
"int",
1335+
"list"
1336+
],
1337+
"difficulty": 3
1338+
},
13041339
{
13051340
"slug": "pig-latin",
13061341
"name": "Pig Latin",

exercise_generator/manifest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "gleam_erlang", version = "0.18.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "14ABC93A7975369CCDDC0C4D9A34C0E0FE99CA3AD336BE6A17299EC0285B7107" },
6-
{ name = "gleam_json", version = "0.5.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "E42443C98AA66E30143C24818F2CEA801491C10CE6B1A5EDDF3FC4ABDC7601CB" },
7-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
5+
{ name = "gleam_erlang", version = "0.18.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "C69F59D086AD50B80DE294FB0963550630971C9DC04E92B1F7AEEDD2C0BE226C" },
6+
{ name = "gleam_json", version = "0.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9A805C1E60FB9CD73AF3034EB464268A6B522D937FCD2DF92BD246F2F4B37930" },
7+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
88
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
99
]
1010

exercise_generator/src/exercise_generator.gleam

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn have_same_type(a: JsonData, b: JsonData) -> Bool {
126126
// Main
127127

128128
pub fn main() {
129-
assert [slug, canonical_data] = erlang.start_arguments()
129+
let assert [slug, canonical_data] = erlang.start_arguments()
130130

131131
case json.decode(from: canonical_data, using: canonical_data_decoder()) {
132132
Ok(data) -> {
@@ -226,15 +226,15 @@ fn write_solution_files(
226226
["..", "exercises", "practice", slug, "src", exercise <> ".gleam"],
227227
"/",
228228
)
229-
assert Ok(Nil) = file.write(content, solution_path)
229+
let assert Ok(Nil) = file.write(content, solution_path)
230230

231231
let example_path =
232232
string.join(
233233
["..", "exercises", "practice", slug, ".meta", "example.gleam"],
234234
"/",
235235
)
236236

237-
assert Ok(Nil) = file.write(content, example_path)
237+
let assert Ok(Nil) = file.write(content, example_path)
238238
}
239239

240240
fn functions_to_implement(test_cases: List(TestCase)) -> Map(String, Function) {
@@ -322,7 +322,7 @@ fn write_test_file(slug: String, data: CanonicalData) {
322322
"/",
323323
)
324324

325-
assert Ok(Nil) = file.write(content, path)
325+
let assert Ok(Nil) = file.write(content, path)
326326
}
327327

328328
fn print_comments(comments: List(String)) -> String {
@@ -375,7 +375,7 @@ fn print_test(
375375
_ -> print_comments(comments)
376376
}
377377
let test_name = flatten_description(prefix <> description)
378-
assert Ok(Function(need_labels: need_labels, ..)) =
378+
let assert Ok(Function(need_labels: need_labels, ..)) =
379379
map.get(functions, function)
380380
let input =
381381
input

exercises/practice/accumulate/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
packages = [
55
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
6+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
77
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
88
]
99

exercises/practice/acronym/.meta/example.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import gleam/regex.{from_string, split}
33
import gleam/string.{capitalise, first}
44

55
pub fn abbreviate(phrase phrase: String) -> String {
6-
assert Ok(re) = from_string("[ +\\-/;_]+")
6+
let assert Ok(re) = from_string("[ +\\-/;_]+")
77
split(with: re, content: phrase)
88
|> fold(
99
"",
1010
fn(acc, val) {
11-
assert Ok(letter) =
11+
let assert Ok(letter) =
1212
val
1313
|> capitalise
1414
|> first

exercises/practice/acronym/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
packages = [
55
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
6+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
77
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
88
]
99

exercises/practice/affine-cipher/.meta/example.gleam

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gleam/result
12
import gleam/string
23
import gleam/list
34
import gleam/int
@@ -11,7 +12,7 @@ pub fn encode(
1112
a a: Int,
1213
b b: Int,
1314
) -> Result(String, Error) {
14-
try _ = modular_inverse(a, alphabet_length)
15+
use _ <- result.then(modular_inverse(a, alphabet_length))
1516

1617
plaintext
1718
|> translate(fn(index) { a * index + b })
@@ -27,7 +28,7 @@ pub fn decode(
2728
a a: Int,
2829
b b: Int,
2930
) -> Result(String, Error) {
30-
try mmi = modular_inverse(a, alphabet_length)
31+
use mmi <- result.then(modular_inverse(a, alphabet_length))
3132

3233
Ok(translate(ciphertext, fn(index) { mmi * { index - b } }))
3334
}
@@ -42,7 +43,7 @@ fn translate(input: String, op: fn(Int) -> Int) -> String {
4243
|> list.filter_map(fn(char) {
4344
case list.contains(letters, char) {
4445
True -> {
45-
assert Ok(shifted_index) =
46+
let assert Ok(shifted_index) =
4647
int.modulo(
4748
op(string.utf_codepoint_to_int(char) - letter_a_int_code_point),
4849
alphabet_length,

exercises/practice/affine-cipher/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
packages = [
55
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
6+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
77
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
88
]
99

exercises/practice/all-your-base/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
packages = [
55
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
6+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
77
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
88
]
99

exercises/practice/all-your-base/test/all_your_base_test.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ pub fn output_base_is_negative_test() {
125125
pub fn both_bases_are_negative_test() {
126126
let output =
127127
all_your_base.rebase(digits: [1], input_base: -2, output_base: -7)
128-
assert True =
128+
let assert True =
129129
output == Error(InvalidBase(-2)) || output == Error(InvalidBase(-7))
130130
}

exercises/practice/allergies/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
packages = [
55
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_stdlib", version = "0.26.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "B17BBE8A78F3909D93BCC6C24F531673A7E328A61F24222EB1E58D0A7552B1FE" },
6+
{ name = "gleam_stdlib", version = "0.27.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "9DBDD21B48C654182CDD8AA15ACF85E8E74A0438583C68BD7EF08BE89F999C6F" },
77
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
88
]
99

0 commit comments

Comments
 (0)