Readit News logoReadit News
EnderShadow8 commented on Challenging algorithms and data structures every programmer should try   austinhenley.com/blog/cha... · Posted by u/whack
EnderShadow8 · 3 years ago
Segment trees are the foundation upon which all of competitive programming is built.
EnderShadow8 commented on VS Code Org Mode   github.com/vscode-org-mod... · Posted by u/spac
prescriptivist · 3 years ago
The most annoying thing to me about VS Code is it cannot be extended in a way that doesn't require developing a plugin. In short there is no ~/.vscode.ts. Instead you have to create a plugin to add custom commands.

I say this a a former emacs user now using VS Code.

EnderShadow8 · 3 years ago
You can write an extension which evals a JS file to recreate this
EnderShadow8 commented on Ask HN: How do you switch between programming languages?    · Posted by u/BrandoElFollito
GianFabien · 3 years ago
I program professionally in C, Python and Javascript.

Instead of starting with a empty file, I copy an existing file in the language that I'm using. Simply by seeing examples of syntactically correct code, I assimilate. It's only a 90% solution. For example using single quotes on strings in C and putting a ';' at the end of lines tends to creep into my Python code.

EnderShadow8 · 3 years ago
Why not use double quotes for strings in all languages? It makes sense for a number of reasons. Single quotes are much more likely to be in the contents of a string than double quotes.

Of course, if you have a style guide, you should stick to that.

EnderShadow8 commented on Deviations from Chromium (features we disable or remove)   github.com/brave/brave-br... · Posted by u/jacooper
Aachen · 3 years ago
But why did you want it removed / dislike it
EnderShadow8 · 3 years ago
It makes it more cumbersome to copy the URL
EnderShadow8 commented on An Intuition for Lisp Syntax (2020)   stopa.io/post/265... · Posted by u/cercatrova
Jensson · 3 years ago
The standard way is to close inline things inline and close multi-line things on a separate line.

Like this:

  (+ (EXPT 23 2.4)
     (SIN (* 44 0.23 22))
     (COS (+ 12 0.43 19.0))
     (TAN (/ 1.4 0.77 3/4))
  )
Instead of

  (+ (EXPT 23 2.4)
     (SIN (* 44 0.23 22))
     (COS (+ 12 0.43 19.0))
     (TAN (/ 1.4 0.77 3/4)))

EnderShadow8 · 3 years ago
Actually that's also wrong, I usually see this rule applied in other languages:

If the opening bracket is on the same line as content, then so is the closing bracket.

By this rule, we have two options:

  (+
     (EXPT 23 2.4)
     (SIN (\* 44 0.23 22))
     (COS (+ 12 0.43 19.0))
     (TAN (/ 1.4 0.77 3/4))
  )
or

  (+ (EXPT 23 2.4)
     (SIN (\* 44 0.23 22))
     (COS (+ 12 0.43 19.0))
     (TAN (/ 1.4 0.77 3/4)))

The first option has both opening and closing brackets on their own lines, while the second has neither. Note that I consider the function name to be part of the opening bracket since it's distinct from the parameters.

This is consistent with other languages:

  [1, 2, 3]
  f(x, y, z)
  [
    1,
    2,
    3,
  ]
  f(
    x,
    y,
    z
  )
instead of

  [1,
   2,
   3,
  ]
  f(x,
    y,
    z,
   )

EnderShadow8 commented on The Mystery of the Frog Riddle   horenbergerb.github.io/20... · Posted by u/seongyher
EnderShadow8 · 3 years ago
This video clears up the confusion IMO

https://www.youtube.com/watch?v=go3xtDdsNQM

EnderShadow8 commented on Five Laws of Human Stupidity (1976)   harmful.cat-v.org/people/... · Posted by u/Budaa
GrinningFool · 3 years ago
Wait.

"The First Basic Law prevents me from attributing a specific numerical value to the fraction of stupid people within the total population: any numerical estimate would turn out to be an underestimate."

If that held true for any estimate, the only correct answer is one hundred percent of the total population is stupid.

EnderShadow8 · 3 years ago
I think that's the implication
EnderShadow8 commented on Ask HN: What are some cool but obscure data structures you know about?    · Posted by u/Uptrenda
gordaco · 3 years ago
Fenwick Trees (which, despite the name, are implemented using an array) allow counting prefix sums AND updating prefix sums in O(log n) time. Very useful when n is in the order of millions. I have used them a few times in Project Euler problems.

https://en.wikipedia.org/wiki/Fenwick_tree

EnderShadow8 · 3 years ago
Segment trees are objectively superior in all ways except implementation length
EnderShadow8 commented on Ask HN: What are some cool but obscure data structures you know about?    · Posted by u/Uptrenda
kaymanb · 3 years ago
Disjoint-Sets have a very cool implementation whose amortized time complexity is extremely slow growing. It is not quite constant, but even for a disjoint-set with as many elements as there are particles in the universe, the amortized cost of an operation will be less than or equal to 4.

https://en.wikipedia.org/wiki/Disjoint-set_data_structure

EnderShadow8 · 3 years ago
I've been told to consider it constant for all practical purposes
EnderShadow8 commented on Ask HN: What are some cool but obscure data structures you know about?    · Posted by u/Uptrenda
EnderShadow8 · 3 years ago
Treap: https://en.wikipedia.org/wiki/Treap

It's like a Red-Black tree in use case, but much faster to implement, which is good for competitive programming. The average case complexity is the same for all operations, but there's an unlikely degeneration to worst-case linked-list behaviour.

Lazy Propagation Segment Tree: https://cp-algorithms.com/data_structures/segment_tree.html

Like a segment tree in that it supports range queries in logarithmic time, but supports range updates in log time as well.

I know a few more fun ones that I occasionally use in contests, but I've never touched otherwise.

u/EnderShadow8

KarmaCake day36May 31, 2021View Original