[Challenge] Random - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Ruby and Ruby on Rails (https://www.supportforums.net/forumdisplay.php?fid=55) +---- Thread: [Challenge] Random (/showthread.php?tid=5038) |
[Challenge] Random - Wolskie - 02-25-2010 Here's another challenge. the challenge this time is to create a script/program (any language) that will randomize the contence of an array without using external libries. This must work by: Code: new_array = [1, 2, 3, 4, 5] Post you code and explain how it works. RE: [Challenge] Random - uber1337 - 02-25-2010 Well you can't really be completely random, there needs to be some sort of pattern. This script can take me anywhere from 10 minutes to 2 hours, depends how "random" you want it to be. RE: [Challenge] Random - Wolskie - 02-26-2010 Code: class Array This sorts the array by using a random number generated by rand. Witch is in kernel modual. This should be random enought. ;) RE: [Challenge] Random - uber1337 - 02-26-2010 Wow so ruby has a random module built in? No fair! RE: [Challenge] Random - Jordan L. - 02-26-2010 (02-26-2010, 06:17 AM)uber1337 Wrote: Wow so ruby has a random module built in? No fair! That sir, is why Ruby > Python. RE: [Challenge] Random - uber1337 - 02-26-2010 Lol yes because Ruby coders are too lazy to type Code: import random Wikipedia Wrote:Python has a large standard library, commonly cited as one of Python's greatest strengths, providing pre-written tools suited to many tasks. This is deliberate and has been described as a "batteries included" Python philosophy. The modules of the standard library can be augmented with custom modules written in either C or Python. Recently, Boost C++ Libraries includes a library, Boost.Python, to enable interoperability between C++ and Python. Because of the wide variety of tools provided by the standard library, combined with the ability to use a lower-level language such as C and C++, which is already capable of interfacing between other libraries, Python can be a powerful glue language between languages and tools. RE: [Challenge] Random - Wolskie - 02-26-2010 (02-26-2010, 06:50 AM)uber1337 Wrote: Lol yes because Ruby coders are too ] Ruby doesn't ;_; RE: [Challenge] Random - Canoris - 02-26-2010 LOL, I could give you a python script.... but I don't think you'd want that.... lol. RE: [Challenge] Random - Wolskie - 02-26-2010 (02-26-2010, 05:00 PM)Μαύρο Wrote: LOL, I could give you a python script.... but I don't think you'd want that.... lol. Go for it RE: [Challenge] Random - Canoris - 02-26-2010 Basically cheating... but who cares! :p Code: import random |