Skip to content

reverse-string: string with newline #2073

Open

Description

@glennj

This came up in the bash track: what to do with strings containing newlines?

A common solution in shell would be to pipe the input into rev which would treat the input as lines and not a single string.

Suggest a new case:

    {
      "description": "with a newline",
      "property": "reverse",
      "input": {
        "value": "Hello,\nWorld!"
      },
      "expected": "!dlroW\n,olleH"
    }

Activity

  1. SleeplessByte commented on Jul 10, 2022

    @SleeplessByte
    Member

    Whilst I like it, this would make the exercise harder in many languages. Even though we can now pick and choose our test cases, perhaps this would be better suited in a reverse-string-2 exercise where other harder concepts could also be tried?

  2. IsaacG commented on Jul 10, 2022

    @IsaacG
    Member

    Introducing a second exercise would mean two very, very similar exercises and may render one redundant. The problem specs do have a handful of exercises which are marked deprecated/redundant.

  3. andrerfcsantos commented on Jul 10, 2022

    @andrerfcsantos
    Member

    I also think this should be a new exercise.

    What I like about the current version of the exercise is that it is simple. As a mentor allows me to focus the mentoring discussions on the best way to reverse a string in the language I'm mentoring in without "noise".

    I don't see a new exercise with this as redundant, because the handling of new lines makes it a very different exercise for me. It stops being an exercise about possibly reversing a slice/list (I'm thinking mainly about Go and Python) and it becomes an exercise that should consider the string as having different parts, reversing some of them and organizing them back together. The function made in the first exercise can be useful for this new one, but it will only be a part of it and I like the idea of exercises building on each other.

    Like this DJ said, I also think this new exercise could be interesting to try new concepts like how to handle other special characters such as \t or how to properly handle multi-byte codepoints (just some ideas).

    Another "fun" special case is to consider strings that use the Left Double Quotation Mark “ and the Right Double Quotation Mark ”. Example:

    Original string: “hello”
    When reversed trivially: ”olleh“
    What you probably want: “olleh”

  4. BethanyG commented on Jul 11, 2022

    @BethanyG
    Member

    Chiming in to agree with @SleeplessByte and @andrerfcsantos here. Spacing/indenting in many text scenarios is considered special, so I don't know that having it in the simple reverse exercise makes conceptual sense.

    Since we've also discussed unicode reverse string in #1661 and long strings in #1983, perhaps we should talk about a reverse string "series"? Have the simple case, the case that handles various whitespace/spacing and quote characters, one that focuses on unicode reversal, and then one for performance?

  5. junedev commented on Jul 12, 2022

    @junedev
    Member

    My vote is also for keeping the existing exercise simple. Especially with the concept trees in V3 it is important to have exercises that can be unlocked early in the learning process.

  6. glennj commented on Jul 12, 2022

    @glennj
    ContributorAuthor

    Seems to be a clear consensus. Thanks for the opinions folks. I don't currently have the gumption to carry this forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions