JochenAdministrator
(KiX Supporter)
2017-11-12 06:20 PM
Kixgolf - Digital Root Clocks: Public Round

Please post your code

JochenAdministrator
(KiX Supporter)
2017-11-12 06:22 PM
Re: Kixgolf - Digital Root Clocks: Public Round

ended

ShaneEP
(MM club member)
2017-11-12 09:46 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


AllenAdministrator
(KiX Supporter)
2017-11-12 10:15 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


AllenAdministrator
(KiX Supporter)
2017-11-12 11:03 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


ShaneEP
(MM club member)
2017-11-13 03:54 AM
Re: Kixgolf - Digital Root Clocks: Public Round

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.


JochenAdministrator
(KiX Supporter)
2017-11-13 05:35 AM
Re: Kixgolf - Digital Root Clocks: Public Round

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
\:\)


JochenAdministrator
(KiX Supporter)
2017-11-13 05:30 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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 \:\)



ShaneEP
(MM club member)
2017-11-13 05:38 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


JochenAdministrator
(KiX Supporter)
2017-11-13 05:43 PM
Re: Kixgolf - Digital Root Clocks: Public Round

What now,
you guys playing tennis?
I see at least 3 more of those little boogers


ShaneEP
(MM club member)
2017-11-13 06:03 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


ShaneEP
(MM club member)
2017-11-13 06:06 PM
Re: Kixgolf - Digital Root Clocks: Public Round

The 0^ trick doesn't work on Int as well as Strings. lol

ShaneEP
(MM club member)
2017-11-13 06:10 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


ShaneEP
(MM club member)
2017-11-13 06:14 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


ShaneEP
(MM club member)
2017-11-13 06:23 PM
Re: Kixgolf - Digital Root Clocks: Public Round

I think I've stressed my eyes enough for now.

JochenAdministrator
(KiX Supporter)
2017-11-13 06:32 PM
Re: Kixgolf - Digital Root Clocks: Public Round

 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


JochenAdministrator
(KiX Supporter)
2017-11-16 01:53 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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 ;\)


AllenAdministrator
(KiX Supporter)
2017-11-16 04:56 PM
Re: Kixgolf - Digital Root Clocks: Public Round

I just haven't had any time. Man I never realized how much time I had when I was single.

AllenAdministrator
(KiX Supporter)
2017-11-19 05:38 PM
Re: Kixgolf - Digital Root Clocks: Public Round

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


JochenAdministrator
(KiX Supporter)
2017-11-19 05:58 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Nice!

JochenAdministrator
(KiX Supporter)
2017-11-19 06:14 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Final Results

 Code:
Private Round

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

Public Round

Allen           505     5       1
ShaneEP         519     4       1


Shane is the winner for this round with 11 Points followed by Allen with 6 Points.

Overall tournament standings

 Code:
Shane - 23 points
Allen -  6 points


AllenAdministrator
(KiX Supporter)
2017-11-20 04:18 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Here is my partially working code. It's a mess but I wanted to show Shane using numbers and the XOR was possible. \:\)

 Code:
function a($)
  dim $array, $vals, $c, $bit, $bin, $sambin, $tbin, $nextbit, $nextbin, $z, $mz, $mt, $maxtz, $i, $val, $zbin, $maxt, $samt
  ;       0   1  2  3   4   5  6  7  8   9  E
  $array=126,96,91,115,101,55,61,102,127,119,0  

$vals=digitalrootarray($)
for $i=0 to 9
  $val=$vals[$i]
  $c=0
  if $val
    while $val
	? "Val:"$val
      $bit=val(substr($val,1,1))
	  $bin=$array[$bit]
	  $sambin=$bin
	  $zbin=$bin
	  $tbin=$bin
      ? "C:" + $c
      ? "Next Val:" + $vals[$i+1]
      $Nextbit=substr($vals[$i+1],$c+1,1)
	  if $Nextbit=""
		$Nextbin=0
	  else	
	    $NextBin=$array[$nextbit]	
	  endif
	  ? "Bit:" + $Bit
	  ? "Next Bit:" + $nextbit 
	  ? "Bin:" + $Bin	
	  ? "Next Bin:" + $nextbin

	  ? "z:" + $z
	  if $c=$z
        do
		  $mz=$bin mod 2=1
		         ? "mz:" + $mz
		  $maxtz=$maxtz + $mz
          ;$maxtz=$maxtz+($bin mod 2=1)
          $bin = $bin / 2
        Until $bin = .
        $z=$z+1
	    ;? "z:" + $maxtz
	  endif


      if NextBin	
	    ? $Nextbin
		? $tBin
	    $NextBin=$Nextbin^$tBin
        do
		  $mt=$nextbin mod 2=1
		  ? "mt:" + $mt
		  $maxt=$maxt + $mt
          ;$maxt=$maxt+($nextbin mod 2=1)
          $nextbin = $nextbin / 2
        Until $nextbin = .	
	    ? "t:" + $maxt
	  endif
      $c=$c+1	

      do
        $samt=$samt+($sambin mod 2=1)
        $sambin = $sambin / 2
      Until $sambin = .
	  ? "s:" + $samt
	
	  ;$Val=$Val/10

	  $Val=right($Val,-1)
    Loop	
	  ? "MaxT:" + ($maxt	 + $maxtz)
	  ? "SamT:" + 2*$samT
  endif
  ? "_____________________________"
next

$a=2*$samT - ($maxt + $maxtz)
?
endfunction

function digitalrootarray($num)
  dim $val, $vals[9],$i,$dr
  $i=1
  do
    $dr=0
	$vals[$i]=$num
	$i=$i+1
    While $num
 
      $dr=$dr+$num mod 10
      $num=$num/10
    loop
	$num=$dr
  until $dr<10
  $vals[$i]=$dr
  $digitalrootarray=$vals
endfunction


ShaneEP
(MM club member)
2017-11-20 06:41 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Nice.

JochenAdministrator
(KiX Supporter)
2017-11-20 07:32 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Hey!
You guys supposed to be drunk already counting beer and whatnot


ShaneEP
(MM club member)
2017-11-20 08:01 PM
Re: Kixgolf - Digital Root Clocks: Public Round

Was out of town for the weekend. Just now taking a look!