Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
[SOLVED] How Can I Detect if a User's Cookies are Disabled?
Daniel0 replied to Fluoresce's topic in Miscellaneous
That will always go into the else. setcookie() doesn't populate the $_COOKIES super global. -
[SOLVED] How Can I Detect if a User's Cookies are Disabled?
Daniel0 replied to Fluoresce's topic in Miscellaneous
So how do you distinguish between a new user (thus without a cookie) or a person with cookies disabled? -
You're making up things. I never said I rejected gravity (or any other scientific theory). I just said that it cannot be proven true. On the contrary, I accept gravity as a valid theory because of the vast amount of evidence that supports it.
-
AlexWD, science cannot prove anything (though it can disprove). Call your local university, ask to talk to any science professor, it doesn't matter which one because all of them will tell you that. You are right, there are no proof that gravity exists because proving things in science is literally impossible. A law (in science) is synonymous with a theory. The "law of gravity" is a theory describing how we currently believe that two objects attract each other, the so called gravitational force. A theory is the highest status anything can get in science, but even then new information could be unveiled that disproves a theory, any theory. You can show that something is true n times, but unless you can show that it is true the 1+nth time you haven't proven anything. That is the nature of induction. Which n is high enough to say that you've proven it? 1, 10, 50, 10,000,000? Acceptation of a theory is based on inductive reasoning, and that is why it cannot be proven true. We can only accept it as true based on the things we currently know. Science isn't even about proving things. Each time you make an experiment you try to disprove it. Either you fail at it or not. If you fail at disproving it you've shown that in your experiment, the theory was true, but you haven't shown that it's true for all possible experiments. Actually, no, there is not proof that it works/exists either.
-
PHP Challange / Learning Experance - Basic Criptography
Daniel0 replied to GoneNowBye's topic in PHP Coding Help
-
All I was saying was just that requiring proof before you believe something is an unreasonable requirement that ultimately prevents you from believing virtually anything. Science only comes up with theories and disproves theories and hypotheses. Scientific theories are accepted based on past experience and observations. However, unlike with gravity, I have no past experience (or heard of others who did) makes that makes me believe any sort of deity exists. Even if a such deity would appear before me, how would I even verify that it is divine? It could also be the case that I am hallucinating, and the question of how you know whether you are sane or insane is also an interesting question.
-
I take it you don't believe in gravity or any other science then? Pretty much the only thing you can believe in is mathematics.
-
Do potential clients a favor and do not start a hosting service if you do not know anything about server administration. There are enough crap hosts out there as it is.
-
Excellent server administration skills.
-
That's why e.g. the "birthday paradox" is called like it is. Using the above function, [imath]p_{365}(23) \approx 0.5[/imath], so there is just above 50% chance that at least two people will have the same birthday when there are 23 people if all days are equally likely as birthdays and you ignore leap years. It's not a mathematical paradox, but it's the underlying probability theory that is not intuitively clear until you go through the math. The reason why it uses factorials is to get rid of the [imath]\cdots[/imath]. If you have n!, but want to get rid of the last k terms (counting downwards), then you just divide by (n-k)! because of the way you can cancel out factors in a fraction.
-
I believe that is incorrect. Say you have a set of distinct elements [imath]X[/imath] with [imath]|X|=k[/imath]. How many elements do you need to pick before you have a 50% chance of picking the same number again? Let [imath]p_k(n)[/imath] be the function determining the probability of picking a duplicate when selecting exactly [imath]n[/imath] elements. By the pigeonhole principle, you are guaranteed to pick duplicates if you pick [imath]n > k[/imath] elements. When determining the probability, it's easier looking at the opposite in this case: what is the probability that all the elements are distinct (i.e., there are no duplicates)? We'll denote this by [imath]p_k'(n)[/imath] and then [imath]\forall n > k : p_k'(n) = 0[/imath]. Now, when selecting the first element we have all [imath]x \in X[/imath] available, so [imath]p_k'(1) = \frac{k}{k} = 1[/imath]. Next time we have one less, so by the multiplication principle [imath]p_k'(2) = \frac{k}{k} \cdot \frac{k-1}{k}[/imath], [imath]p_k'(3) = \frac{k}{k} \cdot \frac{k-1}{k} \cdot \frac{k-2}{k}[/imath]. Indeed for [imath]n \leq k[/imath]: [math]\begin{split} p_k'(n) &= \frac{k}{k} \cdot \frac{k-1}{k} \cdot \frac{k-2}{k} \cdots \frac{k-n+1}{k} \\ &= \frac{k \cdot (k-1) \cdot (k-2) \cdots (k-n+1)}{k^n} \\ &= \frac{k!}{(k-n)! \cdot k^n} \end{split}[/math] Thus our probability [imath]p_k(n)[/imath] must be given by: [math] p_k(n) = \begin{cases} 1 &\text{if } n > k \\ 1 - \frac{k!}{(k-n)! \cdot k^n} & \text{if } 0 < n \leq k \end{cases} [/math] Then we'll see that [imath]p_{100}(12) = 0.4968[/imath] and [imath]p_{100}(13) = 0.5572[/imath]. This is of course assuming that selecting any number is equally likely to selecting any other number. By the way, what's up with all the line breaks?
-
If it's not crucially important, I would just use a cookie to check if they've clicked it. Sure, it can easily be circumvented, but it will also be much easier on the database.
-
Split it up and use dechex. By the way, you've chosen a really bad format for storing it in. Take for instance this: 11211222. It could be either 11,211,222 or 112,11,222 or 112,112,22. Edit: Ah, never mind. I didn't notice that it was just the way you were outputting it. In that case, just call dechex() on all of them.
-
Instead of relying on randomness, why not create an algorithm that is deterministic. If you develop a good hashing algorithm you could easily use that. Just for reflecting on randomness, there is a sorting algorithm called bogosort. It's extremely simple (and stupid): check if your dataset is sorted, if it isn't, shuffle it and start the algorithm again, otherwise stop. Because shuffling is reliant on randomness, this algorithm has a worst case running time of O(∞); you might never get it sorted. It's the same thing here. There is a chance that finding a unique random number will take unreasonably long time, and there is even the (small) chance that you will never find one. Of course as your collection of bar codes increases in size, this probability becomes larger and larger.
-
Yeah, but there is no more food left.
-
Which you could have tested way faster than the 39 hours between your creation of this topic and your last post. Either way, you're obviously flamebaiting, so this topic is locked.
-
It is. You said yourself you haven't tried it, and the fact that you keep bumping your topic even though you haven't even tried it yourself strongly suggests that you want other people to do it for you. Has it ever occurred to you that you haven't received any responses because this is something you should just do yourself? You can just test if the function does what you want it to just like everybody else.
-
Did you try it? We're not here to research for you after all.
-
A function is like a mini-program within your main program. Something that can have input, output and side-effects just like your main program does.
-
It should be $slot[$RAN_2], etc. You might want to read up on PHP's syntax.
-
Did you try it?
-
[SOLVED] Using the word PHP in a PHP Application
Daniel0 replied to Liquid Fire's topic in Miscellaneous
No, because that would make all programs written to run on Windows derivatives on Windows, but you are not allowed to release Windows derivatives either. -
How about Project Euler? This weekend I've also written a program that solves sudokus and generates random sudokus. I didn't do it in Python, but you could try that.