I'm not sure this if this challenge was too hard or too easy. Since no one
responded, I'll show you my solution.  If I can do the challenge at all,
then I pose the question.  My hope is that the solutions you provide will
teach me better ways of doing things.  Actually, I probably enjoy that part
of the process the most.

I welcome all the improvements you can make on this sequence:

   c=:'AKQJT98765432'
   s=:'SHDC'
   ]fla=: 13 :'(52$x),:13#y'
] ((52 $ [) ,: 13 # ])
   ]packla=:c fla s
AKQJT98765432AKQJT98765432AKQJT98765432AKQJT98765432
SSSSSSSSSSSSSHHHHHHHHHHHHHDDDDDDDDDDDDDCCCCCCCCCCCCC
   ]rr=: 13 :'y?y'
] ?~
   ]mla=: 13 :'(rr x) {"1 y'
] (] {"1~ [: rr [)
   ]mixla=: 13 :'52 mla y'
] (52 mla ])
   mixla packla
JA2T8A9QK4A8T36792245JJ372QAK5K57Q6T7358K6Q6J4398T94
SCDDCSCDDCHHHDDCSHCHDDCHHSSDCSSCSHCSDSHSHHCSHDCDDCHS
   ]nla=: 13 :'(|:52 2$ 2#,|:i.13 4){"1 y'
] ((2 52$0 4 8 12 16 20 24 28 32 36 40 44 48 1 5 9 13 17 21 25 29 33 37 41
45 49 2 6 10 14 18 22 26 30 34 38 42 46 50 3 7 11 15 19 23 27 31 35 39 43 47
51 0 4 8 12 16 20 24 28 32 36 40 44 48 1 5 9 13 17 21 25 29 33 37 41 45 49 2
6 10 14 18 22 26 30 34 38 4...
   ]dolela=: 13 :'(|:"2) 4 13 2$,|: nla y'
] ([: (|:"2) 4 13 2 $ [: , [: |: nla)
   dolela mixla packla
5TK9A84K9KQ96
CCCCCSSSHDSDD

J8Q23JT5JKQ48
DCCSCSSHHHDHH

2797363T8TA24
CCSHHHSHDDHDC

25675A4J63A7Q
HDCSSSDCSDDDH
   dolela mixed=:mixla packla
94QAJ2T8Q4543
HDSHCCSHCHSCS

855TK96A736K7
SCHCSSDSHCCHD

JQ64A7JTK9723
HHSSCCSHCDSDH

J8Q262K5A893T
DDDHHSDDDCCDD
   mixed 
98JJ45Q8Q56QAT42JKA62972T6JK8AT5Q7KA439856794K23373T
HSHDDCHDSHSDHCSHCSCHCSCSSDSDHSHDCHCDHCDCSCSCCHDDSDHD
   
Now I'll try to create a new challenge.

Linda

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord
Sent: Friday, December 16, 2011 4:33 AM
To: 'Programming forum'
Subject: [Jprogramming] Challenge 3 - Dole a Mixed Pack

Here's the next challenge. PLEASE DO NOT RESPOND UNTIL DECEMBER 23,2011 AT
12:00 AM EST.  ALLOW THINKING TIME.  THANKS.

 

The name has a small hint as it can be loosely translated as "Deal a
shuffled deck of cards".

 

Design  1  noun  and  2  verbs called  packla(your initials) , mixla(your
initials) and dolela(your initials.  Use any nouns and verbs that you
require to make your final answers.  Avoid  @  .

 

First create a noun to form a traditional deck of cards. There are four
suits called spades, hearts, clubs and diamonds. Each suit has thirteen
cards ace, king, queen, jack, ten, nine, eight, seven, six, five, four,
three and two. When you are finished your 52 cards will look like:

 

   packla=:

   packla

AKQJT98765432AKQJT98765432AKQJT98765432AKQJT98765432
SSSSSSSSSSSSSHHHHHHHHHHHHHDDDDDDDDDDDDDCCCCCCCCCCCCC

 

Now define a monadic verb to shuffle the pack:

   mixla=:

   ]52 mixla packla

T84T8AJK4739853T324K7J6556T64J7J6Q5AQ2KQ9283Q9KA972A
DHSCSHDDHSHDDHSHCSDSDSCSCSSDCHHCHDDCHCHSCDCDCSCDHCHS

   

   ]52 mixla packla

622A583897A652K79A5JK4763A7K4KTQQ58J4Q6T893J49J3Q2TT
SSCSCHDCSDHHDHSCDCSSDCHCHDSCSHSSDHDCHCDCSCSHDHDCHDHD

 

Repeat the use of  mix  twice to insure that a new shuffle has occurred. Now
shuffle the cards for game 1.  Design a monadic verb dole to deal the
shuffled pack of cards.

   ]g1=:52 mixla packla

68898566QA6A724324J4TJQK59K5T329K7JA373T27QQ48TAJK95
HDCCHHDCCHSSDHHSCSSCSDDSCDHDDHDSCHCDCCDCSSHSDSHCHDHS

   

   dolela=:

   dolela g1

68Q72T5TK324J
HHCDCSCDCCSDH

85A24J937778K
DHHHSDDHHCSSD

8664JQK2J3QT9
CDSHSDHDCDHHH

96A34K59ATQA5
CCSSCSDSDCSCS

 

Note that this is the real deal!  The first card goes in hand 1, the second
in hand 2 and so forth. Repeat for game 2.

 

   ]g2=:52 mixla packla

AT9JK2T457236QJ439QQK6839645T7JAAA6K8KQ487J72T835592
CCSDDHSCDDCHCDSHDDCSCSDCHDSCHCCHSDHHSSHDCHHSDDHSHSCS

 

   dolela g2

AK563K9TA8825
CDDCDCHHSSCDH

T27Q9667AK7T5
CHDDDSDCDSHDS

9T2JQ84J6QJ89
SSCSCDSCHHHHC

J434Q35AK4732
DCHHSCCHHDSSS

 

Be sure you have a new deal.

 

4!:0 ;:'packla mixla dolela'

0 3 3

 

Have fun!

 

Linda

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to