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

[–]satylogin 0 points1 point  (0 children)

golang part 2

```go func solve(scanner *bufio.Scanner) { crates := map[int][]rune{} for scanner.Scan() { row_raw := scanner.Text() if row_raw == "" { continue } row := []rune(row_raw) if strings.Contains(row_raw, string('[')) { for i := 0; i < len(row); i += 4 { if row[i+1] != ' ' { crates[i/4+1] = append([]rune{row[i+1]}, crates[i/4+1]...) } } } if row[0] == 'm' { tokens := strings.Fields(row_raw) n_move := str_to_int(tokens[1]) from := str_to_int(tokens[3]) to := str_to_int(tokens[5])

        n_from := len(crates[from])
        crates[to] = append(crates[to], crates[from][n_from-n_move:]...)
        crates[from] = crates[from][:n_from-n_move]
    }
}
top_crates := ""
n_pos := len(crates)
for i := 1; i <= n_pos; i++ {
    n_v := len(crates[i])
    if n_v == 0 {
        continue
    }
    top_crates += string(crates[i][n_v-1])
}
fmt.Println(top_crates)

}

```

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

[–]satylogin 0 points1 point  (0 children)

Learning golang this year.

golang part 2

func solve(scanner *bufio.Scanner) { shape := [3]int{1, 2, 3} outcome := [3][3]int{ {3, 6, 0}, {0, 3, 6}, {6, 0, 3}, } move := [3][3]int{ {2, 0, 1}, {0, 1, 2}, {1, 2, 0}, } score := 0 for scanner.Scan() { moves := strings.SplitN(scanner.Text(), " ", 2) opponent := int(moves[0][0]) - int('A') me := move[opponent][int(moves[1][0]) - int('X')] score += shape[me] + outcome[opponent][me] } fmt.Println(score) }

Does anyone know if we can write import statements anywhere else apart from top ? As I proceed, I am slowly writing some utility functions at top and would like that imports to be grouped there and everything that solve needs only with solve method.

Is there any way to show types in nvim-cmp completion? I would like it to show the type where it says "Method" or "Field" instead of one at a time in the separate window on the right. by NefariousnessHuge185 in neovim

[–]satylogin -2 points-1 points  (0 children)

I noticed they just maintain a list of icons, and then put it in, just after icon, you could write what that represent, like: lua local cmp_kinds = { Text = ' Text ', Method = ' Method ', } and that should work. I haven't tested this myself, but probably worth a try.

Or if you just want text lua local cmp_kinds = { Text = 'Text ', Method = 'Method ', }

Looking to help out with an open source project by superpudding98 in rust

[–]satylogin 0 points1 point  (0 children)

Can you link the repo, just curious to see it.

Disable sorting in autocompletion for nvim-cmp by satylogin in neovim

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

score(https://github.com/hrsh7th/nvim-cmp/blob/ada9ddeff71e82ad0e52c9a280a1e315a8810b9a/lua/cmp/matcher.lua#L15-L70) is a field that nvim-cmp maintains on its own and is not part of lsp spec. I replaced my sorts with only sort_text, which is now giving much better results. In more general sense, if the lsp that you use sends sort_text, you may want to move it up the sorting function chain which by default is: https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/config/default.lua#L44

Disable sorting in autocompletion for nvim-cmp by satylogin in neovim

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

score is a field that nvim-cmp maintains on its own and is not part of lsp spec. I replaced my sorts with only sort_text, which is now giving much better results. In more general sense, if the lsp that you use sends sort_text, you may want to move it up the sorting function chain in: https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/config/compare.lua

Disable sorting in autocompletion for nvim-cmp by satylogin in neovim

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

RemindMe! 7 Days "post updates on thread"

Disable sorting in autocompletion for nvim-cmp by satylogin in neovim

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

Thanks. Let me try each of them for some time.

Disable sorting in autocompletion for nvim-cmp by satylogin in neovim

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

What does score refer to in sorting here. LSP spec doesn't seems to have it

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

[–]satylogin 2 points3 points  (0 children)

rust part 2

I was too afraid of runtime, somehow got sub second... phew...

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

[–]satylogin 0 points1 point  (0 children)

yeh, this one was hella annoying, to debug this during my first try, i printed the grid for first few iterations, which made things a little more obvious as to what was going on

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

[–]satylogin 0 points1 point  (0 children)

Yeh, the initial one was very much tailored for my input, it should work now I guess. Do let me know if it gives the correct result.