I say this a a former emacs user now using VS Code.
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.
Of course, if you have a style guide, you should stick to that.
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)))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,
)"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.
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.