Skip to content

Commit

Permalink
update run-length-encoding (#144)
Browse files Browse the repository at this point in the history
[no important files changed]
  • Loading branch information
BNAndras authored Feb 4, 2024
1 parent 279c160 commit 7c2d743
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
65 changes: 37 additions & 28 deletions exercises/practice/run-length-encoding/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
[canonical-tests]
# 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.

# empty string
"ad53b61b-6ffc-422f-81a6-61f7df92a231" = true
[ad53b61b-6ffc-422f-81a6-61f7df92a231]
description = "run-length encode a string -> empty string"

# single characters only are encoded without count
"52012823-b7e6-4277-893c-5b96d42f82de" = true
[52012823-b7e6-4277-893c-5b96d42f82de]
description = "run-length encode a string -> single characters only are encoded without count"

# string with no single characters
"b7868492-7e3a-415f-8da3-d88f51f80409" = true
[b7868492-7e3a-415f-8da3-d88f51f80409]
description = "run-length encode a string -> string with no single characters"

# single characters mixed with repeated characters
"859b822b-6e9f-44d6-9c46-6091ee6ae358" = true
[859b822b-6e9f-44d6-9c46-6091ee6ae358]
description = "run-length encode a string -> single characters mixed with repeated characters"

# multiple whitespace mixed in string
"1b34de62-e152-47be-bc88-469746df63b3" = true
[1b34de62-e152-47be-bc88-469746df63b3]
description = "run-length encode a string -> multiple whitespace mixed in string"

# lowercase characters
"abf176e2-3fbd-40ad-bb2f-2dd6d4df721a" = true
[abf176e2-3fbd-40ad-bb2f-2dd6d4df721a]
description = "run-length encode a string -> lowercase characters"

# empty string
"7ec5c390-f03c-4acf-ac29-5f65861cdeb5" = true
[7ec5c390-f03c-4acf-ac29-5f65861cdeb5]
description = "run-length decode a string -> empty string"

# single characters only
"ad23f455-1ac2-4b0e-87d0-b85b10696098" = true
[ad23f455-1ac2-4b0e-87d0-b85b10696098]
description = "run-length decode a string -> single characters only"

# string with no single characters
"21e37583-5a20-4a0e-826c-3dee2c375f54" = true
[21e37583-5a20-4a0e-826c-3dee2c375f54]
description = "run-length decode a string -> string with no single characters"

# single characters with repeated characters
"1389ad09-c3a8-4813-9324-99363fba429c" = true
[1389ad09-c3a8-4813-9324-99363fba429c]
description = "run-length decode a string -> single characters with repeated characters"

# multiple whitespace mixed in string
"3f8e3c51-6aca-4670-b86c-a213bf4706b0" = true
[3f8e3c51-6aca-4670-b86c-a213bf4706b0]
description = "run-length decode a string -> multiple whitespace mixed in string"

# lowercase string
"29f721de-9aad-435f-ba37-7662df4fb551" = true

# encode followed by decode gives original string
"2a762efd-8695-4e04-b0d6-9736899fbc16" = true
[29f721de-9aad-435f-ba37-7662df4fb551]
description = "run-length decode a string -> lowercase string"

[2a762efd-8695-4e04-b0d6-9736899fbc16]
description = "encode and then decode -> encode followed by decode gives original string"
include = false
24 changes: 12 additions & 12 deletions exercises/practice/run-length-encoding/run-length-encoding-test.red
Original file line number Diff line number Diff line change
Expand Up @@ -9,95 +9,95 @@ test-init/limit %run-length-encoding.red 1
; test-init/limit %.meta/example.red 1 ; test example solution

canonical-cases: [#(
description: "empty string"
description: "run-length encode a string -> empty string"
input: #(
string: ""
)
expected: ""
function: "encode"
uuid: "ad53b61b-6ffc-422f-81a6-61f7df92a231"
) #(
description: "single characters only are encoded without count"
description: "run-length encode a string -> single characters only are encoded without count"
input: #(
string: "XYZ"
)
expected: "XYZ"
function: "encode"
uuid: "52012823-b7e6-4277-893c-5b96d42f82de"
) #(
description: "string with no single characters"
description: "run-length encode a string -> string with no single characters"
input: #(
string: "AABBBCCCC"
)
expected: "2A3B4C"
function: "encode"
uuid: "b7868492-7e3a-415f-8da3-d88f51f80409"
) #(
description: "single characters mixed with repeated characters"
description: "run-length encode a string -> single characters mixed with repeated characters"
input: #(
string: {WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB}
)
expected: "12WB12W3B24WB"
function: "encode"
uuid: "859b822b-6e9f-44d6-9c46-6091ee6ae358"
) #(
description: "multiple whitespace mixed in string"
description: "run-length encode a string -> multiple whitespace mixed in string"
input: #(
string: " hsqq qww "
)
expected: "2 hs2q q2w2 "
function: "encode"
uuid: "1b34de62-e152-47be-bc88-469746df63b3"
) #(
description: "lowercase characters"
description: "run-length encode a string -> lowercase characters"
input: #(
string: "aabbbcccc"
)
expected: "2a3b4c"
function: "encode"
uuid: "abf176e2-3fbd-40ad-bb2f-2dd6d4df721a"
) #(
description: "empty string"
description: "run-length decode a string -> empty string"
input: #(
string: ""
)
expected: ""
function: "decode"
uuid: "7ec5c390-f03c-4acf-ac29-5f65861cdeb5"
) #(
description: "single characters only"
description: "run-length decode a string -> single characters only"
input: #(
string: "XYZ"
)
expected: "XYZ"
function: "decode"
uuid: "ad23f455-1ac2-4b0e-87d0-b85b10696098"
) #(
description: "string with no single characters"
description: "run-length decode a string -> string with no single characters"
input: #(
string: "2A3B4C"
)
expected: "AABBBCCCC"
function: "decode"
uuid: "21e37583-5a20-4a0e-826c-3dee2c375f54"
) #(
description: "single characters with repeated characters"
description: "run-length decode a string -> single characters with repeated characters"
input: #(
string: "12WB12W3B24WB"
)
expected: {WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB}
function: "decode"
uuid: "1389ad09-c3a8-4813-9324-99363fba429c"
) #(
description: "multiple whitespace mixed in string"
description: "run-length decode a string -> multiple whitespace mixed in string"
input: #(
string: "2 hs2q q2w2 "
)
expected: " hsqq qww "
function: "decode"
uuid: "3f8e3c51-6aca-4670-b86c-a213bf4706b0"
) #(
description: "lowercase string"
description: "run-length decode a string -> lowercase string"
input: #(
string: "2a3b4c"
)
Expand Down

0 comments on commit 7c2d743

Please sign in to comment.