And I was inspired by this: Labyrinth Puzzle.
And I was inspired by this: Labyrinth Puzzle.
Last edited by CornedBee; 03-28-2009 at 11:47 AM.
All things begin as source code.
Source code begins with an empty file.
-- Tao Te Chip
Damn... My argument to why I don't understand any of this is... I haven't finished school xP Now make the algorithm for randomness for me >: D
Last edited by CornedBee; 03-28-2009 at 11:39 AM.
Currently research OpenGL
Well that makes for an interesting optimization for large prime number searches. I wonder what percentage of workload it would reduce to first check that a number met that particular criteria.
Last edited by CornedBee; 03-28-2009 at 11:39 AM.
Last edited by CornedBee; 03-28-2009 at 11:40 AM.
All things begin as source code.
Source code begins with an empty file.
-- Tao Te Chip
Hey that's pretty cool, though. Nice one.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Its faster to just check if a number, modulo 6469693230 has a prime remainder, since all prime numbers do.
Last edited by CornedBee; 03-28-2009 at 11:42 AM.
The greatest common factor explanation of this is great
Last edited by CornedBee; 03-28-2009 at 11:43 AM.
>> Its faster to just check if a number, modulo 6469693230 has a prime remainder, since all prime numbers do.
Are you sure about that? Can you elaborate?
Last edited by CornedBee; 03-28-2009 at 11:43 AM.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Yes I'm sure, no I won't elaborate. Well, maybe a little. Specifically, any prime number P modulo a primorial X such that P=> primorial X will have a prime remainder. Obviously it also works for P< X btu then you just check it agaisnt he known primes. This is not a guarantee that the number tested is prime, but it will guarantee it is composite if it fails. It will nto however give you any of the factors of the composite number. The greater the value of X the stronger the evidence for being prime. This method of checking very large primes is an embarrisingly parallelizable method. Since as X grows, it increases teh number of independant checks very quickly. It does however require a very large and comprehensive database of known primes for values of X larger than ~31. The size of the database approaches (X primorial / ln(X primorial)) * sizeof(N) where N is the type of teh storage unit for a single prime. For X = 23 and N is a DWORD its about 46MB, while for 29 its over 1GB, and it grows more rapidly after that.
Last edited by CornedBee; 03-28-2009 at 11:48 AM.
There are seven dwarfs, each one wearing a unique hat. A wind blows off the hats. The dwarfs start running after their hats and each dwarf puts on the first hat that he manages to catch. Eventually every dwarf has a hat again.
What is the probability that exactly six dwarfs are wearing their own hat now?
Greets,
Philip
All things begin as source code.
Source code begins with an empty file.
-- Tao Te Chip
I would say that equals (6!/(6*5!))-1.
Last edited by CornedBee; 03-28-2009 at 11:45 AM.
Right!
Can someone else explain it?
Greets,
Philip
Last edited by CornedBee; 03-28-2009 at 11:50 AM.
All things begin as source code.
Source code begins with an empty file.
-- Tao Te Chip
Oops, I skipped #4, so here it is.
Consider the following program:
Can you come up with an implementation that doesn't use conditionals, i.e. if, for, while, switch?Code:int cmp(int a, int b) { if(a > b) { return 1; } else if(a < b) { return -1; } else { return 0; } }
Greets,
Philip
All things begin as source code.
Source code begins with an empty file.
-- Tao Te Chip
I presume that includes ternary operator, and that this is either C or C++?
Last edited by CornedBee; 03-28-2009 at 11:45 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
--Code:return (a >b)?1:(a<b)?-1:0;
Mats
Last edited by CornedBee; 03-28-2009 at 11:45 AM.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.