Write a domino effect
Ruby, 38 (46) characters



e=-&gt;n,k,r{k-=r;'\|'[r]*k+'|/'[r]*n-=k}


This function takes the direction as an integer (1 for right, 0 for left). A function that takes a string is 8 characters longer:

d=-&gt;n,k,r{n-=k;r&lt;?r??\\*k+?|*n :?|*~-k+?/*-~n}


Usage examples:

puts e[10, 5, 1] # or d[10, 5, 'r']
||||//////
puts e[10, 5, 0] # or d[10, 5, 'l']
\\\\\|||||