#212873 - 2017-11-12 09:46 PM
Re: Kixgolf - Digital Root Clocks: Public Round
[Re: Jochen]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
540
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
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
There's so much here to golf let me get the easy one for the participation point
537
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
KiX Supporter
Registered: 2003-04-19
Posts: 4548
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
|
|
|
|
#212880 - 2017-11-13 05:38 PM
Re: Kixgolf - Digital Root Clocks: Public Round
[Re: Jochen]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Just to add to what Allen began...
531
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
|
|
|
|
#212882 - 2017-11-13 06:03 PM
Re: Kixgolf - Digital Root Clocks: Public Round
[Re: Jochen]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
529
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
|
|
|
|
#212884 - 2017-11-13 06:10 PM
Re: Kixgolf - Digital Root Clocks: Public Round
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
525
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
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.
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
|
|
|
|
#212905 - 2017-11-19 05:38 PM
Re: Kixgolf - Digital Root Clocks: Public Round
[Re: Allen]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
505
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 313 anonymous users online.
|
|
|