Page 1 of 4 1234>
Topic Options
#213433 - 2018-06-24 08:32 PM Kixgolf - Magic (Private Round)
Allen Administrator Offline
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.
 Code:
;$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:
 Code:
   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:
 Code:
for $b=0 to ubound($a)
  if $a[$b]>0
    $c=$c+1
  endif
next

for a score of 45.

Another solution is:
 Code:
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
#213434 - 2018-06-24 08:33 PM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA

Top
#213435 - 2018-06-24 08:38 PM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Allen Administrator Offline
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
#213436 - 2018-06-24 09:38 PM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Nice,
can‘t make any sense of it right now
See you tomorrow
_________________________



Top
#213439 - 2018-06-25 02:51 PM Re: Kixgolf - Magic (Private Round) [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Just for clarification on the cards. Input1 is the order of the cards top and face down.

I mention making piles and turning them down in the instructions. There is no reason to do this in code however because they are already in that order when you process Input1.

Hope this helps and makes sense.

Top
#213440 - 2018-06-26 01:27 AM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
gonna take a lookie...
_________________________
!

download KiXnet

Top
#213441 - 2018-06-26 02:26 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:
# Tests Run      = 19
# Tests Passed   = 3
# Tests Failed   = 16
Result           = Failed
KiXGolf Score    = 692


wonder what I am doing wrong... might have to put my mind to it.
_________________________
!

download KiXnet

Top
#213442 - 2018-06-26 02:43 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok... so, not only we have to calculate it, we also have to keep track of the cards and not cheat with that code but use it to test if we calculated correctly after we already calculated correctly?

that requirement of if $a=$b doesn't necessarily compute in my head...

without that part I have a working code, now I need to go back and write another stack of lines just to make code that checks if a computer calculated wrong? \:o


Edited by Lonkero (2018-06-26 02:46 AM)
_________________________
!

download KiXnet

Top
#213443 - 2018-06-26 02:49 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Two challenges in one... \:\)
Top
#213444 - 2018-06-26 02:50 AM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Honestly, this challenge is beyond easy if you only have to do one side.
Top
#213445 - 2018-06-26 02:51 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:

KiXtart Version  = 4.67
KiXGolf Script   = kixgolf_magic.kix
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium Model 12
Speed            = 3999 MHz
Memory           = 8192 MB

Tournament       = Magic 11-16
Processing Start = 2018/06/25 19:51:10.206
Processing End   = 2018/06/25 19:51:10.244
Duration         = 0000/00/00 00:00:00.038
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 833

Thank you for participating in KiXtart Golf!


 Quote:

Tournament = Magic 11-16
Processing Start = 2018/06/25 19:55:31.518
Processing End = 2018/06/25 19:55:31.565
Duration = 0000/00/00 00:00:00.047
# Tests Run = 19
# Tests Passed = 19
# Tests Failed = 0
Result = Passed
KiXGolf Score = 762


Edited by Lonkero (2018-06-26 02:56 AM)
_________________________
!

download KiXnet

Top
#213446 - 2018-06-26 02:55 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
all that grumbling... and then poof... code \:\)
Top
#213447 - 2018-06-26 02:58 AM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I still don't get it...

 Code:
Processing Start = 2018/06/25 19:56:57.697
Processing End   = 2018/06/25 19:56:57.735
Duration         = 0000/00/00 00:00:00.038
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 746


edit...
I think it just makes for a longer code and then might make it harder to spot a "cheating" code...
 Code:
KiXtart Version  = 4.67
KiXGolf Script   = kixgolf_magic.kix
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium Model 12
Speed            = 3999 MHz
Memory           = 8192 MB

Tournament       = Magic 11-16
Processing Start = 2018/06/25 20:03:47.634
Processing End   = 2018/06/25 20:03:47.681
Duration         = 0000/00/00 00:00:00.046
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 656


edit2, wonder if I am playing all alone... Jochen?
 Code:
Tournament       = Magic 11-16
Processing Start = 2018/06/25 20:19:58.809
Processing End   = 2018/06/25 20:19:58.840
Duration         = 0000/00/00 00:00:00.031
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 526


edit3, it sure seems lonely here...

 Code:
KiXtart Version  = 4.67
KiXGolf Script   = kixgolf_magic.kix
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium Model 12
Speed            = 3999 MHz
Memory           = 8192 MB

Tournament       = Magic 11-16
Processing Start = 2018/06/25 20:35:14.259
Processing End   = 2018/06/25 20:35:14.280
Duration         = 0000/00/00 00:00:00.020
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 229


Edited by Lonkero (2018-06-26 03:36 AM)
_________________________
!

download KiXnet

Top
#213448 - 2018-06-26 04:02 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, I think I hit my limit... I guess I get to see you guys in 5 days...?


 Code:
Tournament       = Magic 11-16
Processing Start = 2018/06/25 21:01:15.690
Processing End   = 2018/06/25 21:01:15.728
Duration         = 0000/00/00 00:00:00.038
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 215


edit...
just a side note. if I didn't have to memorize for the mark as well but could just do my magical part, it would be down to 192...


Edited by Lonkero (2018-06-26 04:08 AM)
_________________________
!

download KiXnet

Top
#213449 - 2018-06-26 04:04 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
We supposedly got about 3 more coming.

You arent't really done are you?

Top
#213450 - 2018-06-26 04:09 AM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol... not really sure what else to do here. it's not like I got million strokes \:\)

now if jpo pulls of 150 somehow, then I gotta redesign, but short of that, don't really know man...
_________________________
!

download KiXnet

Top
#213451 - 2018-06-26 04:50 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
If you really think it could lead to "cheating" I'm willing to remove the requirement. I don't want to be making a judgement call on a suspect piece of code. My fear is, with only needing to find the answer, your codes are going being to be small and very tough to find strokes.
Top
#213452 - 2018-06-26 04:55 AM Re: Kixgolf - Magic (Private Round) [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no need to remove it... I just griping...

it's not just intentional cheating either, just the fact that twisting numbers and variables around can lead to mistakes.

I had to add explanatory comments to my code to keep up which value we are talking about. first of everything. I guess that means I am really getting old? :'(


anyhow, got this far:
 Code:
KiXtart Version  = 4.67
KiXGolf Script   = kixgolf_magic.kix
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium Model 12
Speed            = 3999 MHz
Memory           = 8192 MB

Tournament       = Magic 11-16
Processing Start = 2018/06/25 21:51:05.720
Processing End   = 2018/06/25 21:51:05.755
Duration         = 0000/00/00 00:00:00.035
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 203
_________________________
!

download KiXnet

Top
#213453 - 2018-06-26 09:07 AM Re: Kixgolf - Magic (Private Round) [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Right now things are a bit packed, hope that I get to play around thursday or so..
203 is really low score regarding what I already have done in the back of my head though.
_________________________



Top
#213456 - 2018-06-27 01:42 AM Re: Kixgolf - Magic (Private Round) [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:

KiXtart Version  = 4.67
KiXGolf Script   = kixgolf_magic.kix
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium Model 12
Speed            = 3999 MHz
Memory           = 8192 MB

Tournament       = Magic 11-16
Processing Start = 2018/06/26 18:41:47.346
Processing End   = 2018/06/26 18:41:47.377
Duration         = 0000/00/00 00:00:00.030
# Tests Run      = 19
# Tests Passed   = 19
# Tests Failed   = 0
Result           = Passed
KiXGolf Score    = 201

Thank you for participating in KiXtart Golf!
_________________________
!

download KiXnet

Top
Page 1 of 4 1234>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.083 seconds in which 0.031 seconds were spent on a total of 15 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org