Random Problem Challenge
Random Problem Challenge
What should the format of the answer be? Just a number? also many numbers would throw an Exception which one will work?
- sabretooth
- Posts: 61
- Joined: Sun Jul 12, 2009 3:13 pm
- sabretooth
- Posts: 61
- Joined: Sun Jul 12, 2009 3:13 pm
-
- Posts: 20
- Joined: Mon Jun 20, 2011 6:25 pm
Struggling
Guessing there is some trick to this? Fairly sure i have run it for everything in the range -2147483647 to 2147483647 without an error
[Edit] -Scratch That. Was Being Retarded. Can't believe i spent over an hour on something so easy and obvious!!
[Edit] -Scratch That. Was Being Retarded. Can't believe i spent over an hour on something so easy and obvious!!
I've rewritten it in PHp to read it better (I'm more familiar with it).
So I have:
Will it work in PHP too?
And what do I have to look for? I can't get it! But maybe i just don't understand what an exception is...
So I have:
Code: Select all
<?php
function bucketFromRandom($randomNumber) {
$a = array();
for ($i = 0; $i < 10; $i++)
$a[$i] = $i * $randomNumber;
$index = abs($randomNumber) % 10;
return $a[$index];
}
echo bucketFromRandom(2147483648);
?>
And what do I have to look for? I can't get it! But maybe i just don't understand what an exception is...
Many challlenges on this site urge you to learn new things: Computer languages, cryptologic techniques, file formats.meis wrote:I've rewritten it in PHp to read it better (I'm more familiar with it).
So I have:Will it work in PHP too?Code: Select all
<?php ... ?>
...
This one is special to Java (and probably close relatives like C#). It won't work in PHP.