Page 1 of 2 12>
Topic Options
#212869 - 2017-11-12 06:20 PM Kixgolf - Digital Root Clocks: Public Round
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Please post your code
_________________________



Top
#212871 - 2017-11-12 06:22 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

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

Edited by Jochen (2017-11-19 06:05 PM)
_________________________



Top
#212873 - 2017-11-12 09:46 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
540

 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o[9],$b[9]
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to Len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next
$m = $s/2

Do
   $y = 0

   For $=1 to Len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $t = Left($i, Len($i) - Len($y))

   For $=1 to Len($y)
      $s = $s + (2*$o[SubStr($y, $, 1)])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, Len($y)), $, 1)], $x, 1) <> substr($b[SubStr($y, $, 1)], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to Len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212874 - 2017-11-12 10:15 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
There's so much here to golf \:\) let me get the easy one for the participation point

537

 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o[9],$b[9]
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next
$m = $s/2

Do
   $y = 0

   For $=1 to Len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $t = Left($i, Len($i) - Len($y))

   For $=1 to Len($y)
      $s = $s + (2*$o[SubStr($y, $, 1)])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, Len($y)), $, 1)], $x, 1) <> substr($b[SubStr($y, $, 1)], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to Len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212875 - 2017-11-12 11:03 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
So Shane.... food for thought... what if you could convert this:

$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

To something like this:
$b=119,3,62,31,75,93,125,83,127,95

Top
#212876 - 2017-11-13 03:54 AM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Well its not really using them for for any numerical value. It’s just random patterns so I could compare two to get the difference in LEDs lit between two numbers. I just numbered the segments and then did 1 or 0 for lit or not lit. I was originally thinking I could do an XOR between two, leaving just differences, but couldn’t get it to work.


Edited by ShaneEP (2017-11-13 03:55 AM)

Top
#212877 - 2017-11-13 05:35 AM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well done,
will return tonight to it, probe your codes and make a temporary scoreboard.
I got a bit of a different approach, with about only ten strokes less, so good job
\:\)
_________________________



Top
#212879 - 2017-11-13 05:30 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Allright, codes verified.

This would result for now in

 Code:
Private Round

ShaneEP         540     5       1
Allen             *     -       1  *no working code from Allen during private round :(

Public Round

Allen           537     5       1
ShaneEP         540     4       1


There are of course lots more strokes to save. So go for it \:\)

_________________________



Top
#212880 - 2017-11-13 05:38 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Just to add to what Allen began...

531
 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o[9],$b[9]
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next
$m = $s/2

Do
   $y = 0

   For $=1 to 0^$i     ;len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $t = Left($i, Len($i) - Len($y))

   For $=1 to Len($y)
      $s = $s + (2*$o[SubStr($y, $, 1)])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, Len($y)), $, 1)], $x, 1) <> substr($b[SubStr($y, $, 1)], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to 0^$t     ;len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212881 - 2017-11-13 05:43 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
What now,
you guys playing tennis?
I see at least 3 more of those little boogers
_________________________



Top
#212882 - 2017-11-13 06:03 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
529

 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o[9],$b[9],$l
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next
$m = $s/2

Do
   $y = 0

   For $=1 to 0^$i     ;len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $l = Len($y)
   $t = Left($i, Len($i) - $l)

   For $=1 to $l
      $s = $s + (2*$o[SubStr($y, $, 1)])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, $l), $, 1)], $x, 1) <> substr($b[SubStr($y, $, 1)], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to 0^$t     ;len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212883 - 2017-11-13 06:06 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
The 0^ trick doesn't work on Int as well as Strings. lol
Top
#212884 - 2017-11-13 06:10 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
525

 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o[9],$b[9],$l,$k
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next
$m = $s/2

Do
   $y = 0

   For $=1 to 0^$i     ;len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $l = Len($y)
   $t = Left($i, Len($i) - $l)

   For $=1 to $l
      $k = SubStr($y, $, 1)
      $s = $s + (2*$o[$k])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, $l), $, 1)], $x, 1) <> substr($b[$k], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to 0^$t     ;len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212885 - 2017-11-13 06:14 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
519. Forgot kix declarations are so lenient. Got rid of those [9]'s.

 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o,$b,$l,$k   ; Removed [9] from declarations
$o = 6,2,5,5,4,5,6,4,7,6
$b = "1110111", "0000011", "0111110", "0011111", "1001011", "1011101", "1111101", "1010011", "1111111", "1011111"

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next

$m = $s/2

Do
   $y = 0

   For $=1 to 0^$i     ;len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $l = Len($y)  ; Made $l to replace multiple Len()s
   $t = Left($i, Len($i) - $l)

   For $=1 to $l
      $k = SubStr($y, $, 1)  ; Made $k to replace multiple Substr()s
      $s = $s + (2*$o[$k])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, $l), $, 1)], $x, 1) <> substr($b[$k], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to 0^$t     ;len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212886 - 2017-11-13 06:23 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
I think I've stressed my eyes enough for now.
Top
#212887 - 2017-11-13 06:32 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: ShaneEP
The 0^ trick doesn't work on Int as well as Strings. lol


Oh yeah, sure, didn't read the code too closely though
_________________________



Top
#212888 - 2017-11-16 01:53 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Cmon guys,
can't be the end of the story.

This "byte-like" string-array seems good enough to get some strokes with a replacement method. Let alone 11 variable declarations. Haven't seen this much very often ;\)


Edited by Jochen (2017-11-16 01:55 PM)
_________________________



Top
#212889 - 2017-11-16 04:56 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Jochen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I just haven't had any time. Man I never realized how much time I had when I was single.
Top
#212905 - 2017-11-19 05:38 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
505
 Code:
function a($i)

Dim $,$s,$m,$x,$y,$t,$d,$o,$b,$l,$k   ; Removed [9] from declarations
$o = 6,2,5,5,4,5,6,4,7,6
$b = 1110111, "0000011", "0111110", "0011111", 1001011, 1011101, 1111101, 1010011, 1111111, 1011111

For $=1 to 0^$i     ;len($i)
  $s = $s + (2*$o[SubStr($i, $, 1)])
Next

$m = $s/2

Do
   $y=0

   For $=1 to 0^$i     ;len($i)
      $y = $y + SubStr($i, $, 1)
   Next

   $l = Len($y)  ; Made $l to replace multiple Len()s
   $t = Left($i, Len($i) - $l)

   For $=1 to $l
      $k = SubStr($y, $, 1)  ; Made $k to replace multiple Substr()s
      $s = $s + (2*$o[$k])

      For $x=0 to 7
         If substr($b[SubStr(Right($i, $l), $, 1)], $x, 1) <> substr($b[$k], $x, 1)
            $d = 1 + $d
         Endif
      Next
   Next

   For $=1 to 0^$t     ;len($t)
      $d = $d + $o[SubStr($t, $, 1)]
   Next

  $i = $y
Until $i < 10

$a = $s - ($m + $d + $o[$y])

endfunction

Top
#212906 - 2017-11-19 05:58 PM Re: Kixgolf - Digital Root Clocks: Public Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

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



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
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.073 seconds in which 0.023 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