Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Go random tests are broken:

    Random tests
    With arr = [0 0 0 0 0 0 0 0], t = 3, k = 3
    Expected
        <int>: 55
    to equal
        <int>: 60
    

    You are given a certain array of positive and negative integers which elements occur only once (all of them different from 0)

  • Custom User Avatar

    There is some wording weirdness in the instructions. I would understand how a sequence of elements in this sense can be contigous - it would be a slice of the original array. Then non contigous would be when it's not a slice of the original array, ie it has one gap. There is no sensible definition for calling an element contigous which the description does as it's not a property of the element. I understand what it's trying to say though. I would reprhase the instructions. Also would explicitly explain that no joint pairs following the original array order are allowed.

  • Custom User Avatar

    This operates on arr in place. While it wasn't explicitly stated the function should operate on a copy, one could argue the return type only makes sense if the function operated on a copy.

  • 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.

  • Loading more items...