Ad
  • Custom User Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

    Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)

    describe "<This message should describe the categories of test groups inside this block>" do
      it "<A short message describing this test group>" do
        expect(...).to eq(...) #Assertions
        #Or Test.assert_equals(user_response, reference_response)
      end
    end
    
  • Custom User Avatar
  • Custom User Avatar

    If there isn't one already, why not add a test case to see whether or not a solution correctly returns a new array, per the instructions? A few of the Java solutions I saw were destructive.

  • Custom User Avatar

    haskell still lacking its random tests

  • Custom User Avatar

    Add random tests:

    import Test.QuickCheck
    import Test.Hspec
    
    main :: IO ()
    main = hspec $ do
      describe "merge" $
        it "should merge basic examples" $ do
          merge [2,2,0,0] `shouldBe` [4,0,0,0]
          
        it "should also shift" $ do
          -- ...  
        
        it "should only merge once per cell" $ do
          -- ...
        
        it "should work for other list sizes" $ do
          -- ...
        
        it "should work for random lists" $ property $ \xs ->
          merge xs `shouldBe` solution xs
          
        it "should work for random (mergeable) lists" $ property $ 
          forAll (listOf1 $ elements [1,2,4,8]) \xs ->
            merge xs `shouldBe` solution xs
      
      where 
        solution = -- your solution here.