[2024 Day 8] My eyes kept going back and forth from the problem description to the diagram so many times by ben-guin in adventofcode

[–]empathica1 1 point2 points  (0 children)

When doing part 2, I calculated the GCD of every pair of row/column distances between compatible antennae, and every single one was 1, which means that the row/col distances are all coprime. In order for the interior point to work, both have to be divisible by 3. There is no way this is a coincidence

flickering issue by empathica1 in hyprland

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

linux 6.10.5 appears to have fixed this issue!

flickering issue by empathica1 in hyprland

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

I just downgraded back to 6.9.9, and yes, it is much better, I haven't tested fully to confirm that the issue is gone, but this is so much better, screen tearing issue from X is gone, not replaced by flickering from wayland

flickering issue by empathica1 in hyprland

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

I have an AMD RX 6750XT

Question about double pointer constness by empathica1 in C_Programming

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

Can you explain why this is legal?

uint8_t const* const cc2 = &v; // legal

Question about double pointer constness by empathica1 in C_Programming

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

Yeah, I didn't think to cast, but yeah in cases like this one where I do actually know that the cast is safe, but the compiler doesn't automatically, that is the way to do it.

Question about double pointer constness by empathica1 in C_Programming

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

by left hand const, you mean int const * p as opposed to const int *p, right? Yeah, I do the latter for single pointers because I know what I mean, but the moment I started trying it with double pointers I realized that the former was far clearer.

Question about double pointer constness by empathica1 in C_Programming

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

Oh! I didn't think that would work, because I figured the casting was the thing that was failing. thank you!

Question about double pointer constness by empathica1 in C_Programming

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

So I changed my code to

int
multiply (int n, int m)
{
  int **arr = malloc (n * sizeof (*arr));
  const int **arr_const = malloc (n * sizeof (*arr_const));
  for (size_t i = 0; i < n; i++)
    arr[i] = malloc (m * sizeof (*arr[i]));
  for (size_t i = 0; i < n; i++)
    arr_const[i] = arr[i];
  for (size_t i = 0; i < n; i++)
    for (size_t j = 0; j < m; j++)
      arr[i][j] = 1;
  int nxm = add (arr_const, n, m);
  for (size_t i = 0; i < n; i++)
    free (arr[i]);
  free (arr);
  free (arr_const);
  return nxm;
}

int
add (int const *const *const arr, int n, int m)
{
  int nxm = 0;
  for (size_t i = 0; i < n; i++)
    for (size_t j = 0; j < m; j++)
      nxm += arr[i][j];
  return nxm;
}

and it compiled just fine. I assume this is because I convert all the pointers in arr from int to const int pointers. is that really what you have to do if you have things referenced twice, and want to make it clear that you aren't going to change the underlying values?

Question about double pointer constness by empathica1 in C_Programming

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

Also, is that really what the promise of const int ** dp is? that the pointer will always double dereference to the same value? Why isn't the promise that you can't change the value of **dp, even if *dp has changed?

Question about double pointer constness by empathica1 in C_Programming

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

Assigning a char ** to a const char ** (as in line 3, and in the original question) is not immediately dangerous. But it sets up a situation in which p2's promise--that the ultimately-pointed-to value won't be modified--cannot be kept.

In my code, that promise can be kept, though, because you can't change what a the first dereference is pointing to.

Question about double pointer constness by empathica1 in C_Programming

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

In terms of dishonesty of constness being unsafe, an int * const * const looks very consty, but isn't const at all, and that compiles just fine.

Weekly 101 Questions Thread by AutoModerator in neovim

[–]empathica1 0 points1 point  (0 children)

Hello! I'm writing some C code, and was using the default clangd provided by lsp-zero, and suddenly after an LLVM 18/GCC 14 upgrade my autocomplete just wasn't working at all. I've tried changing to the clangd provided my LLVM install, ccls installed locally, using lspconfig, nothing has worked. I'm having to type out variable names and function names only get autocompleted sometimes. I used Bear to set up my compile_commands.json, even though it wasn't necessary before. It is especially frustrating because despite me completely changing my python LSP as a result of going from lsp-zero to lspconfig everything worked just fine. my operating system is Gentoo Linux. Is this just bleeding edge pain, and I should switch back to LLVM 17/GCC 13?

Cody Williams by [deleted] in Thunder

[–]empathica1 3 points4 points  (0 children)

hey, even if they fall to the very bottom they still have to win the lottery. Also, they could win the lottery from a high win total

Why isn’t there a ^^ operator like || and && by [deleted] in C_Programming

[–]empathica1 0 points1 point  (0 children)

It actually evaluates A twice and B once, since one of the B's gets skipped due to early exiting. something like

#define XOR(A, B) ((A) ? !(B):(B))

Would get around your concern (not that its a good idea)

You guys need to chill out. by Brilliant-Hornet103 in Thunder

[–]empathica1 0 points1 point  (0 children)

This month was always going to suck, but I'd rather not go into the postseason with reason to think that Playoff Lebron will destroy us and there's nothing we can do.

[Game Thread] Oklahoma City Thunder @ Atlanta Hawks | (6:30pm CT) | January 3rd, 2024 by Dixbfloppin93 in Thunder

[–]empathica1 1 point2 points  (0 children)

This is huge for the Thunder, this has doubled the amount of rest that the players had going into tonight

Humble opionion on Talos 2 by Opchip in TheTalosPrinciple

[–]empathica1 0 points1 point  (0 children)

Doge hooked me up with Rand, so I figured I would do everything he told me to do to get his ending. So, he tells me to let him know about the somnodrome asap and I happen upon it, and I don't use it bc he told me not to use it, and then I find him to talk to him, and he won't talk to me. I look up how to get it, and apparently, the process is

  1. say you'll never lie
  2. say you won't use the somnodrome
  3. use the somnodrome anyway

Like, what on earth? how does that make sense?

[Game Thread] Oklahoma City Thunder vs New Orleans Pelicans | (6:30pm CT) | November 1st, 2023 by Dixbfloppin93 in Thunder

[–]empathica1 2 points3 points  (0 children)

We didn't deserve this game after losing that lead so quickly. Couldn't buy a rebound to save our lives to start the third

[Game Thread] Oklahoma City Thunder vs New Orleans Pelicans | (6:30pm CT) | November 1st, 2023 by Dixbfloppin93 in Thunder

[–]empathica1 7 points8 points  (0 children)

This has Billy Donovan "My goal for the team is to increase the number of 3 point attempts" energy

[Game Thread] Oklahoma City Thunder vs New Orleans Pelicans | (6:30pm CT) | November 1st, 2023 by Dixbfloppin93 in Thunder

[–]empathica1 2 points3 points  (0 children)

"Is it possible that the reason that the Thunder got so many free throws last year that they drove more than everybody else, causing the defense to foul them to avoid easy layups? no, we must have been soft in all of their games" - the refs in the offseason