Dice has a little problem that was caused by the difficulty in transmitting the result without the code that creates it. I would appreciate it if you would correct and reply to this message so the dice look like this (sort of). The two and the three should be on a diagonal from upper left to lower right:
----T---T---T---T---T---┐ │ │o │o │o o│o o │o o│ │ o │ │ o │ │ o │o o│ │ │ o│ o │o o|o o │o o│ L---+---+---+---+---+---- Please add the following lines to your script and then it will be easy for the reader to see that it has complied with the rules. Assert is a wonderful addition for this and future challenges! dice toss toss fd c 0 0 0 3 = 4!:0 ;:'dice toss c fd' Also, you couldn't follow my rules and I couldn't either! I wanted a niladic function (no arguments) which is what you wrote. But it always returns the same result. A monadic function would be better in the long run, but it would be nice also if someone could follow the original instructions. I could write it so Toss 6 gave the new tosses each time. Just because there is one entry, please do not hesitate to submit your thinking and adapt your ideas to this if you wish. It would be nice to give another person credit if you incorporate their idea into yours. This was designed so that there are many ways to create your dice and toss them. The frequency distribution is rather standard and may not allow much adapting. A very nice early entry! #1 Ric Sherlock -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Ric Sherlock Sent: Thursday, December 01, 2011 12:19 AM To: Programming forum Subject: Re: [Jprogramming] Turkey Roll - Challenge 2 facerows=. 0 0 0 , 0 1 0 ,: 1 0 1 NB. 3 row types on faces facechars=. ' o' NB. chars used to draw faces faces=: 0 1 0,1 0 1,1 1 1,2 0 2,2 1 2,:2 2 2 NB. faces in terms of rows dice=: <"2 facechars {~ facerows {~ faces NB. draw faces of a dice throw=: ] {~ [: ? [ $ [: # ] NB. verb to throw dice toss=: 2 10 throw dice NB. 2 dice thrown 10 times c=: ([: +/ [: , 'o' = ,)&>/ toss NB. totals of each throw fd=: [: /:~ ({. , #)/.~ NB. calc frequency distribution assert 0 0 0 3 = 4!:0 ;:'dice toss c fd' NB. check word types follow rules 2011/11/26 Linda Alvord <lindaalv...@verizon.net>: > PLEASE DO NOT REPLY BEFORE December I, 2011 at 12:00 am EST ! > > The turkey roll challenge, named in honor of the Thanksgiving Day > holiday, focuses on the verb roll or ? with one argument. > > Create two nouns and a verb that will generate the following results. > > dice > > ----T---T---T---T---T---┐ > │ │o │o │o o│o o│o o│ > │ o │ │ o │ │ o │o o│ > │ │ o│ o│o o│o o│o o│ > L---+---+---+---+---+---- > > toss > > ----T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---┐ > │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│ │ │ │o o│ │ │ │ o │ │o o│ > │ │ │o o│ │ o│ │o o│ │o o│ │o o│ │o o│ │ o│ │ │ │o o│ > L---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---- > > c=:3 8 7 12 9 8 9 7 4 12 NB. The list c is the sums of the > NB. second toss of ten dice > fd c > > 3 1 NB. A frequency distribution of the ten tosses > 4 1 > 7 2 > 8 2 > 9 2 > 12 2 > > > 4!:0 'dice';'toss';'c';'fd' > 0 0 0 3 NB. 0 for nouns, 3 for verbs > > Some rules and hints: > Write all verbs and nouns without @ . You can use several nouns and > verbs to make a final noun or verb. Here are some things about roll. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm