[Challenge] Colours - 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] Colours (/showthread.php?tid=4980) |
[Challenge] Colours - Wolskie - 02-23-2010 The challenge here is to create a script in Ruby (or any language you like) That will output the string "Hello World" In several different colours. The output should look something like: Hello World! Hello World! Hello World! Hello World! Hello World! Post your code and explain how it works. RE: [Challenge] Colours - uber1337 - 02-24-2010 Well in python there is a module called termcolor That allows you to do this. It is has a very simple function that takes two arguments, the string and the desired colour. Besides it's other functions, it lets you print in grey, red, green, yellow, blue, magenta, cyan, white. Here is my script. Code: from termcolor import * RE: [Challenge] Colours - Wolskie - 02-25-2010 (02-24-2010, 12:52 PM)uber1337 Wrote: Well in python there is a module called termcolor That allows you to do this. I dare you to do this without a library. =) RE: [Challenge] Colours - uber1337 - 02-25-2010 Lol FINE! Code: """ RE: [Challenge] Colours - Wolskie - 02-25-2010 Very nice, I'll post my solution later tonight |