For selecting the best dice , a noun, it seems like 5!:2 helps the most.
d1=:' o ' d2=:'o o' d3=:'o o o' d4=:'o o o o' d5=:'o o o o o' d6=:'o oo oo o' d=:6 9$d1,d2,d3,d4,d5,d6 dice=:(<"2)3 3$"1 d dice facerowsrs=: 0 0 0,1 0 0,0 1 0,0 0 1,:1 0 1 facecharsrs=: ' o' facesrs=: 0 2 0,1 0 3,1 2 3,4 0 4,4 2 4,:4 4 4 dicers=: <"2 facecharsrs {~ facerowsrs {~ facesrs onekm=: ' ',' o ',:' ' twokm=:'o ',' ',:' o' threekm=:'o ',' o ',:' o' fourkm=:'o o',' ',:'o o' fivekm=:'o o',' o ',:'o o' sixkm=:'o o','o o',:'o o' 5!:2 ;:'d1 d2 d3 d4 d5 d6 d dice' 5!:2 ;:'facerowsrs facecharsrs facesrs dicers' 5!:2 ;:'onekm twokm threekm fourkm fivekm sixkm dice' 5!:4 ;:'d1 d2 d3 d4 d5 d6 d dice' 5!:4 ;:'facerowsrs facecharsrs facesrs dicers' 5!:4 ;:'onekm twokm threekm fourkm fivekm sixkm dice' 5!:6 ;:'d1 d2 d3 d4 d5 d6 d dice' 5!:6 ;:'facerowsrs facecharsrs facesrs dicers' 5!:6 ;:'onekm twokm threekm fourkm fivekm sixkm dice' Kip's is the simplest and I'll but his style in the final version. (If any of you are interested in timing, you may wish to explain a better option.) Linda -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Ric Sherlock Sent: Thursday, December 01, 2011 6:01 AM To: Programming forum Subject: Re: [Jprogramming] Turkey Roll - Challenge 2 The following is getting away from the actual rules as of the task but is perhaps useful nonetheless ... >From a storage and processing POV, it will be leaner and faster not to store the dice boxed. The boxing is nice for display purposes though so that could be made a separate verb. facerows=: 0 0 0,1 0 0,0 1 0,0 0 1,:1 0 1 NB. row types on faces facechars=: ' o' NB. chars used to draw faces faces=: 0 2 0,1 0 3,1 2 3,4 0 4,4 2 4,:4 4 4 NB. define faces as rows dice=: facechars {~ facerows {~ faces NB. create dice displayDice=: [: smoutput <"2 NB. display boxed di throw=: ] {~ [: ? [ $ [: # ] NB. verb to throw dice toss=: 2 10 throw ] NB. throw 2 dice 10 times sumThrows=: [: +/ [: ([: +/ ,)"2 'o' = ] NB. sum each throw fd=: [: /:~ ({. , #)/.~ NB. calc frequency distribution displayDice dice +---+---+---+---+---+---+ | |o |o |o o|o o|o o| | o | | o | | o |o o| | | o| o|o o|o o|o o| +---+---+---+---+---+---+ displayDice Toss1=: toss dice +---+---+---+---+---+---+---+---+---+---+ |o |o |o o|o | |o o| |o |o o|o | | o | o |o o| o | o | | o | o | | o | | o| o|o o| o| |o o| | o|o o| o| +---+---+---+---+---+---+---+---+---+---+ |o | |o | |o o| |o o|o |o o|o o| | | o | o | o | | o | | o |o o| | | o| | o| |o o| |o o| o|o o|o o| +---+---+---+---+---+---+---+---+---+---+ sumThrows Toss1 5 4 9 4 5 5 5 6 10 7 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm