7 kyu
254 shades of grey
1,401 of 4,478jekt
Loading description...
Fundamentals
Strings
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.
great kata, thanks! learned something new :)
Ugliest code i ever written... xD
This comment has been hidden.
you have to generate shades even when n is larger than 254, it's just that you stop at 254
That doesn't seem to be the issue, as the error appears for n = 254:
for n = 254, at index 232, expected: "#e9e9e9" but got: ""
the index where it doesn't find any entry seems to change everytime I run it, attempting again, I getfor n = 254, at index 193, expected: "#c2c2c2" but got: ""
.i'm sorry, this is my fault; the assertion message was incorrect when
n > 254
, and the memory was not reset at every test, which caused confusing assertionsI fixed that and republished. Your code is still wrong though, for the reason I said.
Ok, I see, easy fix and I passed. Thanks.
C translation (author gone)
Thanks :)
My code no workey, fixey the code plz and thank <3
forked Python translation with random tests
Approved, now you can add tests to JS, since you're a contributor XDD
Sadly, that's not the case. I would need 10.000 honors to do that :(
No random test in Python and JavaScript
Fixed in latest fork and some time ago respectively
Ruby 3.0 should be enabled.
Done in latest fork
extremely nasty
Every single time I make a comment, I see what I did wrong like 5 seconds later :p
Pair programming with yourself? :P
This comment has been hidden.
The error was "arrays first differed at element [0]; expected:<#010101> but was:" i have no idea how to solve this .
I believe it should be a 6kyu kata...nice idea though. Kudos :)
Run in java and found error message " Submission timed out. Please try again." Is there anything to do with the import etc.?
OP solved it, closing
This isn't event written to compile in C#
This Kata (C#) has issues and shouldn't be part of anything until it has been polished. It doesn't even compile at first.
what he said
Compilation issues should be fixed now.
hi nope still getting this error:Expression denotes a
type', where a
variable',value' or
method group' was expectedeven though the unit tests pass i cannot compile
Fixed.
I ended up having to add a toLowerCase to my hex format string because the test cases are looking for lower case alpha on the hex strings.
The default test should use assertArrayEquals instead of assertEquals because assertEquals with arrays is deprecated.
Gotta say which language.
plain old Java
Actually assertEquals() should check if two arrays point to the same instance of an object, so it should not be the right thing to use here. Like Flash said assertArrayEquals() should be used, but I read in the documentation for Java Test framework here that String Arrays are not supported.
fixed + upgraded to JUnit 5
This comment has been hidden.
For the sorting colors, it's already fixed. For the output, please mention the language. I'm closing this for the lack of details. You're welcome to raise a new suggestion with more information
Everything is fine but it would be good to add error description for last test case scenario.
If this is for css, shouldn't '#111' be acceptable as well?
Probably a "mandatory legacy browser". ;)
3 digit color codes go back to 2001, though: http://www.w3.org/TR/2001/WD-css3-color-20010305. I guess I wouldn't be surprised to see individual browsers with poor support, though.
@JDPorter: My comment was actually a joke. I think that hex triplets probably even predate the first CSS standard. That being said, the kata test cases cannot get changed after 500 warriors have passed the tests.
The default solution code in C# is invalid code. It combines the class and method, which is obviously invalid. It should declare a public static class "Kata" with the method inside (and named in CapitalCamelCase according to C# conventions, and according to the test cases)
Default solution should be fixed now.
Fixed.
I think test cases lack explicit check for large negative number, for example -100. I really saw some solutions that used only -1 for empty result check.
This comment has been hidden.
Hi James: I just tried your code myself and it passes to me. What kind of error did you get?
Just translated it into Ruby :)
The Haskell test suite does not enforce the correctness for n > 254 case, so I accidentally submitted an incorrect solution and it got accepted.
C# Submit tests validated my first and second erroneous solutions.
Fixed.
As mentioned by another user, the default C# code is invalid.
Also, the description of what is being asked for seems unclear. Do you want just the first n shades? Or should the shades be distributed evenly across the spectrum?
Default C# code should be fixed now.
Fixed.
The default C# code is not even valid c#!
public static class shadesOfGrey(int n) {
}
it should be
public class Kata{ public static string[] ShadesOfGrey(int n){
} }
The C# translation doesn't make any sense. Nothing compiles and it does not give any valid indication of what the expected signature is.
I apologize. I made a mistake when I created the translation.
I've tried fixing it, I think it has to be approved again tho. I'm not sure, it's the first Kata I've translated.
Once it's approved, I don't think editing the translation has any effect. I've fixed the signature in the kata, so that should be fine now, at least.
Fixed.
Python translation ready.
There must be something wrong with the test cases. In Haskell, I'm getting:
Yeah, I'm a moron, who doesn't know the base of the hexadecimal system. I fixed the test cases. Please remove the issue if the problem has been solved.
Fixed. Don't worry, it happens to everyone... :-)
Somehow, I think it'd be funnier if the title was '254 shades of grey', but that's unimportant. Cool kata!
"
0xfe
shades of grey"?Ooh, nice one!
Haha, funnier indeed!
Small problem for me with this line :
I understood that when n is higher, just return an array of 254 element, with nothing in the array (so 254 null).
Maybe it's me ! but maybe you could just move this sentence farrer to the empty array instruction.
Can be confusing yeas, I fixed
You could explicitly state that lowercase letters should be used. Other than that, nicely done!
Thanks, you're right, only lowercase letters
You should precise :
"n"
> 254 ?Thank you for your feedback! I updated it