4 kyu
A simple Tic-tac-toe class
344 of 353Cito
Loading description...
Games
Puzzles
Object-oriented Programming
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.
Write code, write tests...why need this kata I dont get it, sorry...
Looks like you start to recognize the whole vanity of life...
the
Computer plays against itself
section makes no sense: the computer should win when the ascending diagonal is full. Currently, the tests expect[..., "Your move?"]
. If those tests are "correct" the computer could never win.I enjoyed this Kata very much, it's a pity that it's so old and therefore has no test cases.
This is pretty much the same as https://www.codewars.com/kata/a-simple-tic-tac-toe-class.
Maybe you meant https://www.codewars.com/kata/5216a87cbf53a9c30f0000dc (or something else)?
Opening an issue to complain that a kata is a duplicate of itself .. you must be losing it Voile.
Closing.
No random tests.
And before you cheated, this problem was non-existent.
Random tests are a means, not an end.
In five years, you were the only person who felt the need to earn a few cheap points.
Good on you.
The description is still a terrible mess, and the sample tests are absent.
This kata was approved without Sample tests, which were not a thing then, and with the current Desription, which you actually have to read ( see the first comments below ), but is complete.
Do you really want to change history so much?
I really suggest closing this issue. Let it be what it is.
Great idea, I wonder why nobody thinks like that except you?
Would you like to rerank all existing kata to current standards as well?
Standards evolve. Saying there were no quality standards 5 years ago is simply untrue - though they were different.
Please do the world a favour. Bring all existing kata up to your standards, descriptions, sample tests, submit tests with random tests. It's a bit more work than raising an issue, but it's the only way to be sure [ that all kata adhere to your standards, without having unsolvable issues on them ].
Even JavaScript and other languages used in Code Wars have evolved and now have features that were not available 5 years ago.
Also note that this is all work by volunteers. If anybody wants to create a new kata with a better description or tests, please go ahead. Or try to convince the author with positive criticism and friendly feedback. Personally I don't feel motivated to go back to what I posted years ago and put time and efford in changing it or adapting it to new standards, if all I get are snarky comments that "the description is a mess" and what is missing as feedback.
Also keep in mind that in a real developer's life problem descriptions are much less complete and exact, often misleading, often formulated by people coming from different domains who think very differently from you. I don't think katas should treat people with velvet gloves and make the path too smooth and straight forward, but give people something to think and experiment, that they can apply in real life as well.
Keep cool and don't make a drama out of everything. There will be always katas that you don't get or don't like but are fun and helpful for others. I like the diversity and have no problem with some mixed quality.
No sample tests.
When this kata was created, sample tests were not a thing.
You are entirely free to write your own.
5 years have passed, and the description is still nonsense about "player playing against the computer". The whole thing should be simplified and rewritten into 1-2 paragraphs at most clearly stating what the task is.
(1) Well, it ain't gonna get fixed then, is it?
(2) It's dense, but it's complete. Everything is there. Yes, player vs. computer is an option. Sometimes you really have to read the description.
.
Well, I'll give you this at least: when you finish this kata you really feel like you earned it. :D
Nice kata, but took more than one hour to complete, some unit tests would be handy!
This problem is frustrating and annoying because if the gotcha about a computer playing itself.
Parsing every single line of the description should not be necessary to start working away at a problem.
At least include the computer playing against itself in the example behavior.
I agree. And to add to it: I was having a lot of fun with this kata until I realized that this strange behavior was required. I, too, was a bit annoyed, and ended up just hacking it up to get it done. I wish it had been a little more clear from the begining what the goal was so I could have planned for it and produced better code.
Please add at least 1 sample test
I think this kata's discription is written in a way to intentionally decieve the user. Throughout the description, the author constantly refers to the player and the computer which gives the impression that once the computer has made its move, it waits for the player to input the next. This is untrue. If your solution makes it past the first 25 or so tests, the remaining tests are written to test the computer playing itself. This is an important criteron that is not mentioned at all and its omission can drastically change the programmer's approach to solve the challenge. There are a lot of comments on this kata which point out that there is no mention that a successful solution must include a way for the computer to play itself which leads me to believe that most people will fall into this "gotcha". Please update the description to spellout exactly what the solution requires.
Of course I did not try to intentionally decieve the user, and tried to make the description very clear. You might have read the description too quickly. If a solution requires re-examination of the problem, a change of your approach or way of thinking about the problem, and not everything is straightforward, then all the better, I think that's exactly the seasoning any good Kata (puzzle) needs.
Reading is a lost art ..
Sorry I could only upvote your comment once Cito.
This comment has been hidden.
You're right. I have added the two test cases now.
Nice solution, by the way.
I am confused with the draw state. In one test case [8, 'Draw!'] is expected in another [0, 'Draw!']. I thougt it is always [0, 'Draw!']. I dunno how to deal with it! Some hints?
The [8, Draw!] means that the computers places his mark on 8 and with that, the game ends in a draw. The [0, Draw!] means that all marks are set already, so the computer has no move any more, i.e. the game ended in a draw with the last move of the human.
Thx
Definitely enjoyed this one. Now I'll have to watch to see if anyone provides a solution with less code.
Nice solution!
Challenge accepted.
Very nice i think this was a nice kata. I also missed the switching side bit, but that probably was because i read the description to fast. Nice with the hint in the testcase that fails if this happens,
Excellent, detailed test cases. Thanks, Cito.
Nice kata! More a 5 kyu IMHO. I fell too into the "Computer changes side playing with itself" trap. Well, I actually started with a check that prohibited computer moves after the first one, returning "illegal move", then I saw that a computer vs. computer was asked to be accepted by the test fixture.
I feel it would be more coherent at this point if the solution accepts either computer vs. computer or computer vs. human matches: my solution, for instance, would erroneously accept a human move after two or more computer moves without batting an eye (
ttt.move(); ttt.move(); ttt.move(4) // -> [0,"Illegal move"]
).The above sequence can be interpreted as the computer suggesting an opening move for the human, or the human suggesting a third move for the computer. I have added another sentence to the description to make this feature of automatic side switching with each call of move() more explicit.
Nice work! I think there is a mistake in one of the examples:
ttt.move(4) // -> ["Game ended"]
while i guess it should say
ttt.move(4) // -> [0,"Game ended"]
Thanks. It's fixed already.
When "playing against itself", the computer changes sides (O and X) after every move (i.e. alternates between O and X instead of always playing O or X). The description says somewhere that move() shall change sides, so I think this is not a bug.
I missed that! Thanks!
fell in the same trap. i think the description could be clearer (but i eventually figured it out)
Ok, so I have added a hint about switching sides to that test method now.
I had this issue too, but it wasn't hard to account for.
This comment has been hidden.