Ad
  • Custom User Avatar

    Go preloaded tests are not quite right. It doesn't correctly pick up the set variables clues and expected. I assume because the examples run after all lines of the Describe are evaluated, so the way it's done it only runs with last clues and examples. Could we move setting these variables inside the It?

    var _ = Describe("Sky Scraper", func() {
      
      It("can solve 6x6 puzzle 1", func() {
        clues := []int{ 3, 2, 2, 3, 2, 1,
              1, 2, 3, 3, 2, 2,
              5, 1, 2, 2, 4, 3,
              3, 2, 1, 2, 2, 4}
              
        expected := [][]int{{ 2, 1, 4, 3, 5, 6 },
                { 1, 6, 3, 2, 4, 5 },
                { 4, 3, 6, 5, 1, 2 },
                { 6, 5, 2, 1, 3, 4 },
                { 5, 4, 1, 6, 2, 3 },
                { 3, 2, 5, 4, 6, 1 }}
    
          Expect(SolvePuzzle(clues)).To(Equal(expected))
      })
      
      It("can solve 6x6 puzzle 2", func() {
        clues := []int{ 0, 0, 0, 2, 2, 0, 0, 0, 0, 6, 3, 0, 0, 4, 0, 0, 0, 0, 4, 4, 0, 3, 0, 0}
        expected := [][]int{{ 5, 6, 1, 4, 3, 2 },  { 4, 1, 3, 2, 6, 5 }, { 2, 3, 6, 1, 5, 4 }, 
                { 6, 5, 4, 3, 2, 1 }, { 1, 2, 5, 6, 4, 3 }, { 3, 4, 2, 5, 1, 6 }}            
    
        Expect(SolvePuzzle(clues)).To(Equal(expected))
      })
      
       It("can solve 6x6 puzzle 3", func() {
         clues := []int{ 0, 3, 0, 5, 3, 4, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 2, 3, 3, 2, 0, 3, 1, 0}
         expected := [][]int{{ 5, 2, 6, 1, 4, 3 }, { 6, 4, 3, 2, 5, 1 }, { 3, 1, 5, 4, 6, 2 }, 
                { 2, 6, 1, 5, 3, 4 }, { 4, 3, 2, 6, 1, 5 }, { 1, 5, 4, 3, 2, 6 }}
    
         Expect(SolvePuzzle(clues)).To(Equal(expected))
       })
    })
    
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This has confusing instructions. I don't mind the chessboard story or what's there but what's missing. There should be some explanation that you expect the results in a rational representation. It shouldn't be a guesswork that the returned array represents a rational number. I did go, and []int is not a natural way to express rationals.

    ok admittedly I haven't read the instructions for other languages which have a hint. I rephrase the suggestion as mentioning this as a language independent requirement at the top.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Awesome. I found "and an unlucky bear that was hit going the other direction" extremely funny. :D

  • Custom User Avatar

    Operator precedences from highest to lowest are: *, sequencing and |.

    So it should be (a(b*))|c

    maybe "sequencing" should be called concatenation? I think it's much better word for it

  • Custom User Avatar

    removed that testcase

  • Custom User Avatar

    Given that the author hasn't logged in for 2 years, and first I reported this 4 years ago I decided to fix the types myself.

  • Custom User Avatar

    Given that the author hasn't logged in for 2 years, and first I reported this 4 years ago I decided to fix the types myself.

  • Custom User Avatar

    Given that the author hasn't logged in for 2 years, and first I reported this 4 years ago I decided to fix the types myself.

  • Custom User Avatar

    ah. I see. the name "count" mislead me.

  • Custom User Avatar

    haskell is non solvable with broken tests.
    the line in the test code

            countKprimes k start nd `shouldBe` s
    

    is supposed to be

            countKprimes k start nd `shouldBe` (length s)
    

    otherwise it doesn't type check. This is true for both the visible and the hidden test cases.

  • Custom User Avatar

    oops, reported it on the wrong kata.

    I meant to report it on https://www.codewars.com/kata/k-primes/

    resolving here... opening there ...

  • Custom User Avatar
  • Custom User Avatar

    haskell is non solvable with broken tests.
    the line in the test code

            countKprimes k start nd `shouldBe` s
    

    is supposed to be

            countKprimes k start nd `shouldBe` (length s)
    

    otherwise it doesn't type check. This is true for both the visible and the hidden test cases.

  • Loading more items...