Does anybody here program with opengl before? If so how do you stop a light source from going through the surface?
Does anybody here program with opengl before? If so how do you stop a light source from going through the surface?
That sounds crazy. My professor also sticks pretty tightly to that book (though I think the book uses red-black trees and we had AVL) but he's doing it in 3 months, and with one final test.Doing a 5-week course entirely based on the Introduction to Algorithms, 3rd Ed, all at a self-study level, with two tests (one per chapter) twice a week. Shit is fucked.
Interviewed a candidate today for a JavaScript Entry Level position and I had to tell him what global/scoped variables are and how to define them.
That literally was the first thing and originally I hesitated to ask that cause why else would someone apply to a position like that. Far too basic, well guess not.
Okay so I just got a new MBP from my company. First time owning an OSX machine. What are some must have developer apps or even general utility apps? Just looking for ways to improve my workflow. I already have iTerm2, homebrew, and a couple IDEs but that's it. Mostly Android development.
That sounds crazy. My professor also sticks pretty tightly to that book (though I think the book uses red-black trees and we had AVL) but he's doing it in 3 months, and with one final test.
Hang in there
If it helps, Youtube was my best friend so far for this course. Almost everything in the book has a nice and intuitive video that explains/shows what's going on in a couple of minutes.Every paragraph and equation.
The problems I had the hardest time with though are those that treat the algorithms/structures as a black box and ask you to write another algorithm that uses them, so understanding the material doesn't really help there.
Okay so I just got a new MBP from my company. First time owning an OSX machine. What are some must have developer apps or even general utility apps? Just looking for ways to improve my workflow. I already have iTerm2, homebrew, and a couple IDEs but that's it. Mostly Android development.
Yeah it's basically a riddle or a brainteaser and that's why it's such a wildcard. Each homework assignment had on average one or two such questions. Still, they usually give us the expected time and space complexity to shoot for, which more than once was a big enough hint to give me the answer outright.As in "design an algorithm to solve this problem"?
On the algorithm courses I've taken, there haven't really been many applied/creative exercises like that unfortunately. It's pretty much been about analysing and following well-known algorithms. I would think carefully before putting that sort of problem on an exam though, it has the same sort of issue as using a brainteaser question in a job interview - some will have a flash of inspiration on that day and some won't.
Those are pretty tough. I have to read up on heaps because I've pretty much forgotten about them.As long as the exam stays at around that level I'll hopefully be ok. It's hard but doable
A bit of a cop out but how an array + an int and a flag, if the flag is set to true then use the int instead of the array, and reset the flag back to false every time something in the array is changed after a reset.Those are pretty tough. I have to read up on heaps because I've pretty much forgotten about them.
Here's a fun brainteaser. Multiple people I've given it to have insisted it can't have a solution, but it does. There's no funny business, no assumption made about the data, and it doesn't require knowledge of any complex data structure. The implementation is actually dead simple. Still took me a good while to find the answer.
Give a data structure that behaves like a fixed size array of size n (that is to say, O(1) to read and write any index) but additionally allows resetting all of the data to arbitrary value k in O(1).
A bit of a cop out but how an array + an int and a flag, if the flag is set to true then use the int instead of the array, and reset the flag back to false every time something in the array is changed after a reset.
A bit of a cop out but how an array + an int and a flag, if the flag is set to true then use the int instead of the array, and reset the flag back to false every time something in the array is changed after a reset.
blah.set(1, 1)
blah.reset(0)
blah.set(0, 1)
print blah.get(1)
Bro, spoilers!stuff
How do I spoiler code tags?
This probably isn't what you're after but I think I have a working solution at least. Totally got nerd sniped by that challenge :'(
http://ideone.com/wyR43I
SpecialArray<int> test = new SpecialArray<int> (0, 4);
test.Set (0, 999);
test.SetAll (14);
test.SetAll (16);
test.Print (); // 999, 16, 16, 16 - oops.
Yep, micro-optimization tricks do not turn O into O(1).Okay, so instead of using one boolean flag like I tried before, use an "array" of booleans in the form of a binary string. You can turn all of them off in O(1) using &&0 and also turn a single bit on in O(1) with ||(<<shift^x 1)
Though I guess this isn't possible with n that's too big..
All the operations are O(1), so it'd be a solution, but it doesn't work. You thought it works because the structure's Get() modifies the structure, and your test code printed the full contents of the structure after every operation, in fact performing a O cleanup sweep into the structure. If you remove the prints from the test code:
Code:SpecialArray<int> test = new SpecialArray<int> (0, 4); test.Set (0, 999); test.SetAll (14); test.SetAll (16); test.Print (); // 999, 16, 16, 16 - oops.
When you get the idea for the correct solution, you won't need an implementation to know it works. I warmly recommend working it out on paper. I never manage to think about structures correctly otherwise.
That's what chainsawkitten proposed earlier (in a now edited post), and I responded:
That's what chainsawkitten proposed earlier (in a now edited post), and I responded:
http://www.neogaf.com/forum/showpost.php?p=170046422&postcount=12927
It's actually a good idea, reasonable and would work in practically all circumstances, but theoretically doesn't satisfy the conditions unless you were to figure out some way to handle the overflow situation in O(1).
For the impatient, an optional hint about how to approach the solution (= what to solve first).
Ignore the O(1) perf requirement for read/write, and just figure out how to do a data structure that has the O(1) reset.
So there must be another solution. Very slight additional hint:I can do that by itself but my solution does not lend itself to the second as it relies on propogating information through a tree.
Android Tool is pretty neat. Yeah, you can capture screenshots and videos from Android Studio, but Android Tool is a nice dedicated app for grabbing a quick capture.
As far as just OS tools go, Better Touch Tool will give you Windows Snap-like features. This is coming in the next OSX update natively, but BTT is so customizable and you need to get it now. You can customize other things too, like multitouch gestures, but I haven't messed with that.
Caffeine is a nice little utility that just acts as a quick toggle to keep the screen/computer from sleeping.
I think BTT and Caffeine are both on the Mac App Store if you'd rather get them from there.
Forklift is a brilliant file manager. I wish there was an equally good one for Windows, but there I have to settle for FreeCommander. The stock Finder is not as bad as Windows Explorer, if you put it permanently in column mode and get used to it, but Forklift is easily worth the cost.
Skim is a PDF reader, handier than Preview for reading books and the like. Has a proper fullscreen (fullscreen borderless window) mode so you can instantly cmd-tab into it and back from other apps, as opposed to using OS X' built-in fullscreen functionality which is garbage.
To be effective with OS X' UI, you have to have substantially different habits than in Windows (but I find it's somewhat nicer when you do develop those habits). OS X' minimize does not interact well with the rest of the windowing system. My suggestion for a power user is to never use it; it might be okay for casual users who don't use the more powerful windowing features. The thing to do is to leave everything open and visible (apps and windows) and then just switch to the one you want using cmd-tab, cmd-' and Mission Control features. Hide (cmd-H) is nice for putting an entire app out of sight and it doesn't take the app off the cmd-tab stack. In Mission Control preference panel -> Hot Corners, assign "Mission Control", "Application Windows" and "Desktop" to three corners of the screen that are easiest to swing the mouse at. This lets you do combos like cmd-tab into an app while throwing the mouse cursor into a corner to get all that app's windows to pick from. You can also drag files while activating the hot corners or cmd-tabbing, which is all kinds of useful.Also, is there a reason I can't alt-tab to minimized windows? They show up in the alt-tab popup screen, but they won't open. It's frustrating having to mouse over to reveal the dock, just to open it back up. I don't think I've ever encountered this behavior in a Linux distro or Windows.
To be effective with OS X' UI, you have to have substantially different habits than in Windows (but I find it's somewhat nicer when you do develop those habits). OS X' minimize does not interact well with the rest of the windowing system. My suggestion for a power user is to never use it; it might be okay for casual users who don't use the more powerful windowing features. The thing to do is to leave everything open and visible (apps and windows) and then just switch to the one you want using cmd-tab, cmd-' and Mission Control features. Hide (cmd-H) is nice for putting an entire app out of sight and it doesn't take the app off the cmd-tab stack. In Mission Control preference panel -> Hot Corners, assign "Mission Control", "Application Windows" and "Desktop" to three corners of the screen that are easiest to swing the mouse at. This lets you do combos like cmd-tab into an app while throwing the mouse cursor into a corner to get all that app's windows to pick from. You can also drag files while activating the hot corners or cmd-tabbing, which is all kinds of useful.
Like minimize, I also essentially never use the Dock, and hide it to one side of the screen.
Give a data structure that behaves like a fixed size array of size n (that is to say, O(1) to read and write any index) but additionally allows resetting all of the data to arbitrary value k in O(1).
How aboutstoring the data in a hash map, keys being the indices. Also store a "default" value, which will be used if a key is looked up that doesn't exist. This way, the reset is simply to set the map to an empty map and update the default value.
So it's something like this in practice:Give a data structure that behaves like a fixed size array of size n (that is to say, O(1) to read and write any index) but additionally allows resetting all of the data to arbitrary value k in O(1).
a = [1, 7, 2, 4, 1] // some data storage/structure
// 1-index ordering
a.get(3) // returns 2
a.reset(5) // a should be perceived as [5, 5, 5, 5, 5]
a.get(4) // returns 5
I had a similar idea as you can see, but no O. I think.That has an O reset.
Yes, while keeping every operation in constant time.So it's something like this in practice:
Sorry, but not initializing the data structure would only move the work to individual writes which would then be O.If that's so . . . I have an idea.
...
I had a similar idea as you can see, but no O. I think.
Here's a fun brainteaser. Multiple people I've given it to have insisted it can't have a solution, but it does. There's no funny business, no assumption made about the data, and it doesn't require knowledge of any complex data structure. The implementation is actually dead simple. Still took me a good while to find the answer.
Give a data structure that behaves like a fixed size array of size n (that is to say, O(1) to read and write any index) but additionally allows resetting all of the data to arbitrary value k in O(1).
This nerdsniped me hard, but I think I got it now:
http://pastebin.com/eTfWUFi1
That was what I had meant. AFAICT this solution is, in fact, constant time. The only work to be done during the reset isMy take: Just create a new hash map upon a reset.
Yep, that's it. Fun, right?
(Out of curiosity - did you use the hints, and how much time did this end up taking?)It's not every day that you get to use arbitrary/random data to drive program logic and get a correct result at the end.
Like I said to hateradio, in a hashmap implementation where the structure initialization is O(1), the individual writes are inevitably O so it's still no good as a solution to the original problem.That was what I had meant. AFAICT this solution is, in fact, constant time. The only work to be done during the reset is ...
Like I said to hateradio, in a hashmap implementation where the structure initialization is O(1), the individual writes are inevitably O so it's still no good as a solution to the original problem.
https://wiki.python.org/moin/TimeComplexity
Like I said to hateradio, in a hashmap implementation where the structure initialization is O(1), the individual writes are inevitably O so it's still no good as a solution to the original problem.
https://wiki.python.org/moin/TimeComplexity