Page 1 of 2 12>
Topic Options
#212828 - 2017-11-05 06:00 PM Kixgolf - Digital Root Clocks: Private Round
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
=================================
The Challenge - Digital Root Clocks
=================================

The following (sparing outputs) is completely and shamelessly copied from https://projecteuler.net/problem=315 \:D



Sam and Max are asked to transform two digital clocks into two "digital root" clocks.
A digital root clock is a digital clock that calculates digital roots step by step.
nB.: to get to the digital root of a number, sum the digits of that number and intermediate results until you end up with a number less or equal 9

When a clock is fed a number, it will show it and then it will start the calculation, showing all the intermediate values until it gets to the result.
For example, if the clock is fed the number 137, it will show: "137" -> "11" -> "2" and then it will go black, waiting for the next number.

Every digital number consists of some light segments: three horizontal (top, middle, bottom) and four vertical (top-left, top-right, bottom-left, bottom-right).
Number "1" is made of vertical top-right and bottom-right, number "4" is made by middle horizontal and vertical top-left, top-right and bottom-right. Number "8" lights them all.

The clocks consume energy only when segments are turned on/off.
To turn on a "2" will cost 5 transitions, while a "7" will cost only 4 transitions.

Sam and Max built two different clocks.

Sam's clock is fed e.g. number 137: the clock shows "137", then the panel is turned off, then the next number ("11") is turned on, then the panel is turned off again and finally the last number ("2") is turned on and, after some time, off.
For the example, with number 137, Sam's clock requires:

"137" : (2 + 5 + 4) × 2 = 22 transitions ("137" on/off).
"11" : (2 + 2) × 2 = 8 transitions ("11" on/off).
"2" : (5) × 2 = 10 transitions ("2" on/off).

For a grand total of 40 transitions.

Max's clock works differently. Instead of turning off the whole panel, it is smart enough to turn off only those segments that won't be needed for the next number.
For number 137, Max's clock requires:

"137" : 2 + 5 + 4 = 11 transitions ("137" on)
7 transitions (to turn off the segments that are not needed for number "11").
"11" : 0 transitions (number "11" is already turned on correctly)
3 transitions (to turn off the first "1" and the bottom part of the second "1";
the top part is common with number "2").
"2" : 4 transitions (to turn on the remaining segments in order to get a "2")
5 transitions (to turn off number "2").

For a grand total of 30 transitions.

Of course, Max's clock consumes less power than Sam's one.
As we are very keen on being environmentally friendly and save energy where we can, we are interested in the savings Max's clock has to offer.
Your code shall therefore return the differences between the total number of transitions needed by Sam's clock and that needed by Max's one.
So, for 137 as input the code should return 10 [ 40(Sam) - 30(Max) = 10(saving) ]

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

================
Inputs and Outputs
================


Input
String of digital root clock value

Example Input
89

Output
Integer or String of calculated savings

Example Output
20

================================================================
Notes
================================================================

- The scoring engine has added code to help diagnose which cases are failing. To see test case results:
 Code:
   kix32 kixgolf_drc $verbose=1 ;shows failing results
   kix32 kixgolf_drc $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: 2017-11-05 to 2017-11-12 (Official Count down clock will determine end time)

2) Public coding phase: 2017-11-12 to 2017-11-19

3) Final results: 2017-11-19


Attachments
kixgolf_drc.zip (288 downloads)
Description:


_________________________



Top
#212833 - 2017-11-05 06:13 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Private round ends in

ended


Edited by Jochen (2017-11-12 06:22 PM)
_________________________



Top
#212835 - 2017-11-05 07:56 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Aye...I can see what you meant by needing a lot of strokes on this one.
Top
#212836 - 2017-11-05 10:19 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
should be interesting to see the solutions
I did the initial PE problem using Python not caring about my strokes and stopped golfing with kix in the lower 500 region
_________________________



Top
#212837 - 2017-11-06 07:24 AM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Rusty as hell, but on the course. I got the hard part figured out so now its just a matter of putting it all together. Hopefully tomorrow.
Top
#212838 - 2017-11-06 09:04 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
remember, once you've put it all together, don't forget to leave out the unnecessary parts.
That's what divide the mere mortal golfers from the Tiger Woods kind ;\)
_________________________



Top
#212839 - 2017-11-07 02:11 AM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Going on no sleep makes it tough to think

Anyway... here's my failing score for the participation point. Hope to work on this after a good nights sleep.

 Quote:

KiXtart Version = 4.66
KiXGolf Script = kixgolf_drc.KIX
Scoring Engine = 3.3
OS = Windows 10 Pro
CPU = Intel Pentium III Xeon
Speed = 3392 MHz
Memory = 16384 MB

Tournament = Digital Root Clocks
Processing Start = 2017/11/06 17:07:57.197
Processing End = 2017/11/06 17:07:57.276
Duration = 0000/00/00 00:00:00.078
# Tests Run = 10
# Tests Passed = 0
# Tests Failed = 10
Result = Failed
KiXGolf Score = 273

Top
#212840 - 2017-11-07 10:08 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
OMG this one is tricky. I thought I had all figured out. GRRR!
Top
#212841 - 2017-11-08 08:58 AM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Jochen, I've finally got something to call "close to working". If you have it handy could you be so kind to give the individual values of Sam and Max for 991 or 89. In other words... what is $s and $m in the following?

$a=$S - $M

My function and my scribble match, but they don't match the ini result.

Top
#212842 - 2017-11-08 10:26 AM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oi Allen,
nice to see you on the green!

will provide this evening when I'm back home from work (about about 9 1/2 hrs from now)
_________________________



Top
#212843 - 2017-11-08 02:22 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Okay... so where might I be going wrong here?

 Code:
  Sam   Max
  7+5  (7+5)*2  
89
  5+1  (2+4)*2
17
  5+4  (7)*2
8
  3+4 
  =34   =50

Top
#212844 - 2017-11-08 02:52 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

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


you got the number 9 wrong (6 segments)
following error then on Sam's one from 89 to 17 (5+1 must be 5+2)
Sam's step from 17 to 8 then... Hmmm, I can not even guess what that means, but correct would be 2 to turn the one off + 3 to make an eight of the seven.

So we have in total of 32 (last step in Sam's calculation to turn the eight off is in my book a 7 and not a 3+4, but hey, can't tell what you do there)

When we consider the 9 for Max (rest of your calculations are correct) we have 2 more in Max's result ;\)

so I guess you tee off in a minute?

 Code:
  Sam   Max
  7+6  (7+6)*2  
89
  5+2  (2+4)*2
17
  2+3  (7)*2
8
    7
  =32   =52   result: 20
_________________________



Top
#212845 - 2017-11-08 02:58 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

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


The 7 got me earlier... I never noticed the 9 having a bottom.

Thanks.

Top
#212846 - 2017-11-08 03:05 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
F!...

 Quote:
Sam's step from 17 to 8 then... Hmmm, I can not even guess what that means, but correct would be 2 to turn the one off + 3 to make an eight of the seven.


I was afraid you were going to say something like this. The original example did not clearly define this....

I may run out of time on this. Heading out of town soon.

I thought I would tell you, I have never spent as much time as I have on this one, just trying to figure the output. Degree of difficulty is higher than it would ever appear from the task given.

Top
#212847 - 2017-11-08 03:39 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yeah sorry,

what can I tell. One clue maybe to give you to chew on:

What really counts are Sam's transitions of digits not what he turns on and off because these are the same cost as Max's ;\)
_________________________



Top
#212848 - 2017-11-08 04:51 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh and maybe, don't let your script do so much calculus... remember you can always substitute/place something you know at the correct position in some lattice.

Now I may have said too much, but as this round seems to be slow anyway, here goes \:\)

btw. Where are the other regulars?
_________________________



Top
#212849 - 2017-11-08 05:14 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I already saw the similarities in Sam's and Max's scores but didn't go down that road yet because I just wanted a working function first.

Substitute Positions... that was the first thing I figured out. \:\) It was the damn counting I had so much trouble with.

No idea on others... I sent invites to everyone I had on my list and only heard from Jooel.

Top
#212850 - 2017-11-08 05:25 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
FFS... where's that golfer with the head exploding avatar when you need it? \:\)

 Code:
KiXtart Version  = 4.66
KiXGolf Script   = kixgolf_drc.KIX
Scoring Engine   = 3.3
OS               = Windows 10 Pro
CPU              = Intel Pentium III Xeon
Speed            = 3392 MHz
Memory           = 16384 MB

Tournament       = Digital Root Clocks
Processing Start = 2017/11/08 11:21:14.045
Processing End   = 2017/11/08 11:21:15.045
Duration         = 0000/00/00 00:00:01.000
# Tests Run      = 10
# Tests Passed   = 4
# Tests Failed   = 6
Result           = Failed

Top
#212851 - 2017-11-08 05:27 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
If I have time tonight I'm going to start over. I think I learned enough the first go rounds to fix whatever the hell is wrong without having to read through this monster.
Top
#212852 - 2017-11-08 05:39 PM Re: Kixgolf - Digital Root Clocks: Private Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

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


 Originally Posted By: Allen
all effort... thanks for noticing


http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=209083#Post209083
_________________________



Top
Page 1 of 2 12>


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

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.086 seconds in which 0.048 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