6 kyu
Number Shortening Filter
436 of 986GiacomoSorbi
Loading description...
Angular
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Good kata. I think the description could be clearer about inputs, about how (in Python, at least) we're tested on strings and lists but nothing else.
Or maybe we could be tested on some other type, as an "otherwise" case.
EDIT: I guess that can be ignored, as seen in my most recent refactored solution, though it feels off.
Thanks autor for this kata. Learned a lot about currying and happy to guess one of the popular solution!
oke saar
☺️
python new test framework is required. updated in this fork
Approved
Giacomo, dinglemouse and docgunthrop make best katas!
Ruby 3.0 should be enabled.
Enabled in this fork
Python 3 should be enabled.
Done.
There is a wonderful testing suite for this Kata, I recommend it!
Thanks for your kind feed :)
Can anyone explain this kata to me. Thanks
You need to create a function that returns other functions, taking parameters to pre-set itself.
Aka "currying" (sorta of).
Hi, still didn't understand, I got this that i have to return a function, but what would that function do? can you please explain this line -
Given an initial array of values replace the Xth power of a given base
and this one -taking parameters to pre-set itself.
Thanks again !!!Let's try this: does working through the example test cases gives you a better insight than the one you might get trying to decypher my poor English?
Hey, I didn't say anything about your english, You speak good english,much better than me!!!
Problem is with me,
i am failing to understand this kata even though i tried with examples.
that's why i need your help,can you please explain me with one example -
filter1 = shortenNumber(['','k','m'],1000); // return a function which takes one argument,
filter1('234324') == '234k'; // How '234324' => '234k'
filter1('98234324') == '98m'; // How '98234324' => '98m'
filter1([1,2,3]) == '1,2,3'; // this one i got it, if function didn't get a string argument, function 'll return argument.toString()
thanks again !!!!
I know you didn't mention my English, but other than that I cannot thing of much more: basically you just need to do some currying to a filter function:
filter1
parses numbers as explained in the description, given the initial array and integer as initializing parameters.I saw this kata and thought: "What for an outstanding idea!" Then I saw the reason. It is from you! :-) Very good kata! Thanx.
And because I like it so much, I translated it to C#. :D
https://www.codewars.com/kumite/57937a6639f33a1bb7000166
Please check and approve! :-)
I also edited the description for the correct c#-Code-Examples. Is the shortcut "cs" correct for showing the cs-Code?
Oh, I barely remembered this one: I actually code it as a filter for Angular in a production environment; translation approved, thanks!
My shortcut "cs" is wrong. The cs-Examples are not visible. Do you know, what it must be? "csharp"? "c#"?
Ahhh, I found: "csharp" is the right shortcut.
Can you change this in the description?
I think you can do it yourself, now that you are a contributor: can't you? No problem otherwise, of course.
I suppose I could only as new kumite. Then you must approve again. In each way, you have to do something. ;-)
I tried last minute and I can't save it.
So can you please change "cs" into "csharp" after the 3 mark-characters?
Mh, what an unusual bug. Well, it should be fixed now; cheers!
Very good, my friend! Thanx!
Thanks for translation. In random tests, for input "58555333344846" it expects "2287317708KB". It might be an issue since the correct answer is "57182942719KB".
I think it was my mistake, I didn't manage to regenrate that problem and my solution passed all tests. Please check above values with your code, and if it returns the correct value, then ignore my comment.
This comment has been hidden.
Ahhhhh, sorry. Now I got it!!!
In the random tests there are free random bases from 50 up to 2000. And also the used range from the whole range of suffixes is always random.
Thats the explanation, why "58555333344846" could(!) lead to "2287317708KB".
So still no problem in the random tests. :-)
Thanks, everything right :)
Cool, thanks for both the feed and the extra checks :)
I think an input has a misspell in the unit tests (2100k instead of 2100).
Description:
filter2('2100') == '2KB';
TestCases:
Test.assertEquals(filter2('2100k'), '2100k');
Error:
Expected: 2100k, instead got: 2KB
No, it is on purpose: did you see what you should do if the input is not a number?
This comment has been hidden.
I agree with the other comments, great kata, I´ve learned a lot about Procs and blocks with it, and the tests are so extensive, hats off to you! Upvoted!
Thanks tigre, your feed is much appreciated :)
Great kata! I need more like this to learn about lambda and proc functions in Ruby.
I think it merits a 5 kyu though, it seems a step above other 6 kyus.
Not my place to rank my own katas, though I might agree; and glad you appreciated it :)
Nice kata, thanks @GiacomoSorbi!
My pleasure zebulan and thanks to you for both your feed and your time in considering it :)