Draft

Tug-o'-War

790 of 1,680edm2410
Description
Loading description...
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • WestwardLand968 Avatar

    Trivial comparison/sum of list values is not a novel idea.

  • WestwardLand968 Avatar

    "Predefined tests in a random order" is not good enough. Actual random tests need to be created.

  • Muhammad Olim Avatar

    Need to add more anchors:

    test.assert_equals(tug_o_war([[1,3,2,4,5], [5,4,3,2,1]]), "Team 1 wins!")

    Number of team members shouldn't be limited:

    test.assert_equals(tug_o_war([[1,2,3,4,5,6,7], [7,6,5,4,3,2,1]]), "It's a tie!")

    test.assert_equals(tug_o_war([[1,3,7], [8,3,1]]), "Team 2 wins!")

    I think it would be better if the cases above are also required in the instructions and tests.

  • ᛚᚨᚱᛊ ᚺᛖᚾᚱᛁᚲ Avatar

    No randomized testing.

  • lechevalier Avatar

    Lack of sample tests in Python

  • FArekkusu Avatar

    Sample tests covering the "if teams are equal compare their anchors" rule should be added to all languages.

  • FArekkusu Avatar

    No random tests in Python, Ruby, Java and C#.

  • ___i Avatar

    Kata approved :)

  • emgordon154 Avatar

    I think this kata's about ready to come out of beta, but a couple more sample tests would be nice

  • ethanh1223 Avatar

    Make it more clear what the ends of the rope mean in terms of array

  • dweldon Avatar

    It's important that the lengths of the test cases vary. Otherwise one could simply hard-code the anchor indexes.

  • donaldsebleung Avatar

    Needs random test cases

  • russh Avatar

    Nice kata, little but of !*&@$ but well definitely good

  • PantlessBandit Avatar

    This comment has been hidden.

  • jincheng_jcs Avatar

    May be we can improve a bit of fun by add more than one Anchor :)

  • PantlessBandit Avatar

    This comment has been hidden.

  • Inox117 Avatar

    I think you need to explain how teams are in the array Team 1 : Anchor + 4 members Team 2 : 4 members + Anchor

    I spent a lot of time searching why tests were failing :)

    But it's a nice Kata

  • Sr.Troe Avatar

    Need more tests

  • haferjir Avatar

    I enjoyed this kata, thank you very much.

  • dleinker Avatar

    Needs more tests

  • miguelvelezmj25 Avatar

    There should be more test cases related to the Anchor.

  • PistachioCake Avatar

    In the "more examples" area, the comments need to be switched. Other than that, it's amazing! I really like the originality!

  • bbl8520 Avatar

    Need more test cases.

  • rawman9x Avatar

    so cute

  • nick.strohl Avatar

    Kumited a ruby translation. My first translation on code wars, so let me know if it needs any work.

  • Gander7 Avatar

    This comment has been hidden.

  • ninjaJay Avatar

    This comment has been hidden.

  • kajcia Avatar

    The final tests should include a situation when the strenght is the same and the anchors are the same (what if the second 'anchor' in order is stronger in one team?)

  • broliux Avatar

    which member is anchor in which team should be explained in a clearer fashion. otherwise the kata is ok.

  • wtfua92 Avatar

    TypeError: Cannot read property 'length' of undefined at tug_o_war at testResult

    I get this kind of error, although my code works, when I test it on http://eloquentjavascript.net/code/

  • ludopradel Avatar

    More unit tests to explain Anchor system

  • radiocontrolled Avatar

    Can you please add more test cases because it's unclear in some instances why code fails when you run "Submit" (and it passes when you just try the tests provided). Thanks.

  • jbaker88 Avatar

    Anchor positions should be clearly described in the problem description

  • votiv Avatar

    I think that the explanation of 'anchor' is confusing.

  • awtotty Avatar

    The definition of anchor is unnecessarily confusing. Some clarification here would be quite helpful. Otherwise, it looks good.

  • Xzxldn Avatar

    what's the anchor ? I just can't understand...

    var r=teams.map(x=> x.reduce((a,b)=>{return a+b})).reduce((j,k)=>{return j-k});

    return r==0?"tie"r>0?"Team 1 wins!":"Team 2 wins!";

  • Royce37 Avatar

    In C#, I'd suggest making the provided test case initialize a jagged array instead of the [2,5] array because that's what the real test cases use.

  • kristaps Avatar

    Minor Issues (I still voted "Ready" however): Missing test cases

    I would add tests that suddenly change people per team to 6, but better logging is needed to inform the coder of such a change. This would simulate changes (as they happen in real life) and would encourage coders to think about maintainability.

    (just my thoughts ofc, rules say "5", so my thoughts can be disregarded)

  • freeman42x Avatar

    In the test the function takes a bidimensional array while in the implementation/solution it takes a jagged array.

  • acraileanu Avatar

    The test code provided does not work, using int[,] instead of int[][].

    The anchor decision should be placed more to the beggining of the description, rather than in examples.

  • ChristianECooper Avatar

    I've added Python translation! Enjoy. :)

  • alexung Avatar

    JS solution does not work.

  • xehpuk Avatar

    I've sent in a Java translation.

  • DragonReborn Avatar

    Unit test for C# is coded different than how the submission is coded. It uses int[,] in the unit test and int[][] in the submission.

  • Buttonsz Avatar

    The description test case for c# is incorrect as people have pointed out.

  • the5th Avatar

    test case needs to be tweaked to work

  • user8585471 Avatar

    The definition of anchor can be a little better (the farthest player from the center of the rope, obviously the last player in the list -> wrong) or maybe a representation could be provided, such as

    tug_o_war([[5,2,3,1,4],[4,3,2,1,5]]) -> 5,2,3,1,4 --> | <-- 4,3,2,1,5

    that way the anchor is clearly defined

  • Deantwo Avatar

    The C# Example Test Cases has an error in the array input.

    The Example Test Cases is:

    new int[,] { {5,0,3,2,1}, {1,6,8,2,9} }
    

    It should be like in the Description:

    new int[][] { new int[] {5,0,3,2,1}, new int {1,6,8,2,9} }
    
  • MagnusAlt Avatar

    Default test case needed slight modification to work

  • AlexIsHappy Avatar

    As it was mentioned, test case doesnt work properly. You have to pass correctly defined parameter to the function.

  • mabeale Avatar

    The default test case does not work for c#!

  • tslater2006 Avatar

    The default test case has this line:

    Assert.AreEqual("Team 1 wins!", Kata.tug_o_war(new int[2,5] { {1,2,3,4,6}, {5,4,3,2,1} } ));

    which is invalid. the line needs to be

    Assert.AreEqual("Team 1 wins!", Kata.tug_o_war(new int[2,5] { new int[]{1,2,3,4,6}, new int[]{5,4,3,2,1} } ));

    Marked as major because the tests fail to run due to this even if the users code is valid.

  • inoabrian Avatar

    The instructions could use a bit of work on specifying the anchor.

  • TehCupcakes Avatar

    I enjoyed this Kata and wanted to spread it more, so I made a kumite for a C# translation. Arrays are so much easier to manipulate in javascript, so I had to make some structural changes for it to work right, but the test cases should all be the same. :)

  • SEGEEK Avatar

    The acceptance test cases always have the same number of players, there should be some variety there as the problem does not explicitly state team size.

    People should be punished for making assumptions about the size of the team and that he team 2 anchor will be index 4 of the second array.

  • pmatos Avatar

    More tests needed.

  • SteveRuble Avatar

    This comment has been hidden.