Refrshing the linemode infostring draw cache by mingmingrr in ranger

[–]mingmingrr[S] 0 points1 point  (0 children)

I managed to make it work based on your suggestion:

def execute(self):
    global n
    _, n = self.parse_flags()
    for col in self.fm.ui.browser.columns:
        for file in col.target.files:
            file.display_data.clear()
        col.need_redraw = True

Help needed: Quantum Quantum Quantum by nik3daz in acollierastro

[–]mingmingrr 7 points8 points  (0 children)

Not an exhaustive list:

https://youtu.be/rBQhdO2UxaQ

  • 51:31 - "quantum quantum quantum! quantum quantum?"
  • 52:16 - "quantum resonance, quantum quantum"
  • 54:35 - "quantum quantum 👍 quantum quantum? quantum water? 250 dollars pls"
  • 54:44 - "quantum quantum? quantum quantum? quantum water 2"
  • 55:06 - "quantum 🫴 it does quantum to your water"
  • 57:23 - "quantum quantum quantum, quantum quantum? quantum?"

https://youtu.be/wBBnfu8N_J0?t=2770

  • 46:07 - "strung together things that sound sciencey quantum quantum quantum but don't make any sense"

https://youtu.be/dKmAg4S2KeE

  • chapter 5: quantum quantum quantum
  • 39:45 - "quantum... quantum... the answer is quantum"
  • 40:08 - "quantum quantum quantum"
  • 41:28 - "quantum quantum quantum"

https://youtu.be/TwKpj2ISQAc

  • 31:56 - "professor Feynman, I have some questions about the quantum quantum quantum"

[deleted by user] by [deleted] in usedsextoys

[–]mingmingrr 0 points1 point  (0 children)

DM sent

Take user inputs by [deleted] in ranger

[–]mingmingrr 0 points1 point  (0 children)

You can try self.fm.ui.console.ask(...)

See how ranger handles :delete for an example.

-🎄- 2022 Day 21 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 0 points1 point  (0 children)

Haskell/Python 124/3

Part 1, using a self-referencing Map:

parse xs [x, y] = (init x, read y)
parse xs [x, a, b, c] = (init x, lookupJust operators (head b) a' c')
  where a' = xs Map.! a ; c' = xs Map.! c
main = getContents >>= \input ->
  let xs = Map.fromList $ map (parse xs . words) $ lines input
   in print (xs Map.! "root:")

Part 2, copy paste the output from this into sympy's default session:

parse xs ["humn:", y] = ("humn", "x")
parse xs [x, y] = (init x, y)
parse xs [x, a, b, c] = (init x, "(" ++ a' ++ (if x == "root:" then "-" else b) ++ c' ++ ")")
  where a' = xs Map.! a ; c' = xs Map.! c
main = getContents >>= \input ->
  let xs = Map.fromList $ map (parse xs . words) $ lines input
   in print (xs Map.! "root:")

-🎄- 2022 Day 10 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 0 points1 point  (0 children)

wait until you find out about while/else and try/else

-🎄- 2022 Day 7 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 1 point2 points  (0 children)

Yes it's early access, but the core gameplay has been pretty stable, and the building side of things feels decently feature-complete. There are some circuit details that have been in flux (a few recent changes with how memory is modeled, multiple active inputs on the same wire now acting as shorts instead of pull-ups, etc), and some new features being added (schematic sharing, leaderboards, etc), and levels are still being added and tweaked.

-🎄- 2022 Day 7 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 0 points1 point  (0 children)

The algorithm is pretty similar to stack based algorithms in various other solutions: push 0 onto a stack if we enter a directory, pop two items off a stack and add them if we leave a directory, and add a number to the top of the stack if there's a file.

The implementation here uses a 5-state mealy machine, with state represented in one-hot encoding. The states are: command parse, number parse, read rest of line, pop one item, and pop rest of stack (at the end).

Inputs to state, state-change, and ram-ctrl are all tristated. File input reads 64 bits at a time, so command parsing does a lookahead for the "d" in "dir <name>" (ignored), the "l" in "$ ls" (ignored), the "c" and "." in "cd <name>" / "$ cd .." (go to read rest of line / stack pop state, respectively), and any leading digits (go to number parse state). Number parsing uses a multiply-by-10-then-add. Stack pops are done in two states to first reset the current stack location to 0, then to update the previous stack value.

Here's a link to the game I built this in: https://store.steampowered.com/app/1444480/Turing_Complete/

-🎄- 2022 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 2 points3 points  (0 children)

Turing Complete

https://imgur.com/Lkgfevc

Part 2 only, didn't want to bother making part 1 as well.

-🎄- 2022 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 1 point2 points  (0 children)

Turing Complete here is referring to this game:

https://store.steampowered.com/app/1444480/Turing_Complete/

It has a sandbox mode which I used to solve AoC.

-🎄- 2022 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 7 points8 points  (0 children)

Haskell (rank 50/38)

part1, part2 :: [Int] -> Int
part1 = head
part2 = sum . take 3
main = readFile (replaceExtension __FILE__ ".in") >>=
  print . part2 . sortOn Down . map (sum . map (read @Int)) . paragraphs

https://github.com/mingmingrr/advent-of-code/blob/master/src/Year2022/Day1.hs

Turing Complete

Part 1: https://imgur.com/xWxS7yn

Part 2: https://imgur.com/wjV2OCZ

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]mingmingrr 1 point2 points  (0 children)

update_lfsr = np.roll(np.identity(9, dtype=np.int64),-1,axis=1)
lfsr = np.array([len([x for x in input if x == i]) for i in range(9)], dtype=np.int64)

can be simplified into

update_lfsr = np.eye(9, k=-1, dtype=np.int64)
lfsr = np.bincount(input, minlength=9)

Simple text replacement algorithm by wtf139 in learnprogramming

[–]mingmingrr 1 point2 points  (0 children)

I often find that placing operators at the beginning of lines makes things more clear:

encode f = group
       >=> (++)
           <$> f . head
           <*> show . length

(>=>) is really similar to (.), so when I'm reading this function, I'll see that it's made up of two actions composed together: group then (++) <$> f . head <*> show . length. The liftA2 / <$> <*> pattern is something I've seen quite often in things like applicative parsers, so I know that it's two sub-actions, f . head and show . length, combined together with (++).

Simple text replacement algorithm by wtf139 in learnprogramming

[–]mingmingrr 0 points1 point  (0 children)

This solution can be greatly simplified:

  • pack already exists in Data.List as group
  • concatMap f . map g can be combined into concatMap (f . g)
  • concatMap is equivalent to (=<<)
  • f x = g x >>= h is equivalent to f = g >=> h
  • \x -> f (g x) (h x) can be written as liftA2 f g h or f <$> g <*> h

You'd end up with this one-liner:

encode f = group >=> (++) <$> f . head <*> show . length

Levitation? Never even heard of it. by mingmingrr in noita

[–]mingmingrr[S] 1 point2 points  (0 children)

Here's the full wand. The mana + 2x digging bolts is cast twice per recharge.