#213433 - 2018-06-24 08:32 PM
Kixgolf - Magic (Private Round)
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
================================= The Challenge - The Magician 11-16 =================================
This challenge is based on a Self Working Card trick. The magic trick would be performed as follows:
The magician would take a deck of 52 cards and ask the subject(s) to shuffle the deck. Then the magician takes the deck back and silently starts flipping cards faceup on the table, making what looks to be random piles of cards. Once all the piles are created, the magician turns all the decks face down. He asks the subject to pick any 3 piles. At this point the magician collects all the other piles and puts them into a single pile. Again, he starts making a pile of cards, when he reaches a certain card he says... "OH!, I see! Tricky!" And then the magician continues laying cards on the pile. Once he's done he says, "Now then, despite your best efforts to fool me, I have figured out the value of the top three cards in your stacks. The value is ##." At this point the subject turns over the top card in each stack, and those three cards equal what the magician said.
Poof Magic!
In addition to being a kixgolf course, this is also a proof. You must solve both the Subject side and the Magicians side and compare those two number before supplying the function value. This means, you must a have section that does the following, or a golfed version of it.
;$a=magician score, $b=subject score
if $a=$b
$function=$a
else
$function=0
endif
There is no time that this shouldn't work, so if you ever have a 0 result, you know you have something going wrong with your code. I will make an effort to remind you about this requirement throughout the duration of the private round.
The card trick is performed by doing the following: Use the following rules for the cards: Number cards are face value, Face Cards are 10, and Aces are 1 Flip the first card over. Silently start placing cards on the pile to add enough cards to make a pile worth 11 Pile #1: So if a 8 flips, Count 8, and add 3 more cards (9,10,11). Four cards total. Take the stack you just created and flip them over. So the 8 is now on top. Pile #2: If on the next pile a K shows first (count 10), add one more card (11). Two cards total. Flip the stack, now the K is on top. Pile #3: If on the next pile a A shows first (count 1), add 10 cards (2,3,4,5,6,7,8,9,10,11). Eleven cards total. Flip Stack, A now on top. Pile #N: Repeat making piles until there is either a last pile of 11, or if it does not equal 11, set those cards aside (but use them later) Ask your subject to select any 3 piles. Leave those piles in place and do not reveal the cards. Now Collect all the other piles (including the discarded pile) and put them back in a stack. The order is irrelvant. Silently count off 16 cards, but act is if the 16th card is very special. From here silently start counting the cards again until you get to the end. The total number of cards is the combined value of the top card of each pile the subject choose earlier.
Example #1 If the deck starts as A 2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K Magician Turns over first card, A, counts 1 in his head, and then adds cards to make it so the total is 11. Once a card is turned over and the remaining cards do not equal 11, it is the discard pile This is repeated until the piles are created below
Pile #1 A + 10 Cards #2 Q + 1 Card #3 A + 10 Cards #4 Q + 1 Card #5 A + 10 Cards #6 Q + 1 Card #7 A + 10 Cards (2 Cards in Dispile, not for Subject to choose from) Turn Piles over Ask Subject to Pick 3 Piles Subject Selects Piles #1, #2, #3 Magician Collects all the other piles (and discards) and puts them in a new pile (order is irrelvant) Magician Starts Flipping the Cards face up and counting in his head to the 16th Card Once the 16th cards appears, start over counting and flipping cards. The total number of cards in this final stack will equal the sum of the top card from each of the Subjects piles (A+Q+A=12).
Example #2 If the deck starts as 8 3 2 A K Q J 10 9 6 7 5 4 A K Q K Q 3 2 10 J 7 9 8 5 6 4 A Q A J 10 9 8 10 7 6 9 8 7 5 4 2 3 J K 2 3 4 5 6 Magician Turns over first card, 8, counts 8 in his head, and then adds cards to make it so the total is 11. Once a card is turned over and the remaining cards do not equal 11, it is the discard pile This is repeated until the piles are created below
Pile #1 8 + 3 Cards #2 K + 1 Card #3 J + 1 Card #4 9 + 2 Cards #5 5 + 6 Cards #6 3 + 8 Cards #7 4 + 7 Cards #8 10 + 1 Cards #9 6 + 5 Cards (9 Cards in Dispile) Turn Piles over Ask Subject to Pick 3 Piles Subject Selects Piles #1, #2, #3 Magician Collects all the other piles (and discards) and puts them in a new pile (order is irrelvant) Magician Starts Flipping the Cards face up and counting in his head to the 16th Card Once the 16th cards appears, start over counting and flipping cards. The total number of cards in this final stack will equal the sum of the top card from each of the Subjects piles (8+K+J=28).
*-->A download is available at http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=387
================ Inputs and Outputs ================
Input Input1=String of 52 cards, separated by spaces Input2=String of the Piles #s picked by the subject, separated by spaces
Aces are worth 1, Face cards are 10, all other cards are face value
Output Value of Top Three Cards on Piles or Number of Cards after the 16th, however you have to solve both in your code and compare them.
================================================================ Notes ================================================================ - The scoring engine has added code to help diagnose which cases are failing. To see test case results:
kix32 kixgolf_magic $verbose=1 ;shows failing results
kix32 kixgolf_magic $verbose=2 ;shows all results
- The scoring engine expects your (primary) function to be named a().
======= Scoring =======
The solution must pass all tests in order for it's KiXgolf Score to be considered.
When posting KiXtart Golf Scores, please include the KIXGOLF_*.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on and the resulting scores.
============ Test program ============
Test cases are provided to help screen entries and to provide the Golf Score. Any script that passes the test cases can be submitted. If you are surprised that your solution passed the test cases, please submit it anyway! That will help me identify bugs in the test program.
================================================================ KiXtart GOLF - How To Play ================================================================
Most importantly, anybody can play, no age restrictions, no penalties, no handicap!
The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.
Example: How many positive elements are in array $a?
Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]
One approach:
for $b=0 to ubound($a)
if $a[$b]>0
$c=$c+1
endif
next
for a score of 45.
Another solution is:
DO
$b=$b+1
if $a[$b]>0
$c=$c+1
endif
UNTIL $b>(UBOUND($a)+1)
for a score of 53.
Better approach: Code sample 1
================================================================ KiXtart GOLF - The Rules ================================================================
1) The goal of KiXtart Golf is to score the lowest strokes. 2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5. 3) Code can be constructed any way you like, as long as it does not generate syntax or other errors when running the script in KiXtart. 4) The final solution MUST pass all test scripts that are part of the KiXtart golf challenge. 7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player. 8) During the public coding phase, code should be posted, reused, and borrowed from other players. 9) The test script contains the official KiXgolf scoring engine 10) Only the person posting a particular score will be recognized for the score, unless the KiXtart Golf Challenge organizer or another delegate posts code on behalf of a player 11) KiXtart Golf (a.k.a KiXgolf) codes must be written inside the KiXgolf UDF collection tags, ';!' and ';!;!' 12) Parameter names of the UDF's can be changed and additional optional parameters can be added. 13) Additional helper UDFs and code can be written as long as they reside inside the ';!' and ';!;!' tags. 14) The use of '$' as a variable is allowed. 15) The UDF layout is up to coder. 16) The UDF is expected to finish in a reasonable time, that is, on modern computers inside 1 hour timeframe. 17) You can submit scores as often as you want. 18) If you reach leading score, you are obligated to post your score immediately so others can try to compete with you. 19) The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed. 20) Calls to COM components that are part of a standard default Windows installation are allowed. 21) The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting. 22) Calls to other executables, as long as they are part of a standard default Windows installation are allowed. 23) The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site or file. 24) You may assume ASCII as character set. 25) You may use block comments as the KiXgolf Scoring Engine now supports block comments. 26) You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed. 27) Your submitted score must include the result print of the KiXgolf test-engine. 28) The SETOPTION() parameters in the KiXgolf script may not be modified and will govern the script behavior. SETOPTION() parameters may change depending on the particular needs of the KiXgolf challenge. 29) Tokenizing the UDF, script, or portions thereof is not allowed. 30) If something is not explicitly denied by the rules, it's allowed. 31) If Confusion arises, arranger of the KiXgolf round has the final say. 32) Additional test cases can be added at any time during the KiXgolf round. The code is expected to pass based on the rules. The test cases may not include tests for all rules and exceptions. Test cases that are added during the public round will not alter the results of the private round.
================================================================ KiXtart GOLF - The Duration of the Competition ================================================================
1) Private coding phase: 2018-06-24 to 2018-07-01 (Official Count down clock will determine end time)
2) Public coding phase: 2018-07-01 to 2018-07-08
3) Final results: 2018-08-01
Attachments
kixgolf_magic.zip (443 downloads) Description:
|
Top
|
|
|
|
#213435 - 2018-06-24 08:38 PM
Re: Kixgolf - Magic (Private Round)
[Re: Allen]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Rushed to get it up, so I won't be surprised if I have something screwy. Hope it works out though.
|
Top
|
|
|
|
#213443 - 2018-06-26 02:49 AM
Re: Kixgolf - Magic (Private Round)
[Re: Lonkero]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Two challenges in one...
|
Top
|
|
|
|
#213446 - 2018-06-26 02:55 AM
Re: Kixgolf - Magic (Private Round)
[Re: Lonkero]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
all that grumbling... and then poof... code
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|