@Geobits Ahh, but my answer works in better than O(1) time.
> finds the sqrt by integer ADDITION from the number until we reach the correct number. This takes a long time since we wait for integer wrap-around. Because of this, it actually takes less time for larger numbers. For the sample output, it took 20 seconds.
I'm sure I've seen worse, but it is pretty bad. I half-heartedly tried to determine complexity, but gave up and called it O(big). — GeobitsFeb 28 '14 at 13:55
Let's see. We iterate from n to 2^31 - 1, then iterate over 2^31 negative integers, then finally sqrt(n) integers. So that should make it take 2^32-1-n+sqrt(n). So apparently my time complexity is sqrt(n) - n plus some constant... not a sustainable complexity. Hmm.
Let's say I have an O(n!) algorithm and I want to make it O(1). I first take b as my bound, then compute b! and n!, busy-loop for b!-n!, then do the actual algorithm and return.
Naturally you have to account for time complexity in computing n!.
long factorial(int n){return factorial_(n, 1);} long factorial_(int n, long acc){return factorial_(n - 1, acc * n);} Assuming tail-recursion of course. O(n). But let's make it O(1). long factorial(int n){long upperBound = factorial_(20, 1); /* 21! overflows long */ long result = factorial_(n, 1); long waitAmount = upperBound - result; for (long _ = 0; _ < waitAmount; _++); }
@Justin Whoops that's not O(1) (for a tight big-Oh). It takes longer for smaller values...
long factorial(int n){final long upperBound = 20; /* 21! overflows long */ long result = factorial_(n, 1); long waitAmount = upperBound - n; for (long _ = 0; _ < waitAmount; _++); }
@Justin Forgot to return: long factorial(int n){final long upperBound = 20; /* 21! overflows long */ long result = factorial_(n, 1); long waitAmount = upperBound - n; for (long _ = 0; _ < waitAmount; _++); return result; }
I think if I'll ever be in a startup, I'll push for a functional programming language. Perhaps Clojure, as it can access Java. But I foresee the future as extreme parallelism. Clojure is supposed to be good at that. Functional programming languages are supposed to be good at that. The programmer doesn't even have to think about the parallelism; it's taken care of for her.
Why do I keep learning different languages instead of C#! I've wanted to learn C# for quite a while now, but I never do...
Is it possible to run a terminal command from within Vim? So if I'm working on a Julia script, do something like julia thisfile.jl from within Vim and see the STDOUT output?
Come to think of it, I had original done the aliases so that I could use 0.3 and 0.4 simultaneously. But now 0.4 is released, so I'll just put that in my path and forget about 0.3.
Hm, I added it to my path but it doesn't seem to want to find it.
Hooray. The CS department at my school has Java 8 installed. Last I checked it was Java 6.... But this means that when I take the class which involves coding in Java, it will be easy, instead of a huge pain.
Your example sentences confuse two different problems.
For nouns that are plural (such as "boys"), the possessive formed in writing by adding an apostrophe after the plural -s. This is pronounced the same as the plural and the singular possesive:
The boys' books [boys' sounds like boys]
Fo...
The most useful rule — and the most general and the easiest to remember — is simply that you add ’s whenever you actually say an extra /əz/ at the end when forming the possessive, compared with how you say the non-possessive version. Let your own ear be your guide. That’s all there is to it. No ...
@haneefmubarak This interpretation of cops and robbers is sort of my fault (because I wrote the first challenge assigning the roles this way round). I've first come across the phrase in internet-security capture-the-flag games, where the cops secure a machine (and the flag in the form of some secret) and the robbers break in to steal it. The metaphor I had in mind was along those lines. — Martin Büttner ♦Jun 1 at 10:07
@AlexA. So I decided to check in on my Nethack savefile that I currently have. Turns out I somehow have a BoH... O_o Anyway, I will attempt to continue now if you want to watch
I've heard about CnR for the first time on PPCG, so it makes sense for me. It also seems logical that the "good guys" are the contestants of the main challenge.
Minimum wage in Utah is something like $8. So $8 * 2 * (7 + 2/3) + $8.5 (7 + 2/3) = 187.83. Hopefully you earned more than that (sorry for doing the math...)
@Maltysen That's where I learned the stuff I told Zach.
Now the scary thing is the Burger King my sister went to work at. The manager thought it was really funny to startle the workers who worked the fryers.
speaking of workplace conditions... I have a friend who works in my neighborhoods McDonald's. she was telling me that sometimes the cockroaches (she referred to cockroaches as "the cockroaches" like it was normal) find their way into the lemonade machine
Well, if you remember "sharp square spruce" and "flat friendly fir", it becomes much easier to recognize the different trees by the needles. I'd rather be flat and friendly than sharp and square. I think...