|
Xarn posted:no you don't. nobody does. To be clear: I know just enough to know they exist lol. I'd ask somebody smarter if I got into a situation where I had to use them.
|
# ? Jun 14, 2019 23:39 |
|
|
# ? May 17, 2024 01:20 |
|
Xarn posted:no you don't. nobody does. https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/
|
# ? Jun 15, 2019 06:57 |
|
https://web.archive.org/web/20110812023545/http://blogs.oracle.com/jag/entry/transcendental_meditation Related to that, part of why Java's trig functions are so slow is they exactly map their input into the range [-pi/4, pi/4] before using the hardware function to do the rest.
|
# ? Jun 15, 2019 19:35 |
|
if only we used degrees we wouldn't have this problem
|
# ? Jun 16, 2019 07:53 |
|
Why not try the usual horror. open Calculator (not in windows 10 though - they finally fixed it) 4 Sqrt -2 = 0.0000000000000001 -29 (or something similar)
|
# ? Jun 16, 2019 09:38 |
|
TheresaJayne posted:Why not try the usual horror. A non techie friend posted a screenshot on Facebook the other day of him being forced to restart the calculator app due to an update. He captioned it “did they change math??” and I thought to myself “in a sense...yeah”
|
# ? Jun 16, 2019 17:18 |
|
Xarn posted:no you don't. nobody does. I spent an entire summer making some polygonal CSG code robust ie. guaranteeing epsilons for parity checks were within correct thresholds for floating point operations, amongst other things (you have to pay attention to every multiply, add and divide and find some creative algebra to minimize epsilon and pigeonhole the math). Imagine doing 1000 consecutive Boolean intersections on a mesh and trying to keep the result to not be nightmarish. I can confidently say I don’t know a drat thing about floating point numbers, they have terrifyingly unintuitive edge cases. Even ignoring stupid processor issues like using == checks to detect NAN’s. Goreld fucked around with this message at 19:55 on Jun 16, 2019 |
# ? Jun 16, 2019 19:52 |
|
What Every Computer Scientist Should Know About Floating-Point Arithmetic Coming in at a mere 45 pages, this should be top of your summer reading list.
|
# ? Jun 16, 2019 19:59 |
|
What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something.
|
# ? Jun 16, 2019 20:11 |
|
ultrafilter posted:What Every Computer Scientist Should Know About Floating-Point Arithmetic Jesus the text is really small too
|
# ? Jun 16, 2019 20:11 |
|
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. Medium.
|
# ? Jun 16, 2019 21:00 |
|
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. "fritz's post history".
|
# ? Jun 16, 2019 23:54 |
|
PornHub video titles
|
# ? Jun 17, 2019 00:10 |
|
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. Elon Musk Tweet.
|
# ? Jun 17, 2019 00:17 |
|
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. Click-bait, assuming you have an iq above about 30
|
# ? Jun 17, 2019 00:32 |
|
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. Click-ward.
|
# ? Jun 17, 2019 00:54 |
Doc Hawkins posted:What's the word for the opposite of click-bait? Like, a title that makes you incredibly averse to the idea of reading something. Clickcrow
|
|
# ? Jun 17, 2019 12:44 |
|
Soricidus posted:Click-bait, assuming you have an iq above about 30 Are you one of those "advertising doesn't work on me" people?
|
# ? Jun 17, 2019 12:50 |
|
https://twitter.com/jfbastien/status/1139298419988549632
|
# ? Jun 17, 2019 15:44 |
|
The caret is XOR - that’s the issue, right? A fundamental misunderstanding of C operators?
|
# ? Jun 17, 2019 16:15 |
|
Ruggan posted:The caret is XOR - that’s the issue, right? A fundamental misunderstanding of C operators? That's a problem, yes; 2^32 in C is 34, not 2³². There's also the problem that even if it were 2³², if (signed) int is 32 bits, you can't represent (2³²-1) in it, so that comparison is always true and you have an infinite loop. So even if ^ worked the way the author thinks it does, that code is wrong.
|
# ? Jun 17, 2019 16:49 |
|
I've been really impressed with how big I can make Javascript arrays recently. I had to write a script that would do something to all the records in a table and I basically just went ahead and fetched them all. There were some few hundred thousand records Javascript totally dealt with it.
|
# ? Jun 17, 2019 18:18 |
|
The tricky thing about Javascript arrays is that they're implemented separately from key-value stores on objects which can make them far faster, but if you do anything that forces the implementation to deoptimize them, they get really slow.
|
# ? Jun 17, 2019 18:27 |
|
fritz posted:Are you one of those "advertising doesn't work on me" people? Clickbait headlines are to advertising as 419 scam emails are to social engineering. One works on everybody, the other is specifically and deliberately targeting people with poor judgment.
|
# ? Jun 17, 2019 18:57 |
|
Soricidus posted:Clickbait headlines are to advertising as 419 scam emails are to social engineering. One works on everybody, the other is specifically and deliberately targeting people with poor judgment. Clickbait works on anybody, look at this blog post about it
|
# ? Jun 17, 2019 19:49 |
|
I did a small interview for Amazon and apparently failed the coding test? Apparently, it wasn't O notation enough? *edit* The exercise was: Make a function that, given a string with brackets in it returns true if the string has the same order of closing brackets. IE: "{$$[fdasfsa<fdaf>####]%@#}" == True "{$$[ff}fff]" == False My solution was to parse the string and dump the opening and closing brackets into separate arrays, and then loop through said arrays to make sure that the opening bracket array matched the closing bracket array. I'm sure there's a way more clever solution with recursion or some poo poo they wanted, but w/e. FlapYoJacks fucked around with this message at 20:27 on Jun 17, 2019 |
# ? Jun 17, 2019 20:23 |
|
Use a stack and only iterate the string once?
|
# ? Jun 17, 2019 20:43 |
|
That might be asking if the brackets are nested properly. You could push the type of bracket onto a stack when you see an opening brackets and pop off the stack when you see a closing one. Return false early if the popped value doesn't match the current closing bracket and return true if the stack is empty at the end.
|
# ? Jun 17, 2019 20:43 |
|
CPColin posted:That might be asking if the brackets are nested properly. You couls push the type of bracket onto a stack when you see an opening brackets and pop off the stack when you see a closing one. Return false early if the popped value doesn't match the current closing bracket and return true if the stack is empty at the end. Was gonna post exactly this so I'll quote instead.
|
# ? Jun 17, 2019 20:44 |
|
ratbert90 posted:I did a small interview for Amazon and apparently failed the coding test? A stack of open brackets and QuarkJets fucked around with this message at 20:51 on Jun 17, 2019 |
# ? Jun 17, 2019 20:45 |
|
Fair enough. This is the coding horrors thread, and I routinely am a bad programmer.
|
# ? Jun 17, 2019 20:51 |
|
The more important thing than the performance is that your solution doesn't have a problem with a)b(c when it presumably should. That should be obvious to you from the fact that your solution clearly erases inter-ordering differences between open and close brackets.
|
# ? Jun 17, 2019 23:00 |
|
Strip everything except brackets from the string, if it's an odd length fail, then match half the indexes against the opposite using a switch statement.
|
# ? Jun 18, 2019 01:33 |
|
Something like JavaScript code:
|
# ? Jun 18, 2019 01:50 |
|
Nolgthorn posted:Strip everything except brackets from the string, if it's an odd length fail, then match half the indexes against the opposite using a switch statement. Ah your second post makes it clear for me. Only caring about the first and last index solves the problem nicely. I have to wonder, is removing elements from both the beginning and end of an array more expensive than just a single passthrough with a bunch of push()es onto a separate buffer though? Happy Thread fucked around with this message at 02:31 on Jun 18, 2019 |
# ? Jun 18, 2019 02:27 |
|
Dumb Lowtax posted:Ah your second post makes it clear for me. Only caring about the first and last index solves the problem nicely. I want to say almost definitely, yes, but the difference is probably negligible for a single use I think the key is probably working your way towards an answer that is correct first, and then working on optimizing it. They're using code review to suss out how you solve problems, so if you just provide an answer that gives wrong results and offer no further refinement then that's bad.
|
# ? Jun 18, 2019 03:00 |
|
Dumb Lowtax posted:Ah your second post makes it clear for me. Only caring about the first and last index solves the problem nicely. It depends on how the language implements the data structure in question, but you should assume that yes, it's more expensive. The easy way to think about it is that removing an item from the front of an array requires shifting every other element in the array forward one position, so that's O(n) time, whereas pushing or popping from the end of the array doesn't require modifying any of the other elements, so it's O(1). Again, in some cases the underlying data structure works differently and that's not the case; the example I'm familiar with is Python's collections.deque, which allows efficient operations on both ends (at the cost of being more expensive to interact with data in the middle). I want to say that Lisp also uses some form of doubly-linked list as its default sequence type, but I've never worked with the language and could be remembering wrong.
|
# ? Jun 18, 2019 03:59 |
|
Mad Jaqk posted:It depends on how the language implements the data structure in question, but you should assume that yes, it's more expensive. The easy way to think about it is that removing an item from the front of an array requires shifting every other element in the array forward one position, so that's O(n) time, whereas pushing or popping from the end of the array doesn't require modifying any of the other elements, so it's O(1). This, except the opposite. In the worst case it's O(n) for both operations, but in some cases you can just advance a pointer one element and avoid allocating extra memory.
|
# ? Jun 18, 2019 04:08 |
|
QuarkJets posted:I think the key is probably working your way towards an answer that is correct first, and then working on optimizing it. They're using code review to suss out how you solve problems, so if you just provide an answer that gives wrong results and offer no further refinement then that's bad. Yeah, if I had to guess, the interviewers are asking this question for three reasons:
Dumb Lowtax posted:I have to wonder, is removing elements from both the beginning and end of an array more expensive than just a single passthrough with a bunch of push()es onto a separate buffer though? Yes, because (1) the maximum nesting depth is at most half the length of the string and can reasonably be expected to be far less and (2) stacks are a significantly more efficient data structure than strings (unless your language can't do generic data structures without boxing the elements). (a)b{c}
|
# ? Jun 18, 2019 04:16 |
|
|
# ? May 17, 2024 01:20 |
|
Use a pointer at each end of the string and move them towards each other. Stacks? Arrays?! Christ! gently caress!!
|
# ? Jun 18, 2019 04:20 |