Hi, I’m Amy.

✨ New 🏳️‍⚧️ improved ♀️ version 👩‍❤️‍👩 out 🏳️‍🌈 now! 🎊

I live in Japan. Talk to me about Haskell, Scheme, and Linux.

日本語も通じます。

  • 2 Posts
  • 40 Comments
Joined 9 months ago
cake
Cake day: October 17th, 2025

help-circle









  • Who wouldn’t like that?

    Surprisingly, an awful lot of men :3 One other factor to consider is how often you think about having a female body. An occasional “heh, that might be cool for a day” when you watch a gender-bending anime, or whenever your mind wanders?

    A good way to confront your internalized phobias and biases is to ask yourself, if being a woman sounds good, why haven’t you transitioned already?

    A couple of answers I hear a lot from trans-questioning people are:

    • “I’m ok with being a man.” ⇨ Does “ok” really mean “ok”, or is it perhaps “I don’t like it, but it’s all I know” (could be repressed dysphoria).
    • “Being born a woman would be OK, but I wouldn’t want to be a trans woman” ⇨ This could be internalized transphobia presenting as a fear of not passing.
    • “I don’t feel like a woman” ⇨ nobody “feels like” their gender, but you know who wants to be a woman? Women.
    • “I’m worried about what family/friends/society would say” ⇨ in other words, I want to transition but other people don’t want me to.



  • Haskell

    Oh, this one was easy (dynamic programming at last!). Still haven’t figured out the right way to approach yesterday’s part two, though.

    import Data.List  
    import Data.Map (Map)  
    import Data.Map qualified as Map  
    
    readInput =  
      Map.fromList  
        . map ((\(name : outs) -> (init name, outs)) . words)  
        . lines  
    
    part1 input = go "you"  
      where  
        go "out" = 1  
        go name = maybe 0 (sum . map go) $ input Map.!? name  
    
    part2 input = let (both, _, _, _) = pathsFrom "svr" in both  
      where  
        pathsFrom =  
          (Map.!)  
            . Map.insert "out" (0, 0, 0, 1)  
            . Map.fromList  
            . (zip <*> map findPaths)  
            $ Map.keys input ++ concat (Map.elems input)  
        findPaths n =  
          let (both, dac, fft, none) =  
                unzip4 $ maybe [] (map pathsFrom) (input Map.!? n)  
           in case n of  
                "dac" -> (sum both + sum fft, sum dac + sum none, 0, 0)  
                "fft" -> (sum both + sum dac, 0, sum fft + sum none, 0)  
                _ -> (sum both, sum dac, sum fft, sum none)  
    
    main = do  
      input <- readInput <$> readFile "input11"  
      print $ part1 input  
      print $ part2 input  
    


  • Haskell

    This is pretty ugly. I got rather fed up after trying out various heuristics when the test case passed but actual data didn’t.

    import Control.Arrow  
    import Data.Function  
    import Data.Ix  
    import Data.List  
    import Data.Ord  
    
    readInput :: String -> [(Int, Int)]  
    readInput = map ((read *** (read . tail)) . break (== ',')) . lines  
    
    pairs = concatMap (\(x : xs) -> map (x,) xs) . init . tails  
    
    toRange ((a, b), (c, d)) = ((min a c, min b d), (max a c, max b d))  
    
    onTiles loop rect = cornersInside && not crossingEdges  
      where  
        cornersInside =  
          let ((a, b), (c, d)) = rect  
           in inside (a, d) && inside (c, b)  
        verticalEdges = sortOn (Down . fst . fst) $ filter (uncurry ((==) `on` fst)) loop  
        inside (x, y) =  
          let intersecting ((a, b), (_, d)) = a <= x && inRange (min b d, max b d) y  
           in maybe False (uncurry ((>) `on` snd)) $ find intersecting verticalEdges  
        crossingEdges =  
          let ((a, b), (c, d)) = rect  
           in any (crossingLoop . toRange) $  
                [ ((a, b), (c, b)),  
                  ((c, b), (c, d)),  
                  ((c, d), (a, d)),  
                  ((a, d), (a, b))  
                ]  
        crossingLoop ((a, b), (c, d))  
          | a == c = anyEdge (\((e, f), (g, h)) -> f == h && f > b && f < d && g > a && e < c)  
          | b == d = anyEdge (\((e, f), (g, h)) -> e == g && e > a && e < c && h > b && f < d)  
        anyEdge = flip any $ map toRange loop  
    
    main = do  
      input <- readInput <$> readFile "input09"  
      let rects = pairs input  
          loop = zip (last input : input) input  
          go = print . maximum . map (rangeSize . toRange)  
      go rects  
      go $ filter (onTiles loop) rects  
    



  • Haskell

    I was late to the part on this one and forgot to post my solution :3

    import Data.List  
    
    readInput = map readMove . lines  
      where  
        readMove (d : ds) =  
          let n = read ds :: Int  
           in case d of  
                'L' -> -n  
                'R' -> n  
    
    part1 = length . filter ((== 0) . (`mod` 100)) . scanl' (+) 50  
    
    part2 = fst . foldl' count (0, 50)  
      where  
        count (z, p) d =  
          let (q, r) = (p + d) `divMod` 100  
              a = if p == 0 && d < 0 then -1 else 0  
              b = if r == 0 && d < 0 then 1 else 0  
           in (z + abs q + a + b, r)  
    
    main = do  
      input <- readInput <$> readFile "input01"  
      print $ part1 input  
      print $ part2 input  
    


  • Haskell

    They’re getting interesting now!

    import Control.Monad  
    import Data.List  
    import Data.List.Split  
    import Data.Ord  
    import Data.Set qualified as Set  
    
    readPos = (\([x, y, z] :: [Int]) -> (x, y, z)) . map read . splitOn ","  
    
    pairs = init . tails >=> (\(x : xs) -> map (x,) xs)  
    
    dist (x1, y1, z1) (x2, y2, z2) =  
      (x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2  
    
    connect circuits (a, b) =  
      let (joined, rest) =  
            partition (\c -> a `Set.member` c || b `Set.member` c) circuits  
       in Set.unions joined : rest  
    
    main = do  
      boxes <- map readPos . lines <$> readFile "input08"  
      let steps =  
            (zip <*> tail . scanl' connect (map Set.singleton boxes)) $  
              sortOn (uncurry dist) (pairs boxes)  
      print . product . take 3 . sortOn Down . map Set.size $  
        (snd . last . take 1000 $ steps)  
      let Just (((x1, _, _), (x2, _, _)), _) =  
            find ((== 1) . length . snd) steps  
       in print $ x1 * x2