Page 1 of 10 12345>Last »
Topic Options
#200825 - 2010-11-28 06:28 PM Kixgolf - Bowling Calculator
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
=============
The Challenge - Bowling Calculator
=============


Ten-pin bowling (commonly just "bowling" in the United States) is a competitive sport in which a player (the “bowler”) rolls a bowling ball down a wooden or synthetic (polyurethane) lane with the objective of scoring points by knocking down as many pins as possible.

A game of ten-pin bowling is divided into ten rounds (called “frames”), with frames one (1) through nine (9) being composed of up to two rolls. In a frame, each player is given two opportunities to knock down the pins. The player rolls the first ball at the pins. If the first ball knocks down all ten pins, it is called a “strike” (denoted by "X")and the frame is completed. When pins are left standing after the first ball, those that are knocked down are counted and then removed. Then the player rolls a second ball and if all the remaining pins are knocked down, it is called a “spare” (denoted by "/"). If a player fails to knock down any pins on a roll, ie hitting zero pins, it is denoted by "-".

The tenth (10) frame may be composed of up to three rolls. If a player rolls a strike (on the first roll) he is awarded 2 additional rolls. If a player rolls a spare in the 10th frame, he is awarded 1 additional roll. The bonus rolls following a strike or spare in the 10th frame are sometimes referred to as the eleventh and twelth frames. This allows for a potential of 12 strikes in a single game, and a maximum score of 300 points, a perfect game.

In general, one point is scored for each pin that is knocked over. So if a player knocks over three pins with the first shot, then six with the second, the player would receive a total of nine points for that frame. If a player knocks down 9 pins with the first shot, but misses with the second, the player would also score nine. In the event that all ten pins are knocked over by a player in a single frame, bonuses are awarded:

- For a strike, a player is awarded ten points, plus a bonus of whatever is scored with the next two rolls/balls. (for a maximum of 30 points in any frame)
- For a spare, a player is awarded ten points, plus a bonus of whatever is scored with the next roll.

Example 1: (Partial Score)
 Code:
Frame  1   2   3
------------------
       X   X   72
------------------
Score 27  46  55

Frame 1: 10 + (10+7)=27 
Frame 2: 10 + (7+2) =19
Frame 3: 7+2        =9
Total               =55


Example 2: (Partial Score)
 Code:
Frame  1   2   3
------------------
       9/  6/  7-
------------------
Score 16  33   40

Frame 1: 9+1 + (6)=16 
Frame 2: 6+4 + (7)=17
Frame 3: 7+0      =7
Total             =40


Example 3:
 Code:
Frame  1   2   3   4   5   6   7   8   9   10
------------------
       9/  9/  8/  X   X   7/  8/  X   9/  9/9
------------------
Score 19  37  57  84  104 122 142 162 181  200 

Frame  1: 9+1 + (9)   =19 
Frame  2: 9+1 + (8)   =18
Frame  3: 8+1 + (10)  =20
Frame  4: 10  + (10+7)=27
Frame  5: 10  + (7+3) =20
Frame  6: 7+3 + (8)   =18
Frame  7: 8+3 + (10)  =20
Frame  8: 10  + (9+1) =20
Frame  9: 9+1 + (9)   =19
Frame 10: 9+1 + (9)   =19
Total                 =200 


Example 4:
 Code:
Frame  1   2   3   4   5   6   7   8   9   10
------------------
       X  81  9/  81   X   X   X  -/  9/   X9/
------------------
Score 19  28  46  55  85  105 125 144 164  184 

Frame  1: 10   + (8+1)  =19 
Frame  2: 8+1           =9
Frame  3: 9+1  + (8)    =18
Frame  4: 8+1           =9
Frame  5: 10   + (10+10)=30
Frame  6: 10   + (10+0) =20
Frame  7: 10   + (0+10) =20
Frame  8: 0+10 + (9)    =19
Frame  9: 9+1  + (10)   =20
Frame 10: 10   + (9+1)  =20
Total                   =184





*-->A download is available at http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=224

=============
Specification
=============


Determine the bowler's score given the frames


=============
Input
=============

The input consists of a string of values, each separated by a space, that would be found on a score sheet of bowling. For example:
"X 81 9/ 81 X X X -/ 9/ X9/"

"X" = Strike, 10 pins on the first roll
"/" = Spare, for example 9/ is equal to rolling 9 on the first ball and 1 on the second.
"-" = Miss/Open, equal to 0 pins on a roll.



=============
Output
=============

A number representing the bowler's score.


=================================================================
Notes
===========================================================+====

- The scoring engine is based on older engine, so there may be something like block comments that are not supported.
- The scoring engine has added code to help diagnose which cases are failing. To see test case results:
 Code:
   kix32 kixgolf_bc $verbose=1 ;shows failing results
   kix32 kixgolf_bc $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: 2010-11-28 to 2010-12-05 (Official Count down clock will determine end time)

2) Public coding phase: 2010-12-05 to 2010-12-12

3) Final results: 2010-12-12


*--> You will need the complete package from http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=224.


Attachments
kixgolf_bc.zip (589 downloads)
Description:



Top
#200826 - 2010-11-28 06:31 PM Re: Kixgolf - Bowling Calculator [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
I added 30 minutes for my lateness... so no time loss.

Private Round ends in:
ended


Edited by Allen (2010-12-06 08:51 PM)

Top
#200827 - 2010-11-28 06:33 PM Re: Kixgolf - Bowling Calculator [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
And since it's not always easy to explain, here are a few other websites that try to explain how to keep score.

http://slocums.homestead.com/gamescore.html
http://www.bowling2u.com/trivia/game/scoring.asp
http://hubpages.com/hub/Bowling-How-to-Keep-Score
http://helpwithbowling.com/how-to-keep-score-in-bowling.php

Top
#200828 - 2010-11-28 06:43 PM Re: Kixgolf - Bowling Calculator [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Thanks Allen!

almost fell asleep waiting though \:\)
_________________________
!

download KiXnet

Top
#200829 - 2010-11-28 06:50 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
example 1 is wrong.
_________________________
!

download KiXnet

Top
#200830 - 2010-11-28 06:53 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Quote:
- For a strike, a player is awarded ten points, plus a bonus of whatever is scored with the next two rolls/balls. (for a maximum of 30 points in any frame)


the correct score would be:
Frame 1: 10 + (10+10)=30
Frame 2: 10 + (10+9) =29
Frame 3: 7+2 =9
Total =68


am I wrong?


Edited by Lonkero (2010-11-28 06:54 PM)
_________________________
!

download KiXnet

Top
#200831 - 2010-11-28 06:55 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
If it were
X X X then it would be 30... but it's X X 7=27

Top
#200832 - 2010-11-28 06:55 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, I think I see.
the player is not awarded nothing. just the scores.
cool, moving on...
_________________________
!

download KiXnet

Top
#200833 - 2010-11-28 07:00 PM Re: Kixgolf - Bowling Calculator [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Tricky ...
_________________________



Top
#200834 - 2010-11-28 07:05 PM Re: Kixgolf - Bowling Calculator [Re: Jochen]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
*mumbl*. Somewhat tricky indeed, or perhaps just me not being good at golfing nor bowling ;P
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#200837 - 2010-11-28 07:41 PM Re: Kixgolf - Bowling Calculator [Re: Björn]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
first try failed \:\(
_________________________
!

download KiXnet

Top
#200838 - 2010-11-28 08:12 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wtf!!!
how does:
9/ 9/ 9/...

result in anything other than:
19 19 ... ???????

I can't get the stupid logic of this game.
where does, the extra bonuses come from in example 3????
_________________________
!

download KiXnet

Top
#200839 - 2010-11-28 08:24 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
still that question remains, how does it any way make sense, I have no idea.

but, just letting you guys know, I need to start from scratch... had a huge design flaw in my code \:\)
_________________________
!

download KiXnet

Top
#200840 - 2010-11-28 08:24 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
lol... I think I am seriously enjoying your struggle

9/ means 10 plus the next roll
the next roll is a 9. so the total for the frame would be 19.
So the next frame would be the same... so in total it would be
19 from the previous frame, plus, 10 plus the next roll, 9. for a total of 38... repeat.

You might check out the other links I provided. It's hard to grasp at first.

Top
#200841 - 2010-11-28 09:33 PM Re: Kixgolf - Bowling Calculator [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ELLO ELLO!

 Code:
KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_bc.KIX

Computer
OS               = Windows 6.1 / 1
CPU              = AMD Turion(tm)X2 Ultra DualCore Mobile ZM-82
Speed            = 2200 MHz
Memory           = 2048 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Bowling Calculator
Processing Start = 2010/11/28 22:32:30.164
Processing End   = 2010/11/28 22:32:30.653
Duration         = 0000/00/00 00:00:00.489
# Tests Run      = 17
# Tests Passed   = 17
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 796

Thank you for participating in KiXtart Golf!
Press any key to continue...
_________________________
!

download KiXnet

Top
#200842 - 2010-11-28 09:35 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nah, not gonna check any links when the code works \:\)
_________________________
!

download KiXnet

Top
#200843 - 2010-11-28 09:42 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
You DAWG! ;\)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#200844 - 2010-11-28 09:46 PM Re: Kixgolf - Bowling Calculator [Re: Benny69]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
a little shorter:
 Code:
KiXtart
KiXtart Version  = 4.61
KiXGolf Script   = kixgolf_bc.KIX

Computer
OS               = Windows 7 Professional Edition
CPU              = AMD Turion(tm)X2 Ultra DualCore Mobile ZM-82
Speed            = 2200 MHz
Memory           = 2048 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Bowling Calculator
Processing Start = 2010/11/28 22:44:07.239
Processing End   = 2010/11/28 22:44:07.321
Duration         = 0000/00/00 00:00:00.081
# Tests Run      = 17
# Tests Passed   = 17
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 411

Thank you for participating in KiXtart Golf!
Press any key to continue...
_________________________
!

download KiXnet

Top
#200845 - 2010-11-28 09:51 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
KiXGolf Score = 398
_________________________
!

download KiXnet

Top
#200846 - 2010-11-28 09:59 PM Re: Kixgolf - Bowling Calculator [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
KiXGolf Score = 383
_________________________
!

download KiXnet

Top
Page 1 of 10 12345>Last »


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

Who's Online
1 registered (Allen) and 280 anonymous users online.
Newest Members
Jojo67, MaikSimon, kvn317, kixtarts2025, SERoyalty
17873 Registered Users

Generated in 0.075 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.

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