Page 1 of 9 12345>Last »
Topic Options
#182416 - 2007-11-10 02:43 AM KiXgolf - Printer Queue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
=============
The Challenge: Printer Queue
=============


The only printer in the computer science students' union is experiencing an extremely heavy workload. Sometimes there are a hundred jobs in the printer queue and you may have to wait for hours to get a single page of output.

Because some jobs are more important than others, the Hacker General has invented and implemented a simple priority system for the print job queue. Now, each job is assigned a priority between 1 and 9 (with 9 being the highest priority, and 1 being the lowest), and the printer operates as follows.
  • The first job J in queue is taken from the queue.
  • If there is some job in the queue with a higher priority than job J, then move J to the end of the queue without printing it.
  • Otherwise, print job J (and do not put it back in the queue).

In this way, all those important muffin recipes that the Hacker General is printing get printed very quickly. Of course, those annoying term papers that others are printing may have to wait for quite some time to get printed, but that's life.

Your problem with the new policy is that it has become quite tricky to determine when your print job will actually be completed. You decide to write a program to figure this out. The program will be given the current queue (as a list of priorities) as well as the position of your job in the queue, and must then calculate how long it will take until your job is printed, assuming that no additional jobs will be added to the queue. To simplify matters, we assume that printing a job always takes exactly one minute, and that adding and removing jobs from the queue is instantaneous.

This, if the queue look like "1 2 3 4" and your job is in postion 2, then it'll take 2 minutes until your job is printed.

In case of the queue being "1 1 9 1 1 1" and your job in position 0 (the first slot), it'll then take 5 minutes as your job and the job after you move all the way back in the queue in order to make room for the higher-priority job in slot 2.

A download is available at http://s91376351.onlinehome.us/kixtart/kixgolf_pq.zip

=============
Inputs & Outputs
=============


Input: One string with n space-separated integers (1<= n <= 100) in the range 1 to 9, giving the priorities of the jobs in the queue. The first integer gives the priority of the first job, the second integer the priority of the second job, and so on. One integer (0<= m <= n-1) denoting the position of your job in the queue.

Output: A single integer; the number of minutes until your job is completely printed, assuming that no additional print jobs will arrive.

=======
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 ';!;!' and must be eclosed by the FUNCTION commands
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.
13) Additional helper UDFs 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 during the private round by submitting a proposal for a new test case to the BBS. The proposed test case becomes official once it has been added to the existing test cases and the KiXgolf package has been reposted for download. If new test cases are added within 12 hours of private round end the private round will extend by an additional 24 hours. The public round will then start one day later and also end one day later. Not additional test cases will be added during the public round.


================================================================
KiXtart GOLF - The Duration of the Competition
================================================================


1) Private coding phase: From date/time of posting the tournament challenge to November 14, 6pm EST (BBS+6 time)

2) Public coding phase: From November 14, 6pm EST (BBS+6 time) to November 18, 6pm EST (BBS+6 time)

3) Final results: November 19, 11pm EST (BBS+6 time)

You will need the complete package from http://s91376351.onlinehome.us/kixtart/kixgolf_pq.zip.
_________________________
There are two types of vessels, submarines and targets.

Top
#182419 - 2007-11-10 04:34 AM Re: KiXgolf - Printer Queue [Re: Sealeopard]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
Please see the following relevant bug report: 4.60 bug: Function
_________________________
There are two types of vessels, submarines and targets.

Top
#182420 - 2007-11-10 05:08 AM Re: KiXgolf - Printer Queue [Re: Sealeopard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
I believe there is a bug in the scoring engine...

this
if $iOutput=$iResult and vartype($iOutput)=3
should be
if $iOutput=$sResult and vartype($sResult)=3

Top
#182421 - 2007-11-10 05:43 AM Re: KiXgolf - Printer Queue [Re: Allen]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
k well, based on the fixed engine, looks like im first on the leader board:

Your solution passed all tests

KiXtart
KiXtart Version = 4.60 Release Candidate 1
KiXGolf Script = kixgolf_pq.kix

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/09 23:34:53.738
Processing End = 2007/11/09 23:34:59.987
Duration = 0
KiXGolf Score = 275

Thank you for participating in KiXtart Golf!

Top
#182422 - 2007-11-10 06:00 AM Re: KiXgolf - Printer Queue [Re: Shawn]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
KiXGolf Score = 231
Top
#182423 - 2007-11-10 08:26 AM Re: KiXgolf - Printer Queue [Re: Shawn]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
GAH! So Close! Gotta go to bed... try to play tomorrow evening.

 Quote:

Your solution failed 4 of 100 tests.

Top
#182424 - 2007-11-10 08:31 AM Re: KiXgolf - Printer Queue [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
Last minute brain fart... \:\) Now I can sleep peacefully. I will clean up this ugly beast tomorrow.


Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 02:28:14.993
Processing End = 2007/11/10 02:28:16.452
Duration = 0000/00/00 00:00:01.458
KiXGolf Score = 503

Thank you for participating in KiXtart Golf!

Top
#182428 - 2007-11-10 02:00 PM Re: KiXgolf - Printer Queue [Re: Allen]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
I've posted an updated scoring script to correct the typos in the results validation line. I've also changed the two variable names in the KiXgolf UDF due to the potential bug of having a parameter with the same name as the function name. You're free to adjust the parameter variable names to your liking.

And congrats to Shawn for posting the first score, darn good opening shot \:\)
_________________________
There are two types of vessels, submarines and targets.

Top
#182429 - 2007-11-10 04:21 PM Re: KiXgolf - Printer Queue [Re: Sealeopard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 10:19:13.592
Processing End = 2007/11/10 10:19:14.559
Duration = 0000/00/00 00:00:00.967
KiXGolf Score = 409

Thank you for participating in KiXtart Golf!

Top
#182430 - 2007-11-10 04:42 PM Re: KiXgolf - Printer Queue [Re: Allen]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
There is no printer \:D

KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 16:38:50.531
Processing End = 2007/11/10 16:38:56.197
Duration = 0000/00/00 00:00:05.665
KiXGolf Score = 218

Thank you for participating in KiXtart Golf!


Nice to see you back on the green, Shawn!
_________________________
The Code is out there

Top
#182431 - 2007-11-10 04:49 PM Re: KiXgolf - Printer Queue [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 16:48:13.059
Processing End = 2007/11/10 16:48:18.584
Duration = 0000/00/00 00:00:05.525
KiXGolf Score = 191

Thank you for participating in KiXtart Golf!
_________________________
The Code is out there

Top
#182432 - 2007-11-10 04:50 PM Re: KiXgolf - Printer Queue [Re: DrillSergeant]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
Show off!
Top
#182433 - 2007-11-10 05:00 PM Re: KiXgolf - Printer Queue [Re: Allen]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
KiXGolf Score = 191
Top
#182434 - 2007-11-10 05:04 PM Re: KiXgolf - Printer Queue [Re: Shawn]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 17:02:17.964
Processing End = 2007/11/10 17:02:23.457
Duration = 0000/00/00 00:00:05.493
KiXGolf Score = 179

Thank you for participating in KiXtart Golf!
_________________________
The Code is out there

Top
#182435 - 2007-11-10 05:20 PM Re: KiXgolf - Printer Queue [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Your solution passed all tests

KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 17:17:59.338
Processing End = 2007/11/10 17:18:04.413
Duration = 0000/00/00 00:00:05.074
KiXGolf Score = 166
_________________________
The Code is out there

Top
#182436 - 2007-11-10 06:27 PM Re: KiXgolf - Printer Queue [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Your solution passed all tests

KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 18:26:19.711
Processing End = 2007/11/10 18:26:25.810
Duration = 0000/00/00 00:00:06.099
KiXGolf Score = 161
_________________________
The Code is out there

Top
#182437 - 2007-11-10 07:52 PM Re: KiXgolf - Printer Queue [Re: DrillSergeant]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
A page out of Rogers handbook:

There is no printer,...

Your solution failed 100 of 100 tests.

KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.kix

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 12:49:19.929
Processing End = 2007/11/10 12:49:20.197
Duration = 0000/00/00 00:00:00.268
KiXGolf Score = 27

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

Ha! Made you look
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#182438 - 2007-11-10 10:29 PM Re: KiXgolf - Printer Queue [Re: Benny69]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4667
Loc: The Netherlands
Damn Sarg! Your code must be on steroids or something.
Looks like you are leading the pack with a 130 on Shawn and almost 250 on Allen. Benny doesn't even count. Anyone can make a 27 script failing all tests ;\)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#182439 - 2007-11-10 10:37 PM Re: KiXgolf - Printer Queue [Re: Mart]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
My opening score

I know it is not there yet, but just wanted to get a post in for participation points \:\)

Your solution failed 56 of 100 tests.

KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_pq.KIX

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Printer Queue
Processing Start = 2007/11/10 14:33:41.578
Processing End = 2007/11/10 14:33:42.250
Duration = 0000/00/00 00:00:00.671
KiXGolf Score = 135

Thank you for participating in KiXtart Golf!
_________________________
Today is the tomorrow you worried about yesterday.

Top
#182440 - 2007-11-10 10:37 PM Re: KiXgolf - Printer Queue [Re: Mart]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
I'm only a measly 30 ahead of shawn, Mart. He posted a 191 right after mine \:\)

besides, I'm sure that Jooel will come around soon and leave us all in his dust again

Top
Page 1 of 9 12345>Last »


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

Who's Online
0 registered and 275 anonymous users online.
Newest Members
Praveer, Ollero, rayyo, Foxlicht, DonChild
17742 Registered Users

Generated in 0.047 seconds in which 0.015 seconds were spent on a total of 13 queries. Zlib compression enabled.

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