codewars / content-issues

Higher level issue tracker for the Codewars content.
15 stars 1 forks source link

Idea: Deduplicate "evaluate math expression" katas. #10

Open hobovsky opened 6 years ago

hobovsky commented 6 years ago

DISCLAIMER

I realize that duplicated katas are general problem on CW, which should be addressed as a whole. But since there is no technical means for that and there is no agreement how to do it, I just want to propose the other way: let's do it slowly, gradually, a kata by kata. I want this thread to be related to this particular set of katas mentioned below, and not a general problem. If we find a good solution for one instance of the problem, maybe then we will know how to resolve other ones too.

While hunting for challenging blue/easy purple katas to solve, I encountered following:

  1. Calculate the expression (5 kyu)
  2. Calculator (3 kyu)
  3. My BEDMAS Approved Calculator (3 kyu)
  4. Evaluate mathematical expression (2 kyu)
  5. Parsing and evaluation of mathematical expressions (2 kyu)
  6. Advanced Calculator! (beta/2 kyu)
  7. (added) Route Calculator (4 kyu)

I solved four of them with almost the same code, just with minor adjustments and/or translating from one language to another (I skipped the yellow and the beta ones). Each of these katas has also its own set of issues, like:

Easy fix: leave two (easier and more difficult) as they are, and retire the others. My picks would go to (1.) and (5.) as their rank fits the difficulty better than in case of others. This way no one needs to edit anything, no one looses any points, only the authors of retired katas are less exposed and potentially lose opportunity of future solutions (not a big loss for the site, if you ask me). But still, we are left with not-that-perfect (albeit quite good, I'd say) katas and can use regular means of fixing them (fork/edit/republish/invalidate solutions/repeat).

More challenging fix: Retire all and send them into oblivion. Provide two new katas with two levels of difficulty: 5 kyu for BEDMAS and no error handling, and 3 (maybe 2?) kyu for additional error handling and functions (but not only unary ones, but also binary, ternary, and variadic, for example avg(32, 8+9, 15, (2+2)*2), maybe performance test, and all common issues addressed (external eval, error handling with exceptions/return values, random tests, etc). Clearly state in the description that they are deduplicates of other katas. Keep an eye on new betas and slap everyone who submits a duplicate (three slaps for anyone who approves it). If you consider it's too much work, I volunteer to create new katas and translations.

Potential follow up: obliterate (6.)

NOTE: I want this thread to become some kind of beta drive or template for "community driven deduplication process", where others can search for more duplicates, cast ideas for what should stay, what should be gone, and what/how should be fixed. @Voileexperiments already created really nice and terribly long list here: https://github.com/Codewars/codewars.com/issues/1315 and I think CW really needs some way to handle such problems. If community will like it, we can go with other duplicates similar way. Maybe we will even get a dedicated board for "kata related issues" :) If you do not like the idea or do not think there is any feasible solution for duplicates (for example, for some reason katas cannot be retired "just like that"), then ok - just close this thread and I promise not to create "my new, great, bright idea" suggestions anymore :)

FArekkusu commented 6 years ago

Leave 1 and 5, retire others

This is an interesting choice considering how only 2 and 4 are available in more than 1 language, and don't have a long list of issues (cough 5).

3 (maybe 2?) kyu for additional error handling and functions

There IS a kata which involves defining and interpreting functions. And it totatally does NOT deserve to be something as low as 3 kyu.

hobovsky commented 6 years ago

This is an interesting choice considering how only 2 and 4 are available in more than 1 language, and don't have a long list of issues (cough 5).

Honestly I completely ignored the available languages, because (unless it's only Haskell and nothing else), it's pretty much irrelevant for me. But yeah, it's quite a selfish approach, I can see it now ;) I picked (1.) because it's 5 kyu for basic evaluator functionality, and (5.) because it's the most advanced one. But anyway, I personally would vote for the option to retire all of these.

There IS a kata which involves defining and interpreting functions. And it totatally does NOT deserve to be something as low as 3 kyu.

If you mean Simple/Simpler Interactive Interpreter, then I do not mean to change these in any way and I consider them completely out of scope of this thread. What I think would be nice to have is 'just' an expression evaluator (like one of mentioned above katas), but without design issues, and not overranked. IMO ideal would be similar to (5.) with issues removed, support for functions other than unary (only calling , and not definig them, like for example 5^3+sqrt(3+3+min(8,NofK(6,4),3,21)) * avg(4,5,6,-11,1^0)), and downranked to 3 kyu. Problem with (5.) and functions right now is that it requires only unary functions, and these are not any different than unary operators. If solution for (4.) requires support for unary -, it makes the problem almost identical to requirement for sin or sqrt. That's why I think that 3-kyu kata needs a requirement some representative binary, ternary, or variadic function. You can propose some if you like.

Interactive Interpreter katas are IMO sufficiently different to not be considered duplicates of the katas listed in initial post.

FArekkusu commented 6 years ago

I picked (1.) because it's 5 kyu for basic evaluator functionality

IMO, 1 fully deserves to be retired as a calculator kata, for trying to be something it is not. Strip zeroes, remove spaces and call eval? This is not a calculator, this is a joke. And there're enough tasks which require you to filter a string from unwanted characters, so...

error256 commented 3 years ago

I haven't looked at how good/bad each of the katas is. In case their quality is about the same, it would be fare to keep the katas that were published earlier, especially if their authors are still active.

JohanWiltink commented 3 years ago

Losing 4 would be a crying shame, because of losing Coyote's JS solution.

That solution has been an inspiration for a lot of people ( including me ).

hobovsky commented 3 years ago

My proposal of improving this set of kata:

Kata Rank Current scope Proposed scope Proposed fix
Calculate the expression (5 kyu) DMAS DMAS Basically a duplicate with Route Calculator, but I propose to keep this one because it has more accurate rank.
Route Calculator has only 3 languages, so I would be able to add missing translations to this kata. I think this kata needs only strenghtening tests a bit (blocking eval) and adding two translations (Javascript and Typescript)
Route Calculator (4 kyu) DMAS Retire/lock/disable as an almost exact duplicate of Calculate the expression.
I think it's overranked, because DMAS does not justify a 4 kyu rank.
Transfer translations to Calculate the expression.
It could be fixed and used instead of Calculate the expression, but IMO it's not worth the effort: TS tests need to be fixed, and it's easier to get rid of it than to fix it.
Calculator (3 kyu) BEDMAS BEDMAS
Unary prefix operators (plus and minus)
Maybe unary postfix operators (factorial)?
It's somewhat overranked as a 3 kyu right now, because it's limited to BEDMAS. Adding unary prefix operators would make the requirements fit the current ranking a bit better.
My BEDMAS Approved Calculator (3 kyu) BEDMAS Remove as an exact duplicate of Calculator
It's C#-only, so not a big loss. It's a duplicate even currently, and Calcualtor was there first.
Evaluate mathematical expression (2 kyu) DMAS
Parentheses
Unary minus
No exponentiation (what means no right-assoc operators)
Full-fledged parser:
BEDMAS
Unary prefix and postfix operators
Function of one, two, and more arguments, incl. variadic ones
The most popular, but also the most lacking and the most overranked. I would prefer to keep this one instead of Parsing and evaluation of mathematical expressions because of its popularity, but it would mean quite a lot of work bringing it to desired difficulty level.
Variadic functions bring a nice twist into parser and evaluator, making the kata worth its rank.
I can fix it if no one else wants to help.
Parsing and evaluation of mathematical expressions (2 kyu) BEDMAS
Unary minus
Unary functions
Scientific notation
Remove.
It's the only one which has functions, but unfortunately all functions are unary, what does not bring any additional challenge because they basically work exactly the same way as an unary prefix operator. It's also C# only, and tests are ridden with issues.
Advanced Calculator! (beta/2 kyu) BEDMAS
No unary ops
One function of 3 args
It has a nice twist of additional syntax element, but I think it's not special enough, and it makes it somewhat overlapping with REPL kata and Evaluate mathematical expression.
It's a beta, so I'd just propose to unpublish it.

Some say that introducing functions into Evaluate mathematical expression would make it too similar to REPL kata Simpler Interactive Interpreter and Simple Interactive Interpreter, but I disagree. Interpreter kata have different scope, because they have requirement of defining a functions and variables at runtime, what makes these kata sufficiently different from evaluator kata. Set of functions called in Evaluate mathematical expression would be predetermined, fixed, and would require no additional state/memory, like user-defined functions and variables do.

I am not saying that kata which I propose to be removed have to be necessarily retired. Currently, retirement is the only possible way of removing a kata, but if you guys are really concerned with existing solutions, points, and availability (I am not, I do not care about old content or points as long as a new content is better), we can ask maintainers if it would be possible to somehow "lock" or "disable" kata without retiring them.

Blind4Basics commented 3 years ago

"proposed scope" is the current state of the kata? in eval math expression there are no functions (I actually don't get what are the 2 last columns, if the first isn't the current state)

hobovsky commented 3 years ago

I wanted to avoid too many columns, because they make view a bit cluttered, but I added the "current scope" column. Current scope is what's there now, Proposed scope is what I think would be good to have in corresponding kata, and Proposed fix is a kind of why/how to proceed with the kata.

Blind4Basics commented 3 years ago

oh... ok. x)

but note that doing so, you especially invalidate the solutions that are considered interesting... :/

hobovsky commented 3 years ago

but note that doing so, you especially invalidate the solutions that are considered interesting... :/

Yes I know, but I (personally) do not care, and I do not really get this argument:

Maybe instead of changing the kata some other approach would be better? Like keep all kata unchanged, make them not accept new solutions, and create replacement kata with fixes?

Blind4Basics commented 3 years ago

yeah maybe we should just nuke the solutions...

JohanWiltink commented 3 years ago

I would like anyone that updates tests, invalidating solutions in the process, to have the option to add such an invalidated solution to a hall of fame.

Sometimes, genius solutions will have to be invalidated because requirements change.

Voileexperiments commented 3 years ago

note that doing so, you especially invalidate the solutions that are considered interesting

Everything is interesting to some people, so this statement is kind of pointless. Meanwhile, CW is not responsible or liable to store and maintain all user solutions; If someone thinks a solution is interesting they should fork it or store it somewhere themselves.

On the other hand, for most upvoted solution it's well known that it's mostly random which solution gets an upvote bootstrap to snowball into the most upvoted solution, so it also isn't very interesting.

Blind4Basics commented 3 years ago

If someone thinks a solution is interesting they should fork it or store it somewhere themselves.

(those "interesting" solutions aren't interesting for those who already know about them, but for new solvers)

JohanWiltink commented 3 years ago

note that doing so, you especially invalidate the solutions that are considered interesting

.. CW is not responsible or liable to store and maintain all user solutions ..

Not all. But trying to showcase interesting ( in one of several ways ) solutions would be a good thing for CW. ( This might even include a Hall of Shame, for a certain kind of "interesting" solutions. )

Nuking solutions just because the kata they solve was bad would lose something for CW.