6 kyu

Tic-Tac-Toe

332 of 333timmontague
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • mrHoft Avatar

    Description must contain a rule about a boards where any move will be fail. Wasted so many attempts to know that function must return any free point (not -1, null, false or undefined).

  • laurelis24 Avatar

    I must return index of the move right 0-8 || -1? Then why it shows some kind of error...

  • dem4ron Avatar

    fun kata. I just don't understand why it is 6kyu and the other - simple result-checker kata - is 5 kyu. I think this kata looks a step further. It is fine for a 6kyu just I find the other one simpler. nvm

  • dandgerson Avatar

    Hi!

    Written tests allows to push partial kata solution

    just look at my terrible solutions, wich passed the tests.

    suggest add this case:

    b = ['O', 'X', 'X', '', '', 'X', 'X', 'O', 'O'];
    Test.expect(solveTTT(b.slice()) == 4, "Error with board: " + b + " - Got: " + solveTTT(b.slice()));
    
  • docgunthrop Avatar

    There's a problem with the random tests. In almost all cases, there will be at least one test with no solution. A couple examples I've encountered below:

    // Example 1:
    ['X','O','O',
      '','X','O',
     'O','X','X']
     
    // Example 2:
    [ '','O','O',
     'O','O','O',
      '','O', '']
    
  • Voile Avatar

    Approved

  • matt c Avatar

    Needs random tests and example tests but good kata :)

  • vferries Avatar

    Ok, I didn't understand that we only have to return a valid move. I used to return all winning or possible moves.

  • constablebrew Avatar

    I would like to see someone solve this using a brute force recursive function.

  • timmontague Avatar

    Thanks, fixed that too. Also another bug I had.

  • user527539 Avatar

    Now my solution fails on your last case :p ['X', 'O', '', 'O', 'X', '', 'X', 'O', ''] i.e.

    XO.
    OX.
    XO.
    

    for which you accept 2, 7 but I think you meant 2, 8.

  • timmontague Avatar

    You are correct, I missed that one!

  • user527539 Avatar

    I don't understand why 8 isn't a valid answer for ['', 'X', 'O', 'O', '', 'O', 'X', 'X', ''] isn't that

    .XO
    O.O
    XX.
    

    which has both 4 and 8 as winning positions?