b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » Message 9398027

# 2012 Olympics money saving idea

No need for big expensive stadiums
(, Mon 27 Apr 2009, 11:55, archived)
# get this on Dragon's Den asap!
adn they can also generate the power to run the lights too!
(, Mon 27 Apr 2009, 11:56, archived)
# It would be much more entertaining this way.
They could slowly increase the speed. Anyone who couldn't keep up would fall off the back, preferably into a pit of spikes.
(, Mon 27 Apr 2009, 12:02, archived)
# Sucks to be the guy that can't keep up.
That is exactly the first thing I thought of when I saw the pic.
(, Tue 28 Apr 2009, 5:46, archived)
# oooooh
Bit racist?
(, Tue 28 Apr 2009, 17:32, archived)
# hahahaha
this is superbly done. woo
(, Mon 27 Apr 2009, 11:56, archived)
# this is awesome :)
(, Mon 27 Apr 2009, 11:56, archived)
# 12 billions to make that!
(, Mon 27 Apr 2009, 11:57, archived)
#
BREAD NOT CARNIVALS!
(, Mon 27 Apr 2009, 11:57, archived)
# ... which doesn't seem to exist any more... or I'm confused in the head
anyway - I agree; the money set aside for the Olympics should be redistributed as international aid.
(, Mon 27 Apr 2009, 12:02, archived)
# Bread and circuses? ("panem et circenses" -- Juvenal)
(wikipedia), but you might have been thinking of something else...
(, Mon 27 Apr 2009, 14:04, archived)
# *waits for it to malfunction*
*waits*
*waits*
*waits*
(, Mon 27 Apr 2009, 11:58, archived)
# :)
(, Mon 27 Apr 2009, 11:58, archived)
# Very clever.
(, Mon 27 Apr 2009, 11:58, archived)
# Wonderful!
(, Mon 27 Apr 2009, 11:59, archived)
# That's just crazy enough to work. Quick, phone up Sebastian Coe
and call him a cunt
(, Mon 27 Apr 2009, 11:59, archived)
# That's SIR cnut to you!


(, Mon 27 Apr 2009, 12:01, archived)
# Hahaha
(, Mon 27 Apr 2009, 12:01, archived)
# Haha!
Excellent work :D
(, Mon 27 Apr 2009, 12:00, archived)
# :D
brilliant
(, Mon 27 Apr 2009, 12:01, archived)
# I like the thought
that if one of them didn't run fast enough they'd fall off the back
(, Mon 27 Apr 2009, 12:02, archived)
# haha!
Needs a big brake for comedy flying-athlete purposes :)
(, Mon 27 Apr 2009, 12:02, archived)
# yes!
(, Mon 27 Apr 2009, 12:03, archived)
# ace!
(, Mon 27 Apr 2009, 12:04, archived)
# hahaha excellent
tj: anyone good at PHP? I need a function to generate 5 (say) random unique numbers
(, Mon 27 Apr 2009, 12:07, archived)
# 25
163
988
10333
1236500983

Done
(, Mon 27 Apr 2009, 12:09, archived)
# cor
ta

*breaks website*
(, Mon 27 Apr 2009, 12:09, archived)
# that's Numberwang!
(, Mon 27 Apr 2009, 13:00, archived)
# Feel free to change rand() to the random function of your choice.
$numbers = array();
while (count($numbers) < 5) $numbers[rand()] = count($numbers);
$numbers = array_flip($numbers);
(, Mon 27 Apr 2009, 13:28, archived)
# clevar
(as long as range of my_rand >> 5, and don't even think of using it to generate a big permutation :-)

EDIT: Haaang onn... I don't think that works? What if rand() does return the same result twice: you'll get two entries in $numbers with the same value (of count), and then array_flip will choose the later one, and count($numbers) will now be 4. Surely?

I think you want:

$numbers = array();
while (count($numbers) < 5) $numbers[rand()] = 1;
$numbers = array_keys($numbers);

(But I've never written a line of PHP in my life before, so it's your risk :-) *gazzes Mighty Nibus & benryves*
(, Mon 27 Apr 2009, 14:16, archived)
# Sorry,
you're correct. If using the count() method to set the array value using a random key you'd need to remove the old value first in case of duplicates, which sort of defeats the point of the exercise.
I forgot about array_keys(), your method should work.
(, Mon 27 Apr 2009, 19:08, archived)
# Oh no, another bug:
Nibus, do you wish to treat the chosen values as an ordered sequence, or as a set? If you treat them a sequence, the code snippet is probably still wrong:

The definition of array_keys (http://uk.php.net/function.array-keys) does not specify the order in which it lists the keys.

It is perfectly legal, and (imho) quite likely, for the implementation to always return the keys in some particular order (for example: in numerical order of their hash-values). This would mean that if the five chosen numbers were (say) 32, 55, 12, 10, 65, then they would ONLY EVER be returned in that order. You would simply never ever see 55, 12, 10, 65, 32. In other words: not very random! They might even be sorted numerically. They might be sorted on some platforms, and not on others. It might change when you upgrade to a new version of PHP. Awoooga! Awooga! Don't go there.

I'll have a go at a new code snippet...
...Here:
<?php
$have = array();
$sequence = array();
while (count($sequence) < 5) {
// pick a number
r = rand() % 1000; // (1000, or whatever upper limit)
if (! array_key_exists(r, $have)) {
// it's new, so remember we have it, and add to sequence
$have[r] = 1;
$sequence[count($sequence)] = r;
}
}
// your sequence is now stored in $sequence[0] to $sequence[4]
?>

Fun this, isn't it!
*gazzes MN and br again*
"The late Roger Needham once remarked that ‘optimisation is the process of
taking something that works and replacing it with something that almost works,
but is cheaper’." ["Optimised to fail: Card readers for online banking"]
(, Tue 28 Apr 2009, 11:31, archived)
# That makes sense (though you'd need $r instead of r)!
That said, rand()%$max is generally unwise as it skews the distribution. (rand()/getrandmax())*$max won't skew the distribution. PHP also provides a rand($min, $max) overload - I'm not sure which method that uses, but it's probably easier to use that!
(, Tue 28 Apr 2009, 14:13, archived)
# Gaaaahhhh!!! The more I look, the worse it gets!
PHP:rand() says:  "On some platforms (such as Windows), getrandmax() is only 32768."
WHAT??!!! That's like helpfully including free exploding poisoned razor blades with the programming language you ordered!

"... consider using mt_rand() instead."
It depends what you want the pseudo-randomness for, but if patterning will have a serious bad effect, you might want to use mt_rand() instead. Don't forget to think about how it is seeded, too!
(, Tue 28 Apr 2009, 14:33, archived)
# hahahaha
(, Mon 27 Apr 2009, 12:35, archived)
# Grand!
(, Mon 27 Apr 2009, 12:35, archived)
# marvellous
(, Mon 27 Apr 2009, 12:54, archived)
# Pfft
Fab!
(, Mon 27 Apr 2009, 13:26, archived)
# fantastic
and really well done......wooooooooo:)
(, Mon 27 Apr 2009, 14:17, archived)
# patent it, and you're on the fast track for the big money
*cough*
(, Mon 27 Apr 2009, 15:08, archived)
# SPANG
(, Tue 28 Apr 2009, 17:54, archived)
# I wonder if it would work with pole vaulting.
WOOOOOOO!
(, Mon 27 Apr 2009, 16:30, archived)
# And
fit an alternator to the end to help with the energy crisis.
I reckon that's a winner.
(, Mon 27 Apr 2009, 17:36, archived)
# ha ha ha
it looks like they're running on bacon :D
(, Mon 27 Apr 2009, 19:58, archived)
# Hahaha,
they should stop it suddenly, and whoever flys furthest, wins.
(, Mon 27 Apr 2009, 20:57, archived)
# superb work :D
(, Tue 28 Apr 2009, 0:43, archived)
# last one to fall off wins!
have a big pool of gunge behind aswell

Mr Blooby and Noel Edmunds could present the whole thing.

Ace.
(, Tue 28 Apr 2009, 12:46, archived)