2024/04/20

Newest at the top

2024-04-20 14:24:19 +0200 <ph88> ncf, that if Left is found that it doesn't try the next value in the functor but stops immediately
2024-04-20 14:22:50 +0200 <Guest13> im not very good at Haskell yet
2024-04-20 14:22:50 +0200elbear(~lucian@79.118.150.93) (Ping timeout: 245 seconds)
2024-04-20 14:22:39 +0200 <Guest13> this solution looks really good, ill need to stare at it for a while though XD
2024-04-20 14:20:58 +0200divya(~user@202.170.201.110)
2024-04-20 14:20:04 +0200tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2024-04-20 14:20:02 +0200 <ncf> ph88: what do you mean by short-circuiting here?
2024-04-20 14:18:41 +0200 <ncf> see glguy's solution for example: https://github.com/glguy/advent/blob/main/solutions/src/2023/04.hs#L55
2024-04-20 14:18:21 +0200 <ncf> fwiw there are simpler ways of solving this problem: instead of translating an imperative solution to haskell, you might try to compute the solution with a single fold
2024-04-20 14:18:05 +0200elbear(~lucian@79.118.150.93)
2024-04-20 14:17:24 +0200 <Guest13> thank you for the help!
2024-04-20 14:17:07 +0200 <Guest13> I understand that this works now I just need to understand foldl vs foldr
2024-04-20 14:16:32 +0200 <Guest13> I think a map would be good also
2024-04-20 14:16:27 +0200 <Guest13> yes this would be better
2024-04-20 14:15:51 +0200 <ph88> https://bpa.st/FXRA
2024-04-20 14:15:40 +0200 <ncf> you should zip with [0..]
2024-04-20 14:15:36 +0200 <ncf> oh i see you already have an off-by-one since you're zipping with [1..] instead of [0..]
2024-04-20 14:15:20 +0200divya(~user@202.170.201.110) (Ping timeout: 245 seconds)
2024-04-20 14:15:16 +0200 <ph88> does the compiler optimize this function by short circuiting on Left? https://bpa.st/RNTQ
2024-04-20 14:15:10 +0200tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Read error: Connection reset by peer)
2024-04-20 14:14:54 +0200ph88(~ph88@91.64.63.48)
2024-04-20 14:14:26 +0200 <Guest13> yes I've got the correct answer now thank you! I changed it to acc!!(I-1) also as well as using foldl
2024-04-20 14:13:15 +0200 <Guest13> scanL?
2024-04-20 14:13:11 +0200 <Guest13> scan?
2024-04-20 14:12:57 +0200 <ncf> btw you can replace fold with scan to see the intermediate results
2024-04-20 14:12:29 +0200 <Guest13> I do want it to go from left to right
2024-04-20 14:12:22 +0200 <Guest13> I think this is it yes
2024-04-20 14:11:05 +0200 <ncf> then i get [(1,1),(2,2),(3,4),(4,8),(5,12),(6,1)], a bit off from what you expect
2024-04-20 14:10:43 +0200 <ncf> i think you want to traverse wins left-to-right, so use foldl instead of foldr
2024-04-20 14:09:57 +0200 <Guest13>     }
2024-04-20 14:09:56 +0200 <Guest13>         }
2024-04-20 14:09:56 +0200 <Guest13>             }
2024-04-20 14:09:55 +0200 <Guest13>                 cards_vec[i+j as usize] += 1 * cards_vec[I];
2024-04-20 14:09:55 +0200 <Guest13>             if (i + j as usize) < cards_vec.len() {
2024-04-20 14:09:54 +0200 <Guest13>         for j in 1..=win {
2024-04-20 14:09:54 +0200 <Guest13>     for (i, &win) in wins_vec.iter().enumerate() {
2024-04-20 14:09:53 +0200 <Guest13> let mut cards_vec = vec![1; wins_vec.len()];
2024-04-20 14:09:53 +0200 <Guest13> not sure if it helps, but what I am trying to do is something like what I did in Rust:
2024-04-20 14:08:12 +0200 <Guest13> the desired output of the fold is [(1,1),(2,2),(3,4),(4,8),(5,14),(6,1)]
2024-04-20 14:06:37 +0200 <Guest13> https://play.haskell.org/saved/pPbc3Jm5
2024-04-20 14:06:30 +0200 <Guest13> sorry let me put the test in string
2024-04-20 14:06:23 +0200 <ncf> Main: input/04.txt: openFile: does not exist (No such file or directory)
2024-04-20 14:06:01 +0200madeleine-sydney(~madeleine@c-76-155-235-153.hsd1.co.comcast.net) (Quit: Konversation terminated!)
2024-04-20 14:04:44 +0200 <Guest13> https://play.haskell.org/saved/Fw88Z29V
2024-04-20 14:03:21 +0200 <ncf> can you post a reproducer on https://play.haskell.org/ ?
2024-04-20 14:01:52 +0200 <Guest13> it updates the correct values but it should be a +2 because multiplier = snd(2,2)
2024-04-20 14:01:15 +0200 <Guest13> sorry, the correct second step should be [(1,1),(2,2),(3,4),(4,4),(5,2),(6,1)]
2024-04-20 14:00:51 +0200 <Guest13> the correct second step should be [(1,1),(2,2),(3,4),(5,4),(6,1)]
2024-04-20 14:00:51 +0200 <Guest13> third step: [(1,1),(2,2),(3,3),(4,4),(5,3),(6,1)]
2024-04-20 14:00:50 +0200 <Guest13> second step: [(1,1),(2,2),(3,3),(4,3),(5,2),(6,1)]