Code a daily horoscope for the 12 zodiac signs, it needs to be self-sustained (no external ressources), quite randomized but fixed by zodiac sign for each day.

It needs to extract three "variables" from 1 to 3 :

  1. love
  2. work
  3. money

Each one ranked from 1 to 3.

Ex. of variables that can be used (vars fixed for a day or more, can be extended) :

  • Year
  • Month
  • Day
  • Day of week
  • Math.PI
  • Zodiac signs order (from 1 to 12)

Python, 106 chars

import time,zlib
for i in range(12):n=zlib.crc32(time.strftime('%%Y%%j%d'%i));print 1+n%3,1+n/3%3,1+n/9%3

Calculates the CRC of a string made up of the current year, day of year, and zodiac sign. Grabs some bits of the result for the horoscope.


From SO : "Add year+month*11+day*13+sign, feed this in as a seed to your local PRNG. After that you can either generate one "next random number" mod 27, extracting your 3 3s from there, or run it three times mod 3."


Not the answer you're looking for? Browse other questions tagged or ask your own question.