Chess960 position lookup
Python, 179 chars



i=input()
a=i%4*2+1
b=i/4%4*2
c=i/16%6
d=i/96*5
s='NNRKRNRNKRNRKNRNRKRNRNNKRRNKNRRNKRNRKNNRRKNRNRKRNN'[d:d+5]
s=s[:c]+'Q'+s[c:]
if a&gt;b:a,b=b,a
print s[:a]+'B'+s[a:b-1]+'B'+s[b-1:]


Builds it backwards from the description order so we don't have to count the spaces that are already taken.