Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Concept Exercise Squeaky Clean #611

Merged
merged 5 commits into from
Oct 15, 2023
Merged

Adds Concept Exercise Squeaky Clean #611

merged 5 commits into from
Oct 15, 2023

Conversation

pwadsworth
Copy link
Contributor

Concept Exercise Squeaky Clean for Strings concept.

Answers #606.

Concepts

  • Char: know of the existence of the char type; know that a char represents; know how to define a char; know how to access a char in a string; know of some basic char methods (like converting to uppercase).
  • String: know how to use a strings.

Prerequisites

  • Booleans
  • Maybe
  • Lists

@pwadsworth

This comment was marked as outdated.

@jiegillet
Copy link
Contributor

Don't know why the test runner is failing:

I suspect that it's because your test file is not structured the way it's supposed to be, and the code extractor in the test runner fails on that. It's poorly/not al all documented, but try and copy the structure of another concept exercise test file.

@ceddlyburge
Copy link
Contributor

ceddlyburge commented Oct 5, 2023

Don't know why the test runner is failing:

The tests are flaky for some reason we haven't figured out yet (there is an open isue for it), I tried running them again, but they are still failing, and on these new tests specifically.

I'll take a look at the tests when I have time, but I think Jie is right, there is probably some requirement in the test runner that isn't met.

@jiegillet
Copy link
Contributor

I ran the exercise with the test-runner locally and the error message is "Number of tests doesn't match number of extracted code snippets"
So it's 100% because of the structure of the test file.

Copy link
Contributor

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the nice exercise, I hope that 2 reviews are not too much at once :D

Only for reference, here is my solution, I wrote after only looking at the instructions.

module SqueakyClean exposing (clean1, clean2, clean3, clean4, clean5)


clean1 : String -> String
clean1 =
    String.replace " " "_"


clean2 : String -> String
clean2 str =
    List.foldl (\ctrl -> String.replace ctrl "[CTRL]") (clean1 str) [ "\n", "\u{000D}", "\t" ]


clean3 : String -> String
clean3 str =
    case String.split "-" (clean2 str) of
        [] ->
            ""

        first :: rest ->
            String.concat (first :: List.map capitalize rest)


capitalize : String -> String
capitalize str =
    case String.uncons str of
        Nothing ->
            str

        Just ( first, rest ) ->
            String.fromChar (Char.toUpper first) ++ rest


clean4 : String -> String
clean4 =
    clean3 >> String.filter (Char.isDigit >> not)


clean5 : String -> String
clean5 =
    let
        notGreek c =
            Char.toCode c < Char.toCode 'α' || Char.toCode 'ω' < Char.toCode c

        notEmoticon c =
            Char.toCode c < 128512 || 128591 < Char.toCode c
    in
    clean4 >> String.filter notGreek >> String.filter notEmoticon

exercises/concept/squeaky-clean/.docs/hints.md Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/.meta/design.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, it's taking shape :)
I left a few more comments

exercises/concept/squeaky-clean/.meta/Exemplar.elm Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/src/SqueakyClean.elm Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/tests/Tests.elm Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/tests/Tests.elm Outdated Show resolved Hide resolved
@ceddlyburge
Copy link
Contributor

Hi Pete, I'm on holiday at the moment, but it looks like you and Joe have everything in hand, so I'll leave it to you two :)

@jiegillet
Copy link
Contributor

Another thing, could you add a introduction.md.tpl file right next to introduction.md? The contents should be

# Introduction

%{concept: strings}

This file is meant to work with configlet. When running bin/configlet generate, it copies over the intro file of the concept in the concept exercise folder, which is very convenient for keeping those files in sync.

@pwadsworth
Copy link
Contributor Author

Incorporated all comments. Thanks for the feedback.

Copy link
Contributor

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more tiny little things! After that I'm merging :D

exercises/concept/squeaky-clean/.docs/hints.md Outdated Show resolved Hide resolved
exercises/concept/squeaky-clean/.docs/introduction.md.tpl Outdated Show resolved Hide resolved
Copy link
Contributor

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!
Thank you so much for making this, I know how much work making concepts and concepts exercisess is, it will mean a lot to the students.

@jiegillet jiegillet merged commit b51d6e8 into exercism:main Oct 15, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants