6 kyu

Get Euchre Score

57 of 210Dana
Description
Loading description...
Games
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • Aleksandr_81 Avatar

    The rules of the game are absolutely unclear. Therefore, the conditions of the problem are also unclear.

  • saudiGuy Avatar

    Python: generates warning after completion.

    /workspace/default/tests.py:9: SyntaxWarning: "is" with a literal. Did you mean "=="? if called_trump is 1:

  • saudiGuy Avatar

    Python: Random tests are vulnerable to input modification

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • catchaser Avatar

    This comment has been hidden.

  • MobulaKuhlii Avatar

    JS version needs fixing, tests labeled "Random" are not working at all.

  • HerrWert Avatar

    My solution succeeds on every test until it gets to the random tests, where it fails with this error message:

    ReferenceError: teamOneTricks is not defined at testUpdateScore at /runner/frameworks/javascript/cw-2.js:179:21 at Promise._execute at Promise._resolveFromExecutor at new Promise at Object.describe at Object.handleError at ContextifyScript.Script.runInThisContext at Object.exports.runInThisContext

    • St3f4n Avatar

      Yes in JS the random testing requires a function teamOneTricks which the author defined in his solution.
      @Dana one way to avoid that is to move that function inside the kata function (updateScore).
      @HerrWert currently you can bypass this just by defining a function teamOneTricks and make it return true

    • HerrWert Avatar

      Thanks. But I have added the function, and now the random tests are expecting results that definitely don't match the instructions.

    • St3f4n Avatar

      Hm that did it for me, I'm not sure why its not working for you. Sorry for the late response I didnt get notified that you commented.

    • Dana Avatar

      Ah.. I didn't understand why anyone else would need to include that function. I'll fix the test cases so it won't be required.

      Dana

    • Dana Avatar

      Sorry about that. You shouldn't have a problem with the missing function anymore.

      Issue marked resolved by Dana 8 years ago
    • HerrWert Avatar

      Thanks, but that still doesn't solve the problem of the incorrect random tests. Here's just one example of many: The arguments are { '0': [ 9, 3 ], '1': 2, '2': false, '3': [ 1, 2, 1, 1, 2 ] }

      ...and the result I get is: ✘ Expected: [9, 3], instead got: [11, 3]

      Shouldn't it be [11, 3]? Team 2 caleld trump, but took only two tricks, so two points go to team 1, right? Or am I misunderstanding the instructions?

    • Dana Avatar

      Is it possible the expected and actual values are reversed? You are correct, the answer should be [11,3] and when I test, this is the answer I receive. I did notice, that even though the documentation says to pass the test cases as (actual, expected), they are printed the opposite for me when I force a failure.

    • HerrWert Avatar

      OK, so it sounds like it needs to be fixed in the test framework somehow. (I admit, on the only two katas I've written so far, I had a lot of trouble figuring out how to set up the testing and needed plenty of help -- especially for the random tests.)

      If you let me know when you get it figured out, I'll run my solution against it again.

    • Dana Avatar

      If your solution is correct, it shouldn't matter which order those parameters are passed. I can look into it further but you probably have a problem in your solution as well.

    • HerrWert Avatar

      Well, after 4 months, I've come back to this kata as a (hopefully) better programmer and solved it without too much trouble!

      I really admire how concisely you described the conditions for solving this real-world situation. These situations are sometimes hard to explain, and the descriptions can become very lengthy. (See my "Determine Results of Pole Vault Competition" kata; I just couldn't find a way to keep it shorter without omitting important information!) And I am the first one to skip a kata if the description is too long :-) So... nice job!

  • Dentzil Avatar

    Hallo Dana,

    i'm sorry to report, a bug hides in your random tests. (C#-solution)

    In your own solution you change the input array "currentScore". It's called "side effect" and can lead to the unexpected consequences. So as in your random tests.
    Look at your random tests, after the exectution of your own solution at the code line 153 the currentScore-array is changed and has the "wrong" value for the user function at the code line 154.

    My first solution was written with a new array returned and i could not pass the random tests because of this side effect.
    The bug was hard to find without seeing the test code. I have spent half an hour reading the article about Euchre in Wiki, because i thought the error was in my solution.

    After i have rewrote my solution with changing the input array, i can pass all tests.

    With changing the input array, after execution of the both functions, the expectedScore and the actualScore are the same array (actually currentScore) and the assertions at the code lines 155-156 compare the result array to itself.
    Therefore you and other who solved the kata could pass the tests successfully.

    You should either rewrite your own function so that it does not change the input array and notice this point in the desciption or pass the currentScore in the random tests as a new array: like this currentScore.ToArray() (System.Linq).

  • Joz Avatar

    It was fun, but i still don't know how to play ^^