4 kyu
Photoshop like - Magic Wand (select pixels by threshold)
Loading description...
Image Processing
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.
No information is given about the order of checking the pixels. Each person can assume a completely different search order and arrive and completely different answers because of this line: "summing the differences between... the pixel that was matched last with the new candidate pixel."
The order matters.
Test output is currently absolutely disgusting because at least it was better than the unintelligible mess that was the old one.
Raising this issue so that people can yell at me if I don't fix it eventually.
JS fork
This one sample test is not enough for users to figure out what to do. I'm passing the sample test, but fail on every random test. I find this recursive behavior explanation very fishy. It seems that depending on the order of recursion, other results can be provided. Or should we be able to reiterate existing pixels in case we can make new progress? This spec is very unclear to me.
That being said, I just passed the kata. My main point of dissatisfaction is the lack of sample and fixed tests.
If you can provide some descriptions of cases you would like tested then I can add them.
it should be told to the user that the x/y axis aren't those used usually for 2D arrays indexing (for now, there is only an hint about it far, far away from the top of the description...)
how do you mean, y is rows and x is columns, seems normal, no?
that convention should always be made crystal clear in descriptions. Some people use
x,y
notation forrow,col
, like indexing, but some others see that ashorizontal,vertical
, like in canvas coordinates.Coffeescript translation
Approved ;-)
There are problems/errors with your testcases - output of your testcode (your functions) is:
By the way for a kata which is a little bit more difficult (more than 7 or 6 kyu) it's really bad practice to publish it without example tests... So i had to build my own tests from your description. I don't know if everyone wants to do this or is able to do this... The output for your tests is not the best too, it's always better to show expected results and not only "not what expected". But ok, seems to me there are no random test too (and this is one reason to show no results), sorry but again "bad practice";-)... Probably it's one reason nobody solved this generally interesting (but not completely new) kata last time. So a little bit work for you - i think;-)!
I added an example test, I forgot to put one. Sorry about that. As for the rest of your comments, I am a little confused:
I am showing the failed result vs. the expected result in this format:


I do have random automated tests:
70 to be exact
Lastly, There was a "," missing in the color array. I added it back in. Should now work.
One last thing. I am new in this community. I officially joined a year ago, but wasn't active until about 2 weeks ago. I am trying to create nice puzzeles for people to solve. Your comment was a little too toxic for what it should have been. There's much I can learn about creating katas, and would love to get help. But please, don't scold users trying to contribute. Even if they make mistakes.
Thanks for your reply - i think you misunderstand, there's no intension to be toxic or something like that (if you think "...bad practice..." is a sign for toxic?). It was s description what happens to me solving your kata. And at the moment (perhaps i have to refresh some things again) i get the same error messages as yesterday. Perhaps this is the problem because i couldn't see any random tests, i always get some errors caused by functions of your tests. I tried it yesterday evening so perhaps my comment was a little bit "short" (is this toxic too?)... Generally my points are "normal points" if something isn't working - and there were some other points too, i haven't mentioned. So at the end it's your kata and if you don't need any comment, leave it as it is but don't wonder if you don't get solutions;-).
Again i get the same errors,
probably because i deleted all the unnecessary functions/vars at the beginning of your initial solution(better to put it into the preload part and not into the initial solution): Example output of my function and output of your testcases:Your basic tests work now, but not the part later on:
I preloaded drawRes() as per your suggestion. I re-ran the kata, and it seems to work perfectly for me. I cannot seem to reproduce the issue you are experiencing. I also get 70 automated tests, which you don't. Not sure what's the cause, but I definitely added random tests.
Often such errors occur if you are using internal vars inside your code which aren't used or defined by/for user (code). As you can see, your functions ("at getColorDistance, at findNextPixel, at magicWandR") throw these errors, not my. Another possibility is: i give you totally wrong results/outputs which your functions can't handle (wrong types or somethink like that)... But i don't think that my output is too bad (see my older example);-), maybe wrong content, but no reason to throw some "system errors";-)...
I re-ran everything. I made sure there are no vars that are needed.
Works for me like a charm.
In my solution there is nothing outside of :
And it passes for all 71 tests.
Perhaps you have an "old" cached version?
Are you sure your output is an array of objects such as:
[ {x:x1,y:y1}, {x:x2,y:y2}, ... {x:xn,y:yn} ]
Yes, same form of output (checked it via console.log and everything looks fine). So first of all thanks for your testing, i'm a little bit busy now, so i will check later once again... You can see my basic test result (i added your description- example, so two basic tests - i did a "reset" before):
Maybe a very simple bug;-)...
And here is the result for your first test ("Attempt button"), console.log for my solution before returning the result:
Can you paste your code? I want to see if I can reproduce this issue... Thanks for taking the time to help
This comment has been hidden.
@MichaelSel
: Can you plaese check my last comment (2 days old) - i only updated the text, so you probably got no new message... thanks;-)...Hi! Thank you so much for helping out!
You are right that (3,1)-(4,1) is above the threshold. BUT (3,0)-(4,1) is within the threshold! 154-134 + 138-51 + 136-118 = 20 + 87 + 18 = 125 :)
You also need to look at pixels diagonally
Or was your confusion about which two pixels to compare with the threshold? Are you always comparing the new pixel to the original pixel? If so, then no. It should be compared to the neighboring pixels. I'll make it clearer in the description. I really sorry about the confusion. And again, thank you for taking the time to help! Sorry about the confusion
I updated the description. I hope this is clearer:
This comment has been hidden.
Hi, yes for me it's clearer now (this was my confusion) - thanks;-)! So i submitted my working solution:-)! It's a good kata, well done, so thanks again for your work! I ranked it as 4kyu, probably a little bit high, but with all these tests and missunderstandings;-)... And it's a little bit harder than most similar katas of the last time... So not really too important and we will see the average voting later on.
I'm so happy we solve the major kinks! I agree with the ranking. It's definitely not 3kyu! But seems a little hard for 5.
I am trying to demystify image proccessing for myself by writing katas. So far, it's working nicely :)
Yes, saw your other kata "...count frames...", probably i will solve it next time too:-)... Image processing is really interesting, there are some other katas too (like https://www.codewars.com/kata/image-processing)... You can look in my "small published kata list", there are some "older graphic- katas" too, but only C# not Javascript;-)... So keep up your good work:-)!
I'll check some of yours out :)