Ad
  • Default User Avatar

    Thank you for answering me. I will try to implement it, but I haven't programmed in a while, so it will take some time and head bumping on how I get it into the machine.

  • Default User Avatar

    I guessed (10,10) once at the 4th move and once at the 5th move. That seems valid to me. The solution would be like exhaustively creating these paths while pruning the resulting tree by remembering what locations I already visited at which steps in a data structure.

    In my above example is actually an error in my 5th guess: I let him walk (3,3) -> (1,1) -> (2,2) -> (3,3) -> (1,1) but at the 3rd move he would end up at (6,6) which I already guessed as wrong for the 3rd move. The correct algorithm would result into this list and go like this:

    [(1,1),(3,3),(6,6),(10,10),(11,11)]

    Evil Genius 1st move: (1,1)                                                     => (1,1)
    EG 2nd move: (2,2) -> (1,1)                                                     => (3,3)
    EG 3rd:      (2,2) -> (3,3) -> (1,1)                                            => (6,6)
    EG 4th:      (2,2) -> (3,3) -> (2,2) -> (3,3)                                   => (10,10)
    EG 5th:      (2,2) -> (2,2) -> (2,2) !(sum = (6,6) already guessed)
                 (3,3) -> (1,1) -> (2,2) !(sum = (6,6) already guessed)
                 (3,3) -> (1,1) -> (3,3) -> (1,1) -> (3,3)                          => (11,11)
    EG 6th:      (3,3) -> (2,2) -> (3,3) -> (2,2) !(sum = (10,10) already guessed)
    paths exhausted
    

    One of these guesses has to be correct i.e.
    Either he went to (1,1) on his first move
    or (3,3) on his second move
    or (6,6,) on his third move
    or (10,10) on his fourth move
    or (11,11) on his fifth move.

    There is no path you can go for which none of these statements is true.
    At least thats how I understood the problem.

  • Default User Avatar

    So I can guess each step only once, but can guess 500 steps in total?
    e.g. for [(1,1),(2,2),(3,3)]
    Was your first step (1,1)?
    No
    Was your second step (2,2) + (1,1) = (3,3,)?
    No
    Was your 3rd step (2,2) + (3,3) + (1,1) = (6,6)?
    No
    Was your 4th step (2,2) + (3,3) + (2,2) + (3,3) = (10,10)?
    No => He didn't start with (2,2) or (1,1)
    Was your 5th step (3,3) + (1,1) + (2,2) + (3,3) + (1,1) = (10,10)?
    ...\

    and so on, search the space efficiently enough to make it in 500 steps for 8 moves\

  • Default User Avatar

    So my understanding of the problem is:
    a) I get a list of moves
    b) I have to guess a random pattern of moves, which can't have the same move twice

    But how do I figure out if a single guess is correct, so I can build on that?

    If we take the example:
    known inputs:
    moves = [(-1, 1), (1, 0), (0, -1), (0, 1), (-1, 0), (1, -1), (-1, -1), (1, 1)]

    unknown to you:
    actual_length_of_move_pattern = 2
    actual_move_pattern_chosen = [(1,0),(0,-1)]
    actual_moves = [(0,0),(1,0),(1,-1),(2,-1),(2,-2)...]

    I'll start my first guess: "Is your first move to (1,1)?"
    And he answers: "no"
    2nd guess: "Is it (1,0)?"
    Evil Genius: "yes"
    3rd guess: "Is your second move to (2,-1)?"
    EG: "no"
    ...
    until 500 guesses

    How do I get that feedback?
    If there is no feedback, the only way to "guess" the moveset - I currently see - is to caluculate all possible movesets which would be worst case 322560 guesses with a moveset of 8 moves. I need some other information than just the list of moves.

  • Default User Avatar

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

  • Default User Avatar
  • Default User Avatar

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

  • Default User Avatar

    I don't really get what happens at

    join (***) length ([...], [...])
    

    join just strips a Monad m => m (m a)) of its first monad container, the (***) -function takes two arrows and joins them via a tuple/the (,) function. All in all that should be the same as

    (***) length length ([...], [...])
    

    But how it works is a miracle for me.

    join :: Monad m => m (m a) -> m a
    (***) :: Arrow a =>  a b c -> a d e -> a (b,d) (c,e)
    length :: Foldable t => t a -> Int
    (***) length :: (Foldable t, Arrow a) => a d e -> a (t b, d) (Int, e)
    --so join somehow makes (***) into a (Arrow a => a b c -> a (b,b) (c,c))-type
    
  • Default User Avatar
  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Haskell:
    My code works and does what it should do when I compile it on my laptop, however when I test it here I get this error I don't understand:
    test/PowerSpec.hs:22:23: error:
    • Ambiguous type variable ‘a0’ arising from a use of ‘show’
    prevents the constraint ‘(Show a0)’ from being solved.
    Probable fix: use a type annotation to specify what ‘a0’ should be.
    These potential instances exist:
    instance Show Ordering -- Defined in ‘GHC.Show’
    instance Show Integer -- Defined in ‘GHC.Show’
    instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
    ...plus 22 others
    ...plus 32 instances involving out-of-scope types
    (use -fprint-potential-instances to see them all)
    • In the first argument of ‘length’, namely ‘(show $ snd (r !! 0))’
    In the first argument of ‘(>)’, namely
    ‘length (show $ snd (r !! 0))’
    In the second argument of ‘(||)’, namely
    ‘length (show $ snd (r !! 0)) > numDig’
    |
    22 | | null r || length (show $ snd (r!!0)) > numDig = (False, -1)
    | ^^^^^^^^^^^^^^^^^

    test/PowerSpec.hs:25:80: error:
    • Variable not in scope: ss :: [(a, a1)]
    • Perhaps you meant ‘ss'’ (line 29)
    |
    25 | r = dropWhile ((i,s) -> s ==0 || length (show s) < numDig ) $ take ordMax ss
    | ^^

    My code:

    olaf1 :: Int -> Int
    olaf1 0 = 0
    olaf1 1 = 1
    olaf1 2 = 3
    olaf1 n = foldl (\a (c,d) -> if c > d then c^d + d^c + a else if c == d then c^d + a else a) 0 $ zipWith (,) [n,(n-1)..(floor ((fromIntegral n)/2) :: Int)] [1..(ceiling ((fromIntegral n)/2) :: Int)]

    diggies :: Int -> Int
    diggies n = 1 + floor (logBase 10 $ fromIntegral n) :: Int

    minLengthNum :: Int -> Int -> (Bool, Int)
    minLengthNum d n = let l@(x:xs) = map (diggies . olaf1) [n, (n-1) .. 0] in if x >= d then (True, (-) (n+2) . length . takeWhile (>= d) $ l) else (False, (-1))

  • Default User Avatar

    there is something wrong with the function testing as this solution right here is false. For example for stuff like [5H, 3H, 4H, 5S, 4S]. I will delete it if i find out how.

  • Default User Avatar

    Oh, sorry. Thank you for pointing that out.

  • Loading more items...