Better HN
topnewbestaskshowjobs
Log inSign up

EnderShadow8

36 karma · joined May 31, 2021 (5y ago) · 29 submissions

Submissions

comment 3y ago · link · parent

Segment trees are the foundation upon which all of competitive programming is built.

comment 4y ago · link · parent

You can write an extension which evals a JS file to recreate this

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

It makes it more cumbersome to copy the URL

comment 4y ago · link · parent

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,
   )

comment 4y ago · link · parent

This video clears up the confusion IMO

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

comment 4y ago · link · parent

I think that's the implication

comment 4y ago · link · parent

Segment trees are objectively superior in all ways except implementation length

comment 4y ago · link · parent

I've been told to consider it constant for all practical purposes

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

This might be interesting https://pypi.org/project/scoping/

comment 4y ago · link · parent

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)

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

CaryKH made something similar a while ago: https://www.youtube.com/watch?v=95rtiz-V2zM

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

I just use a Python or Node shell as a calculator. It usually works well enough.

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

Priority queues aren't constant time. They're log time.

comment 4y ago · link · parent

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.

comment 5y ago · link · parent

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.

21.

I spent a week being wrong online(theoutline.com ↗)

1 points · by EnderShadow8 · 5y ago · 1 comment

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

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.

24.

What does GCD have in common with leap years?(kamila.akagi.moe ↗)

2 points · by EnderShadow8 · 5y ago · discuss

25.

Good Tests Don't Change(owengage.com ↗)

1 points · by EnderShadow8 · 5y ago · discuss

26.

Probably the best way to simulate block scopes in Python(github.com ↗)

2 points · by EnderShadow8 · 5y ago · discuss

27.

Show HN: WolfECS, the fastest entity component system impementation for the web(github.com ↗)

2 points · by EnderShadow8 · 5y ago · discuss