Ad
  • Custom User Avatar

    What I like about this solution is that it defines custum data types. What I don't like about the solution is its often very short variable and function names. When it isn't meaningful to introduce a new variable/function one can often do the computation(?) in place, like inserting a case .. of or a lambda (case) instead of a new function. E.g.:

    exec cmd regs = case cmd of
    Mov a b -> ...
    Inc a -> ...
    where
    ...

    Also in simpleAssembler sz does't change, so it doesn't need to be an argument of go

  • Custom User Avatar

    This solution fails for ambiguous sampling.

    signal = "11111111000000"
    discrete = map length . group $ signal
    
    minimum discrete == 6
    foldl' gcd 0 discrete == 2
    
  • Custom User Avatar

    There's an option to switch to TypeScript ES6, which supports String.prototype.repeat.

  • Custom User Avatar

    I had the same problem, but it just means there's something else wrong with your code.

    Sometimes the errors you get back don't make any sense.

  • Custom User Avatar

    prop_ext_eq n k = n >= 1 && n <= 10000 && k >= 1 && k <= 100 ==> twoByN n k == twoByN' n k
    It generates integers by

    instance Arbitrary Integer where
      arbitrary = arbitrarySizedIntegral
      shrink    = shrinkIntegral
    

    where

    arbitrarySizedIntegral =
      sized $ \n ->
      inBounds fromInteger (choose (-toInteger n, toInteger n))
    

    first, then checks the constraint, so the upper bound of n is about 100 here.

  • Custom User Avatar

    prop_ext_eq n k = n >= 1 && n <= 10000 && k >= 1 && k <= 100 ==> twoByN n k == twoByN' n k
    It generates integers by

    instance Arbitrary Integer where
      arbitrary = arbitrarySizedIntegral
      shrink    = shrinkIntegral
    

    where

    arbitrarySizedIntegral =
      sized $ \n ->
      inBounds fromInteger (choose (-toInteger n, toInteger n))
    

    first, then checks the constraint, so the upper bound of n is about 100 here.

  • Custom User Avatar

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