9,315 reputation
1637
bio website
location
age 33
visits member for 4 years, 6 months
seen yesterday
C:\>If you're happy and you know it, syntax error!
Syntax error

C:\>If you're happy and you know it, syntax error!
Syntax error

C:\>If you're happy and you know it, then you really ought to show it.  If you're happy and you know it, syntax error!
Syntax error

1d
comment How to determine if set of ordered coordinates form a simple curve?
@so.very.tired It should be 4 times faster, because everytime you're running through the list, you do so twice as fast, and this compounds with the nested loop.
1d
comment How to determine if set of ordered coordinates form a simple curve?
@DocBrown I see what you mean by that now. Altered answer.
1d
revised How to determine if set of ordered coordinates form a simple curve?
added 84 characters in body
1d
revised How to determine if set of ordered coordinates form a simple curve?
added 111 characters in body
1d
comment How to determine if set of ordered coordinates form a simple curve?
@DocBrown No. If I did that, p3 and p4 would always be the next line segment, but yes in that p2 succeeds p1 and p4 succeeds p3.
1d
answered How to determine if set of ordered coordinates form a simple curve?
1d
comment How to determine if set of ordered coordinates form a simple curve?
I'll write an answer I suppose. One moment.
1d
comment How to determine if set of ordered coordinates form a simple curve?
The idea is simple. You're guaranteed that there are two line segments between two points which intersect if it isn't simple. So you check every combination of two line segments O(n^2) to see if they intersect and if they don't, you know it is simple. There may even be a way to do it in better time than O(n^2).
2d
comment How to determine if set of ordered coordinates form a simple curve?
I'm fairly sure you could easily perform a O(n^2) algorithm that cross checks each line segment with each other line segment for an intersection. At that point, break and you know it is not simple. If it were closed, you'd simply have to check the start and end points as well.
May
20
comment Short circuit evaluation, is it bad practice?
It should be noted that repeated if blocks checking if an instance is null in a short-circuit evaluation should probably be rewritten to perform that check only once.
May
19
comment How do I communicate to a colleague that their code does nothing?
@gbjbaanb Ouch. Totally unnecessary burn, man.
May
19
comment How do I communicate to a colleague that their code does nothing?
Oh, but "your code sucks!" is so much more fulfilling...
May
15
reviewed Approve Refactoring long methods with a lot of cyclomatic complexity
May
15
comment How to improve understanding of the code written by someone?
Short answer: practice.
May
14
comment Is it possible to Style a csv file?
@quangphan I suggest you take a look at Apache Poi for creating excel documents in Java. And excel documents, unlike csv, you can format as you wish.
May
13
comment “Sweep” a vector of pointers
items.begin()+i-deleted++ is nightmarish. Adding numbers to an iterator is scary at best, not to mention that it is still O(N^2) time.
May
13
comment “Sweep” a vector of pointers
@Wolf It's easy to forget that even if you don't see it being done, that doesn't mean that it is an operation that is O(1).
May
11
comment Regular expression to match strings composed of ABAs or ABs
In summary, this isn't possible without matching both and picking the larger match (at least not without having boundaries). However, you shouldn't consider this such a bad thing in terms of performance, since the two newly created rules become simpler and hence easier to parse and execute.
May
11
comment Regular expression to match strings composed of ABAs or ABs
@Snowman That isn't what greedy means. Greedy is considered to be optimized because you just consume without worrying about backtracking.
May
11
comment Regular expression to match strings composed of ABAs or ABs
Not sure what you mean by that. Using just + and *, by default regular expressions use greedy matching, meaning that when confronted with an ambiguous choice of consuming more or passing to the next rule, it will consume. Though this doesn't necessarily mean it will maximize results.