6 kyu
first character that repeats
1,340 of 2,831jfridye
Loading description...
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.
This shouldn't be a 6 and should be regraded to a 7 imho, thanks for the kata tho!
my code works for the most part but I'm stuck with the error 'expected undefined to equal " " ' I don't actually get it. When I change it arounf instead I get 'expected " " to equal undefined'
Use Pythontutor to visualize what your code is doing. Your code fails the second sample test.
Way to easy for a 6KYU IMO
"the first character that repeats" and "the character that repeats first" mean exactly the same thing. You might want to revise the second definition to: "The first character that repeats consecutively"
No, that's not either what he meant. In
translator
you should returnt
, nota
.While second
a
appears before secondt
, in the string of all repeated letters, the first one ist
.Ahh, I see now. In that case, the description should've used a better example like yours. Btw, thanks for not resolving the
suggestion
immediately.Kata creator has being gone for a while, added another example to clarify.
That's great! I appreciate it.
There is a problem in the test, when doesn't match needed to return an 'undefined', but, in some test waiting an empty value ' ' instead of 'undefined'. This is weird. That is it?
That's because
' '
is indeed repeated (it's a space, not empty value)I understood and fixed, but now other exception occurred "expected undefined to equal 'a'". The conditional the treat a first value is ok. So, I think when the value exists will be return the itself and not undefined or ' '.
Python: Maybe adding some random tests? Solution can be hardcoded.
Lack of random tests has been report below (also it's an issue)
Python 3.6 should be enabled.
Already done
First sample test:
I don't know where you see that test, but it I see it like this:
Python
https://imgur.com/a/lX7b5C9
just reset the trainer
first python test should return e, not t, since two e-s are in a row...
Please read.
the word that was given in the test was TWEET. According to the exercise, I'd say that E repeats earlier than T... correct me if I'm wrong..........
You're doing what it tells not to do, you have to do it like this:
The wording is not the best, but the example is there so you can get it.
No random tests for Python.
added
Javascript needs random test. Don't know about other language.
This comment has been hidden.
Although it doesn't seem to be a problem, you should specify if the test should be case sensitive.
no random test cases
Haskell has them.
@cliffstamp JS has not
Test case is not compilable:
/tmp/haskell116115-17-1qudwmy/Codewars/Kata/FirstCharacter/Test.hs:11:32: No instance for (Show a0) arising from a use of
shouldBe' The type variable
a0' is ambiguous In a stmt of a 'do' block: firstDup []shouldBe
NothingRun Test give error but submitting the whole program pass it
Which language?
Needs random test cases
Haskell has them.
I did not know javascript doesn't maintain Object property order as in other languages :)
What is that even mean? Object's property by nature doesn't have any order. You access them directly with keys, not with index.
Ruby translation kumited
In JS, specifying that the return value if no character is found should be undefined is a little odd. Why not make it null?
Trivial, but the title of the kata should be capitalized.
The text of the kata says this: "Find the first character that repeats in a String and return that character." It goes on to clarify that "this is not the same as finding the character that repeats first." The difference between "the first character that repeats" and "the character that repeats first" is extremely subtle, so the clarification (with the "tweet" example) is helpful--perhaps that could be made more prominent?
Yeah, it should be changed somehow. Both descriptions are exactly the same. I've added a suggestion regarding this.
Supplied testsuite does not type check
I think it's worth pointing out, that most of our solutions wouldn't work for
(1:[2,2..])
as we go in an infinite loop with 1. I think you should either restrict the kata to finite lists or include infinite tests where the repeating character is not the first one. Thinking further there is just no way to terminate for[1..]
so then the kata should state that for infinite lists a repeating elem is guaranteed..in the initial test case here:
the
[]
doesn't type check force some type like([] :: [Int])
, in the last caseJust
is missing.Fixed.
"Run test" does not work
You first test case is wrong.
tweet --> first letter that repeats should be e, not t
Thanks for the feedback. The test case is correct, but the description of the problem could be more clear. Any suggestions would be appreciated.
't' is the first character that repeats, 'e' is the character the repeats first
.
The test is correct.
This comment has been hidden.
This comment has been hidden.
Thanks for the feedback! I agree and will make those changes.
Fine