Ad
  • Custom User Avatar

    I updated the description of the kata, trying to clarify the process of coloring the canvas. I also added some examples with the solution implemented in ruby or python.

  • Custom User Avatar

    No!

    You can only use the colours in the board: purple (p), yellow (y) and blue (b). Each tile needs to be cross by two strands and it is coloured with the colour of the "upper" strand. This means that "last" strand, the second strand that cover a tile, gives the colour to the tile.

    The solution you propose:

    {:type=>"r", :index=>0, :color=>"p"}
    {:type=>"r", :index=>1, :color=>"b"}
    {:type=>"c", :index=>0, :color=>"p"}
    {:type=>"c", :index=>1, :color=>"y"}
    

    Is not correct because it draws the following canvas:

    [["p", "y"],
     ["p", "y"]]
    

    Remember that order matters, so is the last strand that give the colour to the tile. You need to think on the order of the rows and the columns to give the correct colour to each tile.

    For example, this solution:

    {:type=>"r", :index=>0, :color=>"p"}
    {:type=>"c", :index=>0, :color=>"b"}
    {:type=>"r", :index=>1, :color=>"p"}
    {:type=>"c", :index=>1, :color=>"y"}
    

    Generates the following board:

    [["b", "y"],
     ["p", "y"]]
    

    Do you see how we painted with different colours the first column?

  • Custom User Avatar

    take a look on your order:

     1. row 0 to purple
     2. row 1 to blue
     3. col 0 to purple --> so (0,0) is colored to purple (correct)
     4. col 1 to yellow --> so (0,1) is colored to yellow (correct) & so (1,1) is colored to yellow and must be blue (wrong)
    

    so this solution is incorrect

  • Custom User Avatar

    Ok. May be the kata is not right explained. Let me try another shot:

    Each cell neds to be filled with two strands. But it is colored with the color of the last strand. So, while the last item of the list is {:type=>"c", :index=>"1", :color=>"b"} the element {:type=>"r", :index=>1, :color=>"b"} can has any color.

  • Custom User Avatar

    No it is not a valid one. I changed it with a valid one.

  • Custom User Avatar

    The "Examples Test Case" needs to be improved.

  • Custom User Avatar

    I would like to have some default tests on the kata. Here you have some it you want to include them:

    data1 = {
      :id => 1, 
      :items => [
    	  {:id => 2}, 
    	  {:id => 3}
      ]
    }
    
    data2 = {
      :id => 1,
      :items => [
    	{:id => 2},
    	{:id => 3, :items => [
    	  {:id => 4},
    	  {:id => 5}
    	]}
      ]
    }
    
    data3 = {
    	:id => 1,
    	:items => [{
    		:id => 2,
    		:items => [{
    			  :id => 3,
    			  :items => [
    				{:id => 4},
    				{:id => 5}
    			  ]
    			},{
    			  :id => 6,
    			  :items => [{:id => 7}]
    			}]
    	  }]
    }
    
    Test.assert_equals(extract_ids({}), [])
    Test.assert_equals(extract_ids(data1), [1,2,3])
    Test.assert_equals(extract_ids(data2), [1,2,3,4,5])
    Test.assert_equals(extract_ids(data3), [1,2,3,4,5,6,7])
    
  • Custom User Avatar

    I capitalized the content of names, the city and the state and for hence I failed one test. May be some more description can make the kata more enjoyable.​