Skip to content

Reverse String: Add emoji bonus to description #1503

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

Closed
wants to merge 2 commits into from

Conversation

ccouzens
Copy link
Contributor

@ccouzens ccouzens commented Apr 6, 2019

I've added an emoji bonus to the description of reverse string.
This introduces Unicode. Knowing that there are different ways to encode
text, and that not all characters are the same size is important.

I've made it a bonus because it's not straight forward in every
language.

I've added an emoji bonus to the description of reverse string.
This introduces Unicode. Knowing that there are different ways to encode
text, and that not all characters are the same size is important.

I've made it a bonus because it's not straight forward in every
language.
@ccouzens
Copy link
Contributor Author

ccouzens commented Apr 6, 2019

Maybe this would be better as a whole new exercise- Unicode Reverse String.

This way languages that don't make Unicode convenient can easily skip it.

Let me know your thoughts

@coriolinus
Copy link
Member

The Rust track already has two track-specific tests like this one:

https://github.com/exercism/rust/blob/42166418fc8370bf2a3d2a89774d5adda439e870/exercises/reverse-string/tests/reverse-string.rs#L49-L62

The first of these tests wide characters, and is part of the basic test suite. This is because in rust it is easy to reverse a string of characters regardless of width.

The second is feature-locked, because it involves reversing on a grapheme basis, which is more complicated. By default this test is excluded from the tests run; it only runs if you run the test suite with a particular flag. It's meant to give students who are interested some more insight into how unicode works.

@ccouzens
Copy link
Contributor Author

ccouzens commented Apr 7, 2019

I purposely didn't mention multiple characters making up a single grapheme and picked emojis where this wasn't a concern. Rust has a good 3rd party library for this, but I don't think that's true for a lot of languages.


I think there are 3 types of languages to consider:

  1. Languages like Rust where it's almost difficult not to correctly handle unicode characters.
  2. Languages like Java or Javascript where the initial solution likely doesn't handle unicode characters correctly, but can be made to work without too much effort.
  3. Languages like C where the standard library doesn't help with unicode. (forgive me if I've mis-characterized C)

I think the bonus text is helpful for students of # 1 and # 2. But I worry that students of # 3 might get frustrated trying to make it work.

For this reason, I'm beginning to think within the problem specifications it may be better to make Unicode reverse string into a separate exercise.

@coriolinus
Copy link
Member

I agree with your categorization of languages. I think that the right level of unicode depends on which type a language is.

For type 1 languages, I think that wide chars such as the emoji you used or the kanji Rust uses should be part of the basic test suite, and bonuses should introduce something new, such as multi-character graphemes. The language does a lot to make things easy, so let's show the students how easy it really is.

For type 2 languages, I agree with you: a bonus test with wide characters should be part of the normal suite, but reversing multi-character graphemes might be too much unless there exists a good external library, so it should be optional and track-specific.

For type 3 languages, a wide character test might be part of the bonus tests, but doesn't need to be part of the standard test suite.

In all these cases, the bonus exercise introduces a level of difficulty above and beyond the standard test suite. However, because the difficult bonus for type 3 languages is appropriately part of the standard test suite for type 1 languages, it is very difficult to add reasonable test cases in a track-independent way.

Possibly the best way to handle this is a detailed comment in the canonical data talking about the categorization of languages and giving some sample inputs and outputs both for wide characters and multi-char graphemes. That way each track could implement idiomatic tests according to its categorization.

Move the unicode bonus to the exercises instead of the description. This
will allow the exercises to automatically be brought into the various
tracks.

I was originally going to use 👍🏽 as the grapheme example. But as it is
split in my terminal (Gnome Terminal) and my editor (Visual Studio
Code), I presume it would be split for most students. Displaying it
split might make it confusing.
@ccouzens
Copy link
Contributor Author

ccouzens commented Apr 7, 2019

Possibly the best way to handle this is a detailed comment in the canonical data talking about the categorization of languages and giving some sample inputs and outputs both for wide characters and multi-char graphemes. That way each track could implement idiomatic tests according to its categorization.

@coriolinus, have I done what you had in mind in my latest commit?

Copy link
Member

@coriolinus coriolinus left a comment

Choose a reason for hiding this comment

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

Yes, that was exactly what I had in mind. This looks great!

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

Thanks for creating this PR, but I would like to hold off with merging this PR until we have resolved: #1492. That issues discusses how we should deal with cross-language concerns.

@NobbZ
Copy link
Member

NobbZ commented Apr 9, 2019

Hi @ccouzens!

I welcome your PR, but some years ago we agreed upon a "no unicode" rule, since unicode handling in some languages is below par.

But we also agreed upon that extra exercises might get created that do unicode.

Even as an optional exercise, unicode might be problematic, as unicode might confuse generators of languages that do not deal very well with unicode, which we also want to avoid.

@ErikSchierboom
Copy link
Member

Oh and as @NobbZ said, we do welcome PR's!

@SleeplessByte
Copy link
Member

Unicode exercises are on the list of soon to be added!

@cmccandless
Copy link
Contributor

I like the idea of separate exercises for handling unicode. That way, tracks that don't have good unicode support can mark the exercise as "foregone": true and move on instead of having to mess with custom generator handling.

@ErikSchierboom
Copy link
Member

I like the idea of separate exercises for handling unicode. That way, tracks that don't have good unicode support can mark the exercise as "foregone": true and move on instead of having to mess with custom generator handling.

Agreed! What do you think @ccouzens? Are you okay with waiting for/helping with a separate Unicode exercise?

@ccouzens
Copy link
Contributor Author

ccouzens commented Apr 9, 2019

Thanks everyone 🙂

What do you think @ccouzens? Are you okay with waiting for/helping with a separate Unicode exercise?

I like that idea. I hope to have time tomorrow to move these changes into a new unicode-reverse-string exercise. There would be other advantages beyond the technical ones, such as being able to use the Readme to give a brief overview of unicode.

@ErikSchierboom
Copy link
Member

I hope to have time tomorrow to move these changes into a new unicode-reverse-string exercise.

Could you perhaps open an issue first? We are trying to give all (new) exercises a background story, so a little discussion on the specific story first could help. For reference, see #1470.

@ccouzens
Copy link
Contributor Author

@ErikSchierboom

Could you perhaps open an issue first? We are trying to give all (new) exercises a background story, so a little discussion on the specific story first could help.

I've opened #1507. I don't think there was much scope for a story with reversing strings, so I've made the challenge about truncating them to 5 characters.

@ccouzens
Copy link
Contributor Author

I'm going to close this pull request, because it looks like I'll be creating a different exercise instead #1507

@ccouzens ccouzens closed this Apr 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants