HNHacker News
TopNewBestAskShowJobs

EnderShadow8

36 karma · joined May 31, 2021

submissionscomments
EnderShadow8··on Challenging algorithms and data structures every programmer should try
Segment trees are the foundation upon which all of competitive programming is built.
EnderShadow8··on VS Code Org Mode
You can write an extension which evals a JS file to recreate this
EnderShadow8··on Ask HN: How do you switch between programming languages?
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··on Deviations from Chromium (features we disable or remove)
It makes it more cumbersome to copy the URL
EnderShadow8··on An Intuition for Lisp Syntax (2020)
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··on The Mystery of the Frog Riddle
This video clears up the confusion IMO

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

EnderShadow8··on Five Laws of Human Stupidity (1976)
I think that's the implication
EnderShadow8··on Ask HN: What are some cool but obscure data structures you know about?
Segment trees are objectively superior in all ways except implementation length
EnderShadow8··on Ask HN: What are some cool but obscure data structures you know about?
I've been told to consider it constant for all practical purposes
EnderShadow8··on Ask HN: What are some cool but obscure data structures you know about?
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.

EnderShadow8··on Why Hy?
This might be interesting https://pypi.org/project/scoping/
EnderShadow8··on Google, Meta, others will have to explain algorithms under new EU legislation
An alternative might be for personalisation to be opt-in rather than opt-out even when signed in with an account (which shouldn't even be necessary for many services anyway)
EnderShadow8··on Ana is a Python, PHP, and C inspired dynamically typed scripting language
Go enforces 1TBS over Allman style braces IIRC. I don't really care because I like 1TBS and also don't write Go but it did enstrange parts of the community.
EnderShadow8··on Show HN: I made a puzzle game in HTML5
CaryKH made something similar a while ago: https://www.youtube.com/watch?v=95rtiz-V2zM
EnderShadow8··on MarketRank: Anti-SEO Ranking Algorithm
Instead of using upvotes from sites such as Reddit and HN, why not instead allow the users of the search engine itself upvote and downvote results? This might allow quality results outside the scope of larger online communities to still be highly ranked, and also tailor the results to the audience of the search engine itself.
EnderShadow8··on Show HN: All desktop software calculators are wrong, so I had to build my own
I just use a Python or Node shell as a calculator. It usually works well enough.
EnderShadow8··on How I See Numbers
This is basically exactly me, except I don't have as concrete of a feel of the actual shapes, all I know is that 9's slice off ones from other numbers, not that actual shape of the number that allows it to do wo.
EnderShadow8··on Speeding up my Advent of Code solution with Dijkstra's Algorithm
Priority queues aren't constant time. They're log time.
EnderShadow8··on Speeding up my Advent of Code solution with Dijkstra's Algorithm
If it works, it works. Priority queues are an extremely powerful data structure if you leverage them right.

I find C++'s set and map and related data structures are also very useful for solving cp problems.

EnderShadow8··on Ask HN: I feel so shallow and dumb when I see what other smart people are doing
I often feel something along the lines of this as well. I often feel like no matter how much effort and energy and passion I put into something, nobody will care. It's like screaming into the void. If almost nobody sees this comment, well, that just proves my point.
EnderShadow8··on Ask HN: Stack Overflow Without the Cancer?
Marking questions as "stupid, irrelevant, lazy etc" is SO's way of maintaining site content quality. Though they do get a bit aggressive at times, it's actually a good thing. A site without that just turns into Reddit.

AKA Shitpost Central.

EnderShadow8··on Tricks I wish I knew when I learned TypeScript
Note: don't use typeof x === 'object' to check whether something is a valid object, because it will return true for arrays as well.

Arrays are objects, so this is expected behaviour.