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

reverse-string: string with newline #2073

Open
glennj opened this issue Jul 10, 2022 · 6 comments
Open

reverse-string: string with newline #2073

glennj opened this issue Jul 10, 2022 · 6 comments

Comments

@glennj
Copy link
Contributor

glennj commented Jul 10, 2022

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"
    }
@SleeplessByte
Copy link
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?

@IsaacG
Copy link
Member

IsaacG commented Jul 10, 2022

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.

@andrerfcsantos
Copy link
Member

andrerfcsantos commented Jul 10, 2022

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”

@BethanyG
Copy link
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?

@junedev
Copy link
Member

junedev commented Jul 12, 2022

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.

@glennj
Copy link
Contributor Author

glennj commented Jul 12, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants