Interesting Bug

Правка en1, от Ritwin, 2021-04-21 08:07:59

So I was golfing this problem, and I wanted to improve the line int c = t[v] = 1;, so I tried c = t[v] = 1;, with c defined earlier on in the same spot as a and b, but this didn't work. For the sample case, it gave the output 1 1 1 0 0 instead of 1 0 0 1 1.

I was wondering what that line actually does and if I can golf it more, so I found this question on quora, but even after reading that I still don't know why the other way isn't working. I use VSCode, so when I hover over the t[v] part, it says something to do with a reference to part of the bitset, so I'm thinking it's almost like a pointer to that index of the bitset, but that doesn't make sense because we're incrementing it, and you can't really increment a boolean value (which is basically what t[v] is..

Code
Теги bugs, #bitset

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Ritwin 2021-04-21 08:07:59 1393 Initial revision (published)