PDA

View Full Version : Christmas Challenge: Day 3



Chippiewill
03-12-2011, 12:10 PM
Today's challenge is a little bit different, as you may be able to tell by the differing forum there will be some coding going on today. Nothing too complex however.

Simply, you must create a PHP script that can create a 1000 digit long pseudo-random number, you may not use any randomizing functions or hashing functions and the script must be self contained. The number must be generated and not pre-defined. Some ways to create a pseudo-random number:

Product of time of day, date, and other frequently changing system variables. Points for creativity and for the amount of entropy the number has. In order to test the entropy I will be taking three runs of the script and seeing how far ZIP archiving will compress it. If the data is completely random then there will be no compression. Using pre-established formulas to generate pseudo-random numbers is allowed however will be severely penalised.

Final entries this time tomorrow, I will try and have the winner of the VIP decided early evening.

Note: This is not an official Habbox Competition.

twinart
03-12-2011, 01:02 PM
OMG! This is hard. Good luck to all who're joining.

Dentafrice
03-12-2011, 01:19 PM
Not sure how to submit.. in private or on here? Here's the code:

http://pastie.org/2959651

Chippiewill
03-12-2011, 03:03 PM
Not sure how to submit.. in private or on here? Here's the code:

http://pastie.org/2959651
Yes please post in the thread, unfortunately you're not allowed to use hashing functions (Unless you actually made the function yourself..)

Dentafrice
03-12-2011, 05:27 PM
Hmm, okay. You said no hashing functions, here it is again but with an encoding function, base64.

You're not a programmer so I wouldn't expect you to understand thesillinessof your hash rule. Hashes are no where near random so it wouldn't be spoiling the competition. Every hash with the same value is the same.. hey will be MD5'd the same every time, no randomization there.

Base64 is encoding, not hashing.. and that wasn't in your rules.

I'd figure with a competition such as this, you would have got a real programmer to come up with the rules.

http://pastie.org/2960590

Chippiewill
03-12-2011, 07:52 PM
It wasn't the randomness of the hash function I was worried about, it was the lack of resemblance between the hash and the value used to generate the hash, makes it too easy, in hindsight I should have asked someone a bit more wiseup about the rules but it was a bit of an afterthought.

Dentafrice
03-12-2011, 09:00 PM
Anyways, agree that my Base64 method is acceptable?

Chippiewill
03-12-2011, 09:10 PM
Anyways, agree that my Base64 method is acceptable?
Technically it's against the intention of my rules but I'll let it slide. No bonus points for creativity however.

Dentafrice
03-12-2011, 09:18 PM
Haha seriously? I give up on you. You're a non-programmer judging a programmer's work, I don't see how you could determine creativity.

Would you enter the competition? I'd love to see yours.

What's creativity to you? Using a random number to generate a pixel filled bitmap image, pulling a certain section out, analyzing the pixel's color attributes based upon the random colors that were assigned and using that to create a number?

I believe your tests should calculate the actual randomness of it. Run tests for like 100 digit numbers, 1000 times. Calculate how many times the numbers get within like 3 of each other. Give that a percentage.

Your method of creativity is just stupid. Trust me ;) Oh how the D&D section has went down. Be thankful that you wasn't an original 56er.

Chippiewill
03-12-2011, 09:21 PM
I believe your tests should calculate the actual randomness of it. Run tests for like 100 digit numbers, 1000 times. Calculate how many times the numbers get within like 3 of each other. Give that a percentage. Compress-ability is a test of randomness.


You're a non-programmer judging a programmer's work,
Not strictly true, I may not post in the D&D forum often and I'm certainly not an avid coder, however I have worked on web projects for my game servers.

Dentafrice
03-12-2011, 09:33 PM
And that means anything? Like I said.. I'd like to see you enter something "creative".

This is a logic experiment for generating a RN. Creativity really doesn't play into it, logic does. Logic and true randomness.

Like I said, enter :)

Chippiewill
03-12-2011, 10:22 PM
I don't have time to write a script but I'd probably do something like:

Generate time() and microtime(), raise time() to the power of microtime()*10^-(Length of microtime) store as $n1, repeat again but multiply microtime by it's second non-zero digit then store as $n2, repeat but multiply microtime by it's last non-zero digit store as $n3, multiply these all together to make $n4, convert all these to binary, XOR them then store as $fnum, convert $fnum back to base_10, choose central 10 digits and append them to final number, repeat 100 times. Would probably have a bias towards zero due to XOR, I'd also have to manually xor the numbers rather than use "^" as it's technically an encryption function.

Dentafrice
03-12-2011, 10:23 PM
And that's creative?

Chippiewill
03-12-2011, 10:24 PM
I didn't use an easy peasy encoding function to change my non-random integer into a pseudorandom one.

Dentafrice
03-12-2011, 11:46 PM
You still used time and micro time, the base of mine. So in regards, they both do the same thing from the same initial seed ;)

Chippiewill
04-12-2011, 12:49 PM
That I wasn't bothered about, regardless. Considering you're the only entry you still win. Which colour VIP would you like?

Dentafrice
04-12-2011, 05:23 PM
I couldn't take it from you, I've been a real butt to you. Either buy it for yourself from me, or buy it for me and me not know about it haha. Whatever color, I don't care :)

HotelUser
04-12-2011, 06:02 PM
[@]@Dentafrice[/@]

Okay first of all as you said he's a non-programmer so maybe you should have humoured him a little bit with his rules and allowed the terminology conflict to slide, because he's trying to do something fun here and if you're only going to put him down by being cynical you're only ruining it.

Second I don't understand why you've pressured him into posting what he would have done just to tell him it's not very creative. I'm not sure how he's validating the scripts by compressing them, but from a general standpoint your script to generate a psudorandom number wasn't super creative either.

Dentafrice
04-12-2011, 06:14 PM
You're not understanding that logical applications such as PRNGS, OCRs, and things of that nature are not "meant" to be creative. That is why I was making fun of him for a "creative" programming competition.

Programming is logical, not an art project.

Chippiewill
04-12-2011, 07:22 PM
I'm not sure how he's validating the scripts by compressing them
Compression is often used to check how random data is because non-random data should be incompressible. This is because procedural generators eventually loop back round or have repeats which is how most compression formats work, (Locating repeats and storing the location of them instead of storing two copies of the same thing). For example if you kept appending time stamps one second apart then a majority of the time stamp would be repeated each iteration.


You're not understanding that logical applications such as PRNGS, OCRs, and things of that nature are not "meant" to be creative. That is why I was making fun of him for a "creative" programming competition.

Programming is logical, not an art project.
The purpose of the competition was to show people how difficult it is to create random data, I was hoping that people would make scripts without the use of hashing or encryption or encoding to make it challenging and then to use unique ways of generating the numbers, and then to tinker around with it until it becomes fairly incompressible.

Want to hide these adverts? Register an account for free!