Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS320 APL Programming Assignment Program 2 01/22/18 16:20:54 For five-of-a kind, multiply by 1000000, six-of-a-kind uses 100000000 (10*8) and seven-of-a-kind uses 10000000000 (10-10) ZZZ2123 xx

image text in transcribedimage text in transcribed

CS320 APL Programming Assignment Program 2 01/22/18 16:20:54 For five-of-a kind, multiply by 1000000, six-of-a-kind uses 100000000 (10*8) and seven-of-a-kind uses 10000000000 (10-10) ZZZ2123 xx 1 1x 1x 360000 340200 (only 4-of-a-kind) (4-of-a-kind plus 3-of-a-kind) Let' s score the earlier exanple: 4ST7SMA 5 + 29 (a pair of 4's and a pair of S's XXW1X2X 34 10000 (four x'S 599ESEE 15 100610 (three E's, a pair of 's and a pair of 9'3) What really counts is how many of each type of the of-a-kind combinations a license plate has. A license plate like would be tallied as 0 000 1 2 (zero 7-, 6-, 5-, or 4-of-a-kind, one 3-of-a-kind, two 2-of-a-kind) Your SCORE function should calculate these weights, then reorder the license plates accordingly, and print the weights after each plate. In this example, the proper output would be: xxw1x2x 340000 599E5EE 1516 AST7SM4 3 would be tallied as 0 001 1 0. and so on.If you interpret these tallies as base-4 numbers, you get a nice numerical interpretation of the value of the hand that makes it easy to sort them correctly Almost. Actually, we should still pay attention to the numerical scores when we otherwise have a tie the types of the of-a-kind' combinations.- Your SCORE function wil1 behave differently, depending on the shape of the argument it is given.If ScoRE is given an Nx7 array of characters (such as the predefined CARS array), it should treat this array as the set of license plates to score. If given a scalar as an argument, SCORE should use this integer to first create a set of random] license plates and then score them For xx11X1)X ..will both tally as o00 1 0, which is nominally a tie. Here, we need to use the scores 340200 and 340900 to favor Xx99x9X over xX11xix (9s beat 1's) Whether you do just the simple totaling or this more accurate tallying, you should report the totals to the right of each hand. For example, CARS contains: should behave the same as SCORE (DEAL 4) (that is, you should have your SCORE function call DEAL when needed) Page 69 of "cs320/APLX Language Manual.pdf shows how to test for the shape; you can then use the result in a branching f atatement, much like they show on Page 29 [but beware of the misprint: they use an equal (Shift-5) where their logic indicates that they really wanted not-equal' (Shift-8)]. Except for this one issue, you should NOT be using any sort of branch or loop in either function make use of the power of arrays and the array manipulation operators! f you find that youve written a sinilar expression on multiple lines, that's an indication that you should be doing the operation only ONCE, but with a higher-dimension object. That is. if you do a computation with 2. then with 3. 4. 5. 6, 7you really should just be doing that computation using the vector 2 3 4s67 2Z22789 ABABABC ...and SORE CARS should produce: Y000YYY 350100 xx88x8X 340900 xx11x1X 340200 2222789 360000 There is often a conmon misconception about how DEAL and SCORE receive input Neither of these functions should be asking for keyboard input-that's NOT what the specs say to do! For example, in the POKER DEAL function i1lustrated in my tutorial, if I wanted 7 cards. I typed: (print it in this order if you implement tho 100 version of the assignment, with tallying; if you do the simpler version, Z222789 would be on top, since it has the highest nunerical score) For full credit, it is all right to have SCORE and DEAL assume that they are being given a proper' argument (of the right kind and shape), but you can get extra credit by testing for this. That is. if DEAL is given anything other than a scalar positive integer, you could test for this and conplain (e.g, it was given a character, or a negative number, or an array of integers,or..) Similarly, SCORE expects cither a positive integer OR an Nx7 array of characters, where N is a (You could even test for 'illegal, characters as 'or 'a"; and neither function really should have a left-hand argument. This is the one other place where , if, statements and branches would be OK to use, but again, error checking is NOT required for full credit. (I you do go for the extra credit, be sure to note this with a yes' in the ident function. I didn't type just POKER DEAL and then prompt the user to enter a 7 after the function starts running. Follow the specs (and the examples)! For both DEAL and SCORE, use the sane parameter-passing technique as was illustrated in POKER DEAL. ive integer If you order the license plates based on the scoring function outlined above, you can receive at least 90% of the credit for the assignment. However, the scores are not always reflective of the winning hand To be assured of 100% of the credit you should use the more accurate scoring method outlined next (If only a few people successfully do this, the winnera may well get much more than 100*) Page 29 of es320/APLX Language Manual pdf shows the magic syntax for testing if a function has been invoked with two or only one paraneter (by checking if the 'name classification' of the left-hand dunny variable is zero, and if so, branching to the line labeled START Remember, it's perfectly fine to reuse such code verbatim, as long as you include a citation (e.g.. "as per Page 29 of AP you don't want to use it verbatimthey use an equal' (Shift-5) where their logic indicates that they really wanted not-cal' (Shift-8) Here's the problem with the simple scoring already outlined: A license plate with 4-of-a-kind plus 3-of-a-kind should win overa license plate with just 4-of-a-kind. Sometimes the scoring algorithn predicts this correctly, as in: x 340200 (4-ot XXW1X2X 340000 (only 4-of-a-kind) but sometimes it doesn't: WHAT TO HAND IN: CS320 APL Programming Assignment Program 2 01/22/18 16:20:54 For five-of-a kind, multiply by 1000000, six-of-a-kind uses 100000000 (10*8) and seven-of-a-kind uses 10000000000 (10-10) ZZZ2123 xx 1 1x 1x 360000 340200 (only 4-of-a-kind) (4-of-a-kind plus 3-of-a-kind) Let' s score the earlier exanple: 4ST7SMA 5 + 29 (a pair of 4's and a pair of S's XXW1X2X 34 10000 (four x'S 599ESEE 15 100610 (three E's, a pair of 's and a pair of 9'3) What really counts is how many of each type of the of-a-kind combinations a license plate has. A license plate like would be tallied as 0 000 1 2 (zero 7-, 6-, 5-, or 4-of-a-kind, one 3-of-a-kind, two 2-of-a-kind) Your SCORE function should calculate these weights, then reorder the license plates accordingly, and print the weights after each plate. In this example, the proper output would be: xxw1x2x 340000 599E5EE 1516 AST7SM4 3 would be tallied as 0 001 1 0. and so on.If you interpret these tallies as base-4 numbers, you get a nice numerical interpretation of the value of the hand that makes it easy to sort them correctly Almost. Actually, we should still pay attention to the numerical scores when we otherwise have a tie the types of the of-a-kind' combinations.- Your SCORE function wil1 behave differently, depending on the shape of the argument it is given.If ScoRE is given an Nx7 array of characters (such as the predefined CARS array), it should treat this array as the set of license plates to score. If given a scalar as an argument, SCORE should use this integer to first create a set of random] license plates and then score them For xx11X1)X ..will both tally as o00 1 0, which is nominally a tie. Here, we need to use the scores 340200 and 340900 to favor Xx99x9X over xX11xix (9s beat 1's) Whether you do just the simple totaling or this more accurate tallying, you should report the totals to the right of each hand. For example, CARS contains: should behave the same as SCORE (DEAL 4) (that is, you should have your SCORE function call DEAL when needed) Page 69 of "cs320/APLX Language Manual.pdf shows how to test for the shape; you can then use the result in a branching f atatement, much like they show on Page 29 [but beware of the misprint: they use an equal (Shift-5) where their logic indicates that they really wanted not-equal' (Shift-8)]. Except for this one issue, you should NOT be using any sort of branch or loop in either function make use of the power of arrays and the array manipulation operators! f you find that youve written a sinilar expression on multiple lines, that's an indication that you should be doing the operation only ONCE, but with a higher-dimension object. That is. if you do a computation with 2. then with 3. 4. 5. 6, 7you really should just be doing that computation using the vector 2 3 4s67 2Z22789 ABABABC ...and SORE CARS should produce: Y000YYY 350100 xx88x8X 340900 xx11x1X 340200 2222789 360000 There is often a conmon misconception about how DEAL and SCORE receive input Neither of these functions should be asking for keyboard input-that's NOT what the specs say to do! For example, in the POKER DEAL function i1lustrated in my tutorial, if I wanted 7 cards. I typed: (print it in this order if you implement tho 100 version of the assignment, with tallying; if you do the simpler version, Z222789 would be on top, since it has the highest nunerical score) For full credit, it is all right to have SCORE and DEAL assume that they are being given a proper' argument (of the right kind and shape), but you can get extra credit by testing for this. That is. if DEAL is given anything other than a scalar positive integer, you could test for this and conplain (e.g, it was given a character, or a negative number, or an array of integers,or..) Similarly, SCORE expects cither a positive integer OR an Nx7 array of characters, where N is a (You could even test for 'illegal, characters as 'or 'a"; and neither function really should have a left-hand argument. This is the one other place where , if, statements and branches would be OK to use, but again, error checking is NOT required for full credit. (I you do go for the extra credit, be sure to note this with a yes' in the ident function. I didn't type just POKER DEAL and then prompt the user to enter a 7 after the function starts running. Follow the specs (and the examples)! For both DEAL and SCORE, use the sane parameter-passing technique as was illustrated in POKER DEAL. ive integer If you order the license plates based on the scoring function outlined above, you can receive at least 90% of the credit for the assignment. However, the scores are not always reflective of the winning hand To be assured of 100% of the credit you should use the more accurate scoring method outlined next (If only a few people successfully do this, the winnera may well get much more than 100*) Page 29 of es320/APLX Language Manual pdf shows the magic syntax for testing if a function has been invoked with two or only one paraneter (by checking if the 'name classification' of the left-hand dunny variable is zero, and if so, branching to the line labeled START Remember, it's perfectly fine to reuse such code verbatim, as long as you include a citation (e.g.. "as per Page 29 of AP you don't want to use it verbatimthey use an equal' (Shift-5) where their logic indicates that they really wanted not-cal' (Shift-8) Here's the problem with the simple scoring already outlined: A license plate with 4-of-a-kind plus 3-of-a-kind should win overa license plate with just 4-of-a-kind. Sometimes the scoring algorithn predicts this correctly, as in: x 340200 (4-ot XXW1X2X 340000 (only 4-of-a-kind) but sometimes it doesn't: WHAT TO HAND IN

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions