|
KIXgolf: MOAN(), Part II
|
|
Folks: Please post your codes!
|
|
Re: KIXgolf: MOAN(), Part II
|
|
The EXECUTE line has been broken for readability. To run this UDF, you will have to unbreak the long line.
code:
; begin MOAN ;
;! Function MOAN($a,$b,$c) dim $, $z, $r, $1, $2, $3, $4
if $a+$b=$c exit endif
if not isdeclared($n) global $n, $m[32], $s ; create 32bits of zeros and ones $n=$m $m=join($m,0) $n=join($n,1) $s='.' endif
; create a function Z for validation and a modified binaryip function Y ; that is able to convert to/from binary ip addresses $=execute("function z($a) dim $ $a=split($a,$s) $z=ubound($a) $=$a[0] select case $z=0 and $='' $z='' case $z=3 $z=y($a) case $z=0 and 0<$ and 31>$ $z=left($n,$)+left($m,32-$) case 1 $z=a endselect endfunction function y($i) dim $, $b, $c, $a if ubound($i)+1 $a='' for each $ in $i if 0<$ or 255>$ $b=128 while $b if val($) & $b $a=$a+1 else $a=$a+0 endif $b=$b/2 loop endif next else redim $a[3] for $=0 to 3 $b=128 for $c=1 to 8 $a[$]=($b*substr($i,$*8+$c,1))+$a[$] $b=$b/2 next next $a=join($a,$s) endif $y=$a endfunction")
; validating the subnetmask $c=z($c) ; validating the ip address $a=z($a) ; validating the networkid $b=z($b)
; exit if incorrect formatting if $a=a or $b=a or $c=a exit endif
; z is being used in two placed ; to calculate networkid and to check whether ip is in network defined by networkid and subnetmask $z='' for $=1 to 32 $z=$z+(val(substr($a,$,1))&val(substr($c,$,1))) next
select case $a='' ; return array of ips based on networkid and subnetmask $b=left($b,31)+1 $=instrrev($c,'1') $=split(y(left($b,$)+substr($n,$+2)+0),$s) $b=split(y($b),$s) for $1=$b[0] to $[0] for $2=$b[1] to $[1] for $3=$b[2] to $[2] for $4=$b[3] to $[3] $r=ubound($a)+1 redim preserve $a[$r] $a[$r]=''+$1+$s+$2+$s+$3+$s+$4 next next next next $r=join($a,',') case $b='' ; return networkid based on ip and subnetmask ; ip AND subnetmask = networkid if $z<>$a $r=y($z) endif case $c='' ; return subnetmask based on ip and networkid ; ip AND networkid = subnetmask $=instrrev($b,'1') if left($a,$)=left($b,$) for $r=$ to 30 $c=$c+'/'+$r+',' next $c=left($c,len($c)-1) else $c='' endif $r=$c case $a and $b and $c ; check whether ip is part of network defined by networkid and subnetmask $r=$z=$b case 1 ; at least two empty inputs endselect $moan=$r EndFunction ;! ;!
; end MOAN
And here's the results:code:
KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.KIX
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 448 MHz Memory = 448 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/05/30 15:00:27.791 Processing End = 2003/05/30 15:00:27.991 Duration = 0000/00/00 00:00:00.200 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 1265 Thank you for participating in KiXtart Golf!
[ 30. May 2003, 21:39: Message edited by: sealeopard ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$h,$m[32]
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 Dim $h $=$e for $g=1 to 4 $h=$h+iif($/8,"255",$f[$ mod 8])+iif($g<4,".","") $=iif($>8,$-8,0) next $m[$e]=$h next ;End build mask array
$h=$c if $c ;Convert mask bits to 1.2.3.4 format if len($c)<3 $c=$m[$c] endif ; End convert bits else $c="..." endif
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+"."+IIF($b,$b,$)+"."+$c,".") for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
if $a and $h ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+"."+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match if $a and $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],".")[$e]) next if $b $a=$a+" /"+$f endif next
$=IIF($a,split(substr($a,2)),"") else ;Output: Array of all potential IP addresses or empty string if no match $a="" for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+"."+$c+"."+$e+"."+$f next next next next $=IIF($a,split(substr($a,2)),"") endif endif
$moan=$ EndFunction ;! ;!
; end MOAN
code:
KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 848 MHz Memory = 512 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/05/30 15:30:53.505 Processing End = 2003/05/30 15:30:53.595 Duration = 0000/00/00 00:00:00.090 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 836 Thank you for participating in KiXtart Golf!
[ 30. May 2003, 21:27: Message edited by: Howard Bullock ]
|
MightyR1
|
(MM club member)
|
2003-05-30 10:13 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Here's mine, result=1033.
Passes the test, but not useable for determining class A / B ip numbers...
code:
; begin MOAN ; ;! Function MOAN($i,$n,$s) Dim $d,$e,$f,$x,$y,$,$t,$m $d=Split('0 0 0 0') $e=Split(' ') $f=Split('0 128 192 224 240 248 252 254')
$i=Split($i,'.') $n=Split($n,'.')
If $s If InStr($s,'.') $s=Split($s,'.') Else $s=Val($s) $x=$s/8 $y=$s mod 8 $s=$d For $=0 to $x-1 $s[$]=255 Next If $y $s[$x]=$f[$y] EndIf EndIf If $s[3]>252 $s=$e EndIf Else $s=$e EndIf
$m=''
$t=$d $x=0 If $i[0] AND $s[0] For $=0 to 3 $t[$]=Val(LTrim($i[$])) & Val(LTrim($s[$])) Next If $n[0] ;InRange If Join($t)=Join($n) $m=1 Else $m=0 EndIf Else ;NetID $m=Join($t,'.') EndIf
Else
If $i[0] AND $n[0] ;Subnets For $=0 to 3 If Val(LTrim($i[$]))=Val(LTrim($n[$])) $t[$]=255 $x=1+$x Else $=3 EndIf Next
If $x < 4 For $=0 to 7 If (Val(LTrim($i[$x])) & Val($f[$])) = Val(LTrim($n[$x])) $t[$x]=$f[$] $m=$m+Join($t,'.')+',' EndIf Next $m=SubStr($m,1,Len($m)-1) EndIf EndIf
If $n[0] AND $s[0] ;IPs For $=0 to 3 If Val(LTrim($s[$]))=255 $t[$]=Val(LTrim($n[$])) $x=1+$x EndIf Next $y='' For $=0 to 255 If (Val(LTrim($s[$x])) & $) = Val(LTrim($n[$x])) $y=$y+$+' ' EndIf Next $y=Split(SubStr($y,1,Len($y)-1))
If $x=3 For $=1+$y[0] to Val($y[Ubound($y)])-1 $t[3]=$ $m=$m+Join($t,'.')+',' Next $m=SubStr($m,1,Len($m)-1) EndIf EndIf EndIf
$moan=$m
EndFunction
;! ;!
; end MOAN
|
MightyR1
|
(MM club member)
|
2003-05-30 10:57 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Howard,
looked at your code... Again we were thinking alike...
Nice to see how you solved the IP thingie...
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 02:07 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
hoby, I saw right away a way to make your udf shorter than mine. anyway, will not crack it before posting my code, thus:
code:
Function MOAN($a, $n, $m) dim $i,$s,$,$!,$z
for each $! in split($a+"."+$n+"."+$m,".") $=256 do $=$/2 if 0<=0+$!-$ $z=$z+"1" $!=-$+$! else $z=$z+"0" endif until 1=$ next $i=left($z,32) $s=substr($z,33,32)
if 2<len($m) $m=instr(right($z,32),0)-1 endif select
case 0=$m for $=instrrev($s,1) to 31 if moan($a,$n,$) $m=$m+" /"+$ endif next $=substr($m,2)
case 0=$n $s=0 for $!=1 to $m if 2>$s $s=256 $n=$n+$+"." $=0 endif $s=$s/2 if 1=substr($i,$!,1) $=$+$s endif next $=iif($m>30,"",substr($n+$,3))
case 0=$a $!=0,128,192,224,240,248,252,254,255 $=$! $n=split($n,".") for $s=0 to 3 $i=-8*$s+$m $i=iif($i>8,8,$i) $[$s]=255+$n[$s]-iif($i,$![$i],0) next for $s=$n[0] to $[0] for $!=$n[1] to $[1] for $m=$n[2] to $[2] for $i=1+$n[3] to $[3]-1 $a=$a+" "+$s+"."+$!+"."+$m+"."+$i next next next next $=substr($a,2)
case 1 $=iif(left($i,$m)=left($s,$m) & $i=>$s ,1,0) ;and instr(right($i,32-$m),0),1,0) ; x.x.x.255 proper ip? endselect $moan=iif(instr($," "),split($),$)
EndFunction
this comes to 807. added one stroke to remove a problem with special subnet-masks. it probably still has one... at least I feel like it does
|
|
Re: KIXgolf: MOAN(), Part II
|
|
You are a better programmer than I. I stared at the code for 30 minutes and did not see anything. I know there has to be something, but these eyes just see it.
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 02:56 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
now as I look at your code. damn, it's darn similar to mine!
they are like evolution versions of same base udf
anyway, the thinking of ours is different. you coded a working code, I coded a shorter one
meaning that your udf has larger scopes for variables and thus cutting of strokes affects too many places...
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Howard: I think I can see some stuff, too, that can be shortened.
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 05:52 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
damn... I feel like obligated on cuttin' his code as took his score on last day...
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Go to it guys. I don't have a lot of time today. I woudl be interested in seeing your ideas.
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 06:13 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
now this is weird. copied the code from the board and ran it. got only "unexpected command, line 0"
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I just copied the program from the board and it ran just fine.
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 08:08 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
yeah it had copied the "]" from the code-tag
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 08:20 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, hoby...
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$h,$m[32]
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 $h=$c for $e=8 to 31 ; Dim $h $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,".","") $=iif($>8,$-8,0) next ; $m[$e]=$h if $e=$c $c=$m[$e] endif next ;End build mask array
;Convert mask bits to 1.2.3.4 format $c=iif($c,$c,"...")
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+"."+IIF($b,$b,$)+"."+$c,".") for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
if $a and $h ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+"."+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match if $a and $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],".")[$e]) next if $b $a=$a+" /"+$f endif next
$=IIF($a,split(substr($a,2)),"") else ;Output: Array of all potential IP addresses or empty string if no match $a="" for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+"."+$c+"."+$e+"."+$f next next next next $=IIF($a,split(substr($a,2)),"") endif endif
$moan=$ EndFunction ;! ;!
; end MOAN
there is a start for you that brings it to 824... I bet we can make your code shorter than mine
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 08:42 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
still silent? 811 with your code: {edit} well, 807... won't take the bet yet?
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32]
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,".","") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+"."+IIF($b,$b,$)+"."+iif($c,$c,$),".") for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
if $a and $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+"."+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match if $a and $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],".")[$e]) next if $b $a=$a+" /"+$f endif next
$=IIF($a,split(substr($a,2)),"") else ;Output: Array of all potential IP addresses or empty string if no match $a="" for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+"."+$c+"."+$e+"."+$f next next next next $=IIF($a,split(substr($a,2)),"") endif endif
$moan=$ EndFunction ;! ;!
; end MOAN
[ 31. May 2003, 20:46: Message edited by: Lonkero ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Doh!
I can't believe I missed that.
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 08:59 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, 775 with your code. please fight back!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32]
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,".","") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+"."+IIF($b,$b,$)+"."+iif($c,$c,$),".") for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
if $a and $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+"."+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match if $a and $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],".")[$e]) next if $b $a=$a+" /"+$f endif next
else ;Output: Array of all potential IP addresses or empty string if no match $a="" for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+"."+$c+"."+$e+"."+$f next next next next endif $=IIF($a,split(substr($a,2)),"") endif $moan=$ EndFunction ;! ;!
; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-05-31 09:00 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I go out. hopefully I have competition when I come back
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Very good coding Jooel. Don't know why I did not see some of those good optimizations. Good job so far. I now have a few minutes to see if I can regain ownership of my code and best score.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I really like the:
code:
if $e=$c $c=$m[$e] endif
reduction. It is so logical.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Okay, got an improvement for Howard's code:
code:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/05/31 16:19:10.920 Processing End = 2003/05/31 16:19:10.990 Duration = 0000/00/00 00:00:00.069 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 771
with the following code:code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32],$d
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
$d="."
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,$d,"") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+$d+IIF($b,$b,$)+$d+iif($c,$c,$),$d) for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
;if $a and $c if $a & $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+$d+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match ; if $a and $b if $a & $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],$d)[$e]) next if $b $a=$a+" /"+$f endif next
else ;Output: Array of all potential IP addresses or empty string if no match $a="" for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next endif $=IIF($a,split(substr($a,2)),"") endif $moan=$ EndFunction ;! ;! ; end MOAN
[ 31. May 2003, 22:13: Message edited by: sealeopard ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I am glad to see everyone likes my code. But am dismayed that I could design a good approach but fail to see improvements you guys have found so far.
Hopefully, I will be able make another post.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 12:20 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I see we have competition here. so I will reduce too:
quote: KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 797 MHz Memory = 376 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 01:27:54.047 Processing End = 2003/06/01 01:27:54.207 Duration = 0000/00/00 00:00:00.160 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 766
Thank you for participating in KiXtart Golf!
with:
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32],$d
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
$d="."
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,$d,"") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+$d+IIF($b,$b,$)+$d+iif($c,$c,$),$d) for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
;if $a and $c if $a & $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+$d+($[$c] & $[$c+8]) next $=substr($e,2)
if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match ; if $a and $b if $a & $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],$d)[$e]) next if $b $a=$a+" /"+$f endif next
else ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next endif $=IIF($a,split(substr($a,2)),"") endif $moan=$ EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 12:34 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, not sure about this. with some spooky input someone could break it but:
quote: KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 797 MHz Memory = 376 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 01:42:24.108 Processing End = 2003/06/01 01:42:24.238 Duration = 0000/00/00 00:00:00.130 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 748
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32],$d
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
$d="."
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,$d,"") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+$d+IIF($b,$b,$)+$d+iif($c,$c,$),$d) for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
;if $a and $c if $a & $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+$d+($[$c] & $[$c+8]) next $=substr($e,2) if instr($a,$) $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(instr($b,$),1,0) endif else
;Output: Array of all potential subnet masks or empty string if no match ; if $a and $b if $a & $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],$d)[$e]) next if $b $a=$a+" /"+$f endif next
else ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next endif $=IIF($a,split(substr($a,2)),"") endif $moan=$ EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 01:11 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, I think... not sure but as I thought of it, the last score can't hold input like: "142. 34.120.145" as IP as example. but 766 still remains though
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 02:04 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, new 1-hit reduction, what ya like? quote: KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 797 MHz Memory = 376 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 03:11:06.511 Processing End = 2003/06/01 03:11:06.621 Duration = 0000/00/00 00:00:00.109 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 765
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$e,$f,$g,$m[32],$d
; Convert all input data to numeric array elements. ; The array is 12 elements each element is value (0-255). ;'$' hold the input data and later is the array version of the input data
$d="."
;Build Subnet Mask ARARRY $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e for $g=1 to 4 $m[$e]=$m[$e]+iif($/8,"255",$f[$ mod 8])+iif($g<4,$d,"") $=iif($>8,$-8,0) next if $e=$c $c=$m[$e] endif next ;End build mask array
;build array of input values by splitting a string. Then convert to integers ;IPaddr = $[0..3] NetID = $[4..7] Mask = $[8..11] $="..." $=split(IIF($a,$a,$)+$d+IIF($b,$b,$)+$d+iif($c,$c,$),$d) for $e=0 to 11 $[$e]=0+$[$e] next ;End build array
;if $a and $c if $a & $c ;Output: Network ID or empty string if no match
;Calculate NetworkID using $ array $e="" for $f=0 to 3 $e=$e+$d+($[$f] & $[$f+8]) next $=substr($e,2)
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID $=iif( $b,IIF(join(split($b),"")=$,1,0),iif(join(split($a),"")=$,"",$)) else
;Output: Array of all potential subnet masks or empty string if no match ; if $a and $b if $a & $b $a="" for $f=8 to 31 $b=1 for $e=0 to 3 $b=$b & $[$e+4]=($[$e] & 0+split($m[$f],$d)[$e]) next if $b $a=$a+" /"+$f endif next
else ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[8] for $c=$[5] to $[5] + 255 - $[9] for $e=$[6] to $[6] + 255 - $[10] for $f=$[7]+1 to $[7] + 254 - $[11] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next endif $=IIF($a,split(substr($a,2)),"") endif $moan=$ EndFunction ;! ;! ; end MOAN
|
|
Re: KIXgolf: MOAN(), Part II
|
|
code:
KiXtart KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 848 MHz Memory = 512 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 00:37:40.715 Processing End = 2003/06/01 00:37:40.815 Duration = 0000/00/00 00:00:00.099 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 746
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$i,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254,255 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next $=split(substr($c,2))
;End build mask array
if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) for $g=0 to 11 $[$g]=0+$[$g] next if $a="" ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[0] for $c=$[5] to $[5] + 255 - $[1] for $e=$[6] to $[6] + 255 - $[2] for $f=$[7]+1 to $[7] + 254 - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $=split(substr($a,2)) else ;Calculate NetworkID using $ array $e="" for $c=0 to 3 $e=$e+$d+($[$c] & $[$c+8]) next $=substr($e,2) if join(split($a),"")=$ $="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $=IIF(join(split($b),"")=$,1,0) endif endif endif $moan=$ EndFunction ;! ;! ; end MOAN
|
|
Re: KIXgolf: MOAN(), Part II
|
|
code:
KiXtart Version = 4.21 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 848 MHz Memory = 512 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 02:27:09.540 Processing End = 2003/06/01 02:27:09.651 Duration = 0000/00/00 00:00:00.110 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 734
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) for $g=0 to 11 $[$g]=0+$[$g] next if $a="" ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[0] for $c=$[5] to $[5] + 255 - $[1] for $e=$[6] to $[6] + 255 - $[2] for $f=$[7]+1 to $[7] + 254 - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+($[$e] & $[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
[ 01. June 2003, 08:20: Message edited by: Howard Bullock ]
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 11:17 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 12:24:18.969 Processing End = 2003/06/01 12:24:19.130 Duration = 0000/00/00 00:00:00.161 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 733
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) for $g=0 to 11 $[$g]=0+$[$g] next if 0=$a ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[4] + 255 - $[0] for $c=$[5] to $[5] + 255 - $[1] for $e=$[6] to $[6] + 255 - $[2] for $f=$[7]+1 to $[7] + 254 - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+($[$e] & $[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
MightyR1
|
(MM club member)
|
2003-06-01 11:34 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Nice job...
Will try to nibble some strokes of the latest code...
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 11:59 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
yea, do that. but don't get below: quote: KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 13:06:30.229 Processing End = 2003/06/01 13:06:30.359 Duration = 0000/00/00 00:00:00.129 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 717
hoby, I thought already at start that your waste was the large $-array and now it seems that this can indeed go to 600 and below if we just get ourself rid of that. code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if 0=$a ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=0+$[4] to 255 + $[4] - $[0] for $c=0+$[5] to 255 + $[5] - $[1] for $e=0+$[6] to 255 + $[6] - $[2] for $f=0+$[7]+1 to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
MightyR1
|
(MM club member)
|
2003-06-01 02:09 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Does the Lonk never stop???
Waiting for someone to break the 700-border... Could it be me??
|
|
Re: KIXgolf: MOAN(), Part II
|
|
This is sheer madness! Will I never be the master of my own code? Back to the drawing the board.
Good job Lonk
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Lonk, take that! Pat, you too! Just a cheap couple strokes, but it is enough for now. code:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 10:08:43.400 Processing End = 2003/06/01 10:08:43.500 Duration = 0000/00/00 00:00:00.099 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 715
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if 0=$a ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=0+$[4] to 255 + $[4] - $[0] for $c=0+$[5] to 255 + $[5] - $[1] for $e=0+$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
[ 01. June 2003, 16:04: Message edited by: Howard Bullock ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Make that 709! code:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 10:16:03.354 Processing End = 2003/06/01 10:16:03.464 Duration = 0000/00/00 00:00:00.110 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 709
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if 0=$a ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $c=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
|
Re: KIXgolf: MOAN(), Part II
|
|
And 2 more strokes bite the dust! code:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 10:35:28.748 Processing End = 2003/06/01 10:35:28.858 Duration = 0000/00/00 00:00:00.110 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 707
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if 0=$a ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $c=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a else ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 05:15 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
[ 01. June 2003, 17:17: Message edited by: Lonkero ]
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 05:16 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
shit!
you are too quick to post!
|
Lonkero
|
(KiX Master Guru)
|
2003-06-01 05:18 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 18:26:10.649 Processing End = 2003/06/01 18:26:10.830 Duration = 0000/00/00 00:00:00.180 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 705
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) else $h=0 endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $c=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$c+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
[ 01. June 2003, 17:19: Message edited by: Lonkero ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Your turn Lonkero code:
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/01 22:51:10.972 Processing End = 2003/06/01 22:51:11.072 Duration = 0000/00/00 00:00:00.100 # Loops = 1 KiXGolf Result = passed (10 out of 10 correct) KiXGolf Score = 697
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+$[$e+8]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 10:12 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
my turn? sure I'll do my job. and now it's your turn quote: KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 11:18:51.899 Processing End = 2003/06/02 11:18:52.249 Duration = 0000/00/00 00:00:00.350 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 690
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $="..." $=split($c+$d+IIF($b,$b,$),$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 10:19 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 11:26:32.060 Processing End = 2003/06/02 11:26:32.411 Duration = 0000/00/00 00:00:00.351 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 679
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b+"...",$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 10:23 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
should I continue?
KiXGolf Score = 673
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=IIF($d+join(split($b),"")=$c,1,0) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:07 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
hehee! check this score quote:
KiXtart KiXtart Version = 4.21 Release Candidate 1 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium II Speed = 398 MHz Memory = 320 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 14:13:39.289 Processing End = 2003/06/02 14:13:39.649 Duration = 0000/00/00 00:00:00.360 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 666
Thank you for participating in KiXtart Golf!
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=iif($>8,$-8,0) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=($d+join(split($b),"")=$c) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:10 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
got rid of that number: 663 code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=($d+join(split($b),"")=$c) endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:11 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: KiXtart KiXtart Version = 4.21 Release Candidate 1 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium II Speed = 398 MHz Memory = 320 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 14:29:22.465 Processing End = 2003/06/02 14:29:22.805 Duration = 0000/00/00 00:00:00.340 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 661
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=$d+join(split($b),"")=$c endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $moan=iif(len($c)>1,split(substr($c,2)),$c) EndFunction ;! ;! ; end MOAN
[ 02. June 2003, 13:22: Message edited by: Lonkero ]
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:30 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
660 code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) if $a ;Calculate NetworkID using $ array $c="" for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=$d+join(split($b),"")=$c endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $a = $a+" "+$b+$d+$h+$d+$e+$d+$f next next next next $c=$a endif endif $=$c,split(substr($c,2)) $moan=$[len($c)>1] EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:41 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
and still have some work-time left... quote:
KiXtart KiXtart Version = 4.21 Release Candidate 1 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium II Speed = 398 MHz Memory = 320 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 14:47:28.406 Processing End = 2003/06/02 14:47:28.757 Duration = 0000/00/00 00:00:00.350 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 657
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) $c="" ;Calculate NetworkID using $ array for $e=0 to 3 if $a $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) else $[$e]=255 + $[$e+4] - $[$e] endif next if $a if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=$d+join(split($b),"")=$c endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to $[0] for $h=$[5] to $[1] for $e=$[6] to $[2] for $f=1+$[7] to $[3]-1 $c = $c+" "+$b+$d+$h+$d+$e+$d+$f next next next next endif endif $=$c,split(substr($c,2)) $moan=$[len($c)>1] EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 01:43 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: KiXtart KiXtart Version = 4.21 Release Candidate 1 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium II Speed = 398 MHz Memory = 320 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 14:50:01.957 Processing End = 2003/06/02 14:50:02.308 Duration = 0000/00/00 00:00:00.350 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 655
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$f,$g,$h,$m[3] $d="."
;Build Subnet Mask $f=0,128,192,224,240,248,252,254 for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $m[$g]=iif($/8,255,$f[$ mod 8]) $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) $c="" if $a ;Calculate NetworkID using $ array
for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=$d+join(split($b),"")=$c endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $f=1+$[7] to 254 + $[7] - $[3] $c = $c+" "+$b+$d+$h+$d+$e+$d+$f next next next next endif endif $=$c,split(substr($c,2)) $moan=$[len($c)>1] EndFunction ;! ;! ; end MOAN
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 02:15 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: KiXtart KiXtart Version = 4.21 Release Candidate 1 KiXGolf Script = kixgolf_moan.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium II Speed = 398 MHz Memory = 320 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXtart Golf Score Tournament = KiXtart Golf: MOAN - Mother Of All Networks Processing Start = 2003/06/02 15:22:48.305 Processing End = 2003/06/02 15:22:48.695 Duration = 0000/00/00 00:00:00.389 # Loops = 1 KiXGolf Result = passed (9 out of 9 correct) KiXGolf Score = 652
code:
; begin MOAN ; ;! Function moan($a,$b,$c) Dim $,$d,$e,$g,$h,$m[3]
;Build Subnet Mask for $e=8 to 31 $=$e $h=1 for $g=0 to 3 $d=0,128,192,224,240,248,252,254 $m[$g]=iif($/8,255,$d[$ mod 8]) $d="." $=($>8)*($-8) if $a & $b $h=$h & split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g]) endif next if $h $c=$c+" /"+$e endif if $e=$c $c=join($m,$d) endif next ;End build mask array if instr($c,$d) ;build array of input values by splitting a string. Then convert to integers ; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11] $=split($c+$d+$b,$d) $c="" if $a ;Calculate NetworkID using $ array
for $e=0 to 3 $c=$c+$d+(0+$[$e] & 0+split($a,$d)[$e]) next if $d+join(split($a),"")=$c $c="" endif
;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 ;Input NetworkID = Calculated NetworkID if $b $c=$d+join(split($b),"")=$c endif else ;Output: Network ID or empty string if no match ;Output: Array of all potential IP addresses or empty string if no match for $b=$[4] to 255 + $[4] - $[0] for $h=$[5] to 255 + $[5] - $[1] for $e=$[6] to 255 + $[6] - $[2] for $a=1+$[7] to 254 + $[7] - $[3] $c = $c+" "+$b+$d+$h+$d+$e+$d+$a next next next next endif endif $=$c,split(substr($c,2)) $moan=$[len($c)>1] EndFunction ;! ;! ; end MOAN
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Quick remark. The MOAN code will NOT work for subnet masks like 255.0.0.0 if provided as /8, thus it would fail a test like this:
MOAN('126.0.0.1','126.0.0.0/8')
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 03:02 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
you are right. also, the output of subnet masks with slash in them does not fit to the moan idea. the output should be like the input.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
My mistake, I meant MOAN('126.0.0.1','126.0.0.0',8). I started using Howards CIDR-conversion code in a new UDF that I'm writing and I noticed that subnetmasks of 0-8 will not resolve correctly. It actually was an easy fix but has a 3-stroke penalty.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 03:27 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
well, the 8 was hardcoded in his code right from the start... but wonder who thought that this golf should work on greater space than a-class...
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I did not say that it IS limited to /9 and higher . Thus, technically, it will have to cover the /0 to /8 range, too.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-02 04:54 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
well, I surely asked it during first period.
and the current code is limited to 8 and higher
so, if it fails that, there is something weird and it needs to be tested... [ 02. June 2003, 16:55: Message edited by: Lonkero ]
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Well, it looks like I will have to seriously review the current state of things when I get to the hotel this evening.
|
MightyR1
|
(MM club member)
|
2003-06-02 06:12 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
My compliments to Jooel and Howard!! You guys are really quick... I give up...
Job well done guys...
|
Lonkero
|
(KiX Master Guru)
|
2003-06-03 10:25 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
now I'm starting to be scared. it's wednesday tomorrow...
hoby, if you got better code, post it already...
|
Lonkero
|
(KiX Master Guru)
|
2003-06-04 08:49 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
ding dong. closed are we?
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Yes, we're closed, but I'll be busy with stuff for at least another hour.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Good job Lonkero.
Some of the feeling this outing caused?
thanks Jens. [ 04. June 2003, 22:50: Message edited by: Howard Bullock ]
|
Shawn
|
(KiX Supporter)
|
2003-06-04 11:10 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
In true golf tradition, there is polite applause from the crowd. As a spectator, would like to say "Thanks for the entertainment boys" ! Special thanks to Jens for organizing this tournament.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
FIRST ROUND
First to post a valid score: Howard Bullock on 25. May 2003 02:25 with a score of 1460
Best score posted: Lonkero on 30. May 2003 16:07 with a score of 806
SECOND ROUND
Initial scores: Sealeopard with 1265 MightyR1 with 1033 (admitted non-working code in some non-tested cases) Howard Bullock with 836 Lonkero with 807
Final improved score: Lonkero on 02. June 2003 14:15 with a score of 652 (an improvement of roughly 22%, based on Howard Bullock's codebase)
Congratulation to all participants!
|
Lonkero
|
(KiX Master Guru)
|
2003-06-05 12:14 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
hmm... we need better testing that's for sure.
806 for first round and then 807 after many posters???
need to work on the orgarinizing of the golf.
anyway, once again had good fight, thanks to hoby who kept on fighting and ofcourse jens who brought so hard task that not many participated.
not sure if it was good thing or bad but at least it lead to some good findings about kixtart scripting and I think that is the main task of golf.
so, thanks to jens of good golf!
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I'll come up with something easier for the next round.
|
MightyR1
|
(MM club member)
|
2003-06-05 09:22 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Nice Tournament, had a lot of fun...
Liked the battle between the 'Giants'...
|
Chris S.
|
(MM club member)
|
2003-06-05 02:40 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Good job guys! Congrats to all.
Now, anyone care to comment the code and 'splain it to us mortals so we can learn something too?
|
Lonkero
|
(KiX Master Guru)
|
2003-06-05 06:17 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
comment? damn, there is almost as many comment lines as code lines! what else you want?
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Chris, I don't have much time now. Is there something or some part of the program that you would like a quick recap?
At the moment I on a phone connection in a Microsoft sales office so I do not know how long I will remain connected until this evening. [ 05. June 2003, 18:23: Message edited by: Howard Bullock ]
|
MightyR1
|
(MM club member)
|
2003-06-05 10:15 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Chris,
I'm busy making the code a more readable UDF. Will post it here in an hour or two...
Since the latest code wasn't one I wrote, Jooel and Howard are hereby asked to modify and publish the UDF in the UDF forum...
|
Chris S.
|
(MM club member)
|
2003-06-05 10:42 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Thanks, guys.
My thought behind asking for commented code is to understand the methods you guys took to make the code more efficient and get an understanding for how it works. That way, even though I didn't participate I can still learn from the experience. Which is what I think the intention of a golf outing is.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-05 11:13 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
chris, actually. I think you are so leveled coder/specialist that you would in hour come out with the proper semi-coding.
it's pretty easy if you go line by line. but think you are too lazy to do it on this one as you haven't participated
not sure am I sober enough to provide even the semi-code but maybe hoby is
|
MightyR1
|
(MM club member)
|
2003-06-05 11:53 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Chris, here ye go...
I added some variables to make things more clear. This version passes the tests with a score of 1184
Jooel, Howard,
please verify my comments and if necessary modify the comments. If all is OK, then it will be posted as a UDF.
code:
;**************************************************************************** ; ;SCRIPT/FUNCTION : MOAN() ; ;ACTION : Depending on the input, returns IP-addresses, Subnets, ; NetworkIDs or Yes-/No-is_in_subnet ; ;AUTHOR : Jooel Nieminen and Howard Bullock ; ;CONTRIBUTORS : Patrick Rutten (MightyR1@hotmail.com) ; - making the code readable ; ;VERSION : 1.0 ; - 2003-06-05 Initial Release ; ;SYNTAX : MOAN($IP, $NetworkID, $SubnetMask) ; ;PARAMETERS : ; ;RETURNS : Input: IP, NetworkID, SubnetMask ; Output: 1 If the IP is a member of a network defined ; by NetworkID AND SubnetMask, otherwise 0 ; ; Input: IP, NetworkID ; Output: Array of all potential SubnetMasks ; (CIDR notation) OR empty string If no match ; ; Input: IP, SubnetMask ; Output: NetworkID OR empty string If no match ; ; Input: NetworkID, SubnetMask ; Output: Array of all potential IP addresses OR ; empty string If no match ; ;REMARKS : This UDF is a result of a KiXGolf Tournament hosted by ; Sealeopard. Follow the links below to see how the game ; was played. ; ; Assumption: Network/broadcast addresses are NOT ; available as regular IP addresses though RFC3021 ; allows /31 networks (two IP addresses where the ; network/broadcast addresses are used as regular ; IP addresses) ; ; At least two input parameters must be provided. ; ; If the output consists of an array of IP addresses, ; then the IP addresses must be sorted In ascending order. ; ; The subnet mask $SubnetMask can be either the traditional ; four-octets OR the alternate CIDR number, ; e.g. 255.255.255.0 AND 24. ; ; The parameters can contain up to two spaces between the ; decimal points AND the number, e.g. 192.168.0.10 AND ; 192.168. 0. 10 should be treated the same. ; ;DEPENDENCIES : ; ;EXAMPLE(S) : ; [Example 1] ; IP=192.168.1.2 ; NetworkID=192.168.1.0 ; SubnetMask=255.255.255.0 ; MOAN=1 ; ; [Example 2] ; IP=192.168.0.1 ; NetworkID=192.168.1.0 ; SubnetMask=255.255.255.0 ; MOAN=0 ; ; [Example 3] ; IP= ; NetworkID=10.10.5.4 ; SubnetMask=255.255.255.252 ; MOAN=10.10.5.5,10.10.5.6 ; ; [Example 4] ; IP=192.10.128.55 ; NetworkID= ; SubnetMask=27 ; MOAN=192.10.128.32 ; ; [Example 5] ; IP=10.10.10.2 ; NetworkID= ; SubnetMask=255.255.255.254 ; MOAN= ; ; [Example 6] ; IP=10.10.10.2 ; NetworkID=10.10.10.0 ; SubnetMask= ; MOAN=/23,/24,/25,/26,/27,/28,/29,/30 ; ; [Example 7] ; IP=192.168.99.55 ; NetworkID=192.168.99.55 ; SubnetMask= ; MOAN= ; ;KNOWN ISSUES : ; ;KIXTART VER : 4.2x ; ;KIXTART BBS : KiXGolf: MOAN(), Mother Of All Networks --> ; - http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=14;t=000720 ; ; KixGolf: MOAN(), Part II --> ; - http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=14;t=000748 ; ;**************************************************************************** ; ;! Function MOAN($IP,$NetworkID,$SubnetMask) ;declaring variables Dim $cidrarray,$dot,$dummy,$subnetarray,$count,$help,$maskarray[3],$count2 Dim $first,$second,$third,$fourth ;build SubnetMask; starting from bit 8 through 31 For $count=8 to 31 $dummy=$count $help=1 ;determine each octet For $count2=0 to 3 $cidrarray=0,128,192,224,240,248,252,254 ;if bitnumber/8 > 0, the octet is 255 else the mod must be determined ;255.255.248.0=11111111.11111111.11111000.00000000 $maskarray[$count2]=IIf($dummy/8,255,$cidrarray[$dummy mod 8]) $dot="." ;8 must be substracted if one "moves" to the next octed $dummy=($dummy>8)*($dummy-8) ;& the IP, NetworkID and the SubnetMask octets to see if the are "compatible" If $IP & $NetworkID $help=$help & Split($NetworkID,$dot)[$count2]=(0+Split($IP,$dot)[$count2] & $maskarray[$count2]) EndIf Next ;if all variables are "compatible", add the bit number to the subnet string in CIDR notation If $help $subnetMask=$SubnetMask+" /"+$count EndIf ;if current bit=current subnetmask then convert the SubnetMask to ;normal notation, e.g. 255.255.248.0 If $count=$SubnetMask $SubnetMask=Join($maskarray,$dot) EndIf Next ;end Built subnet mask $MOAN=$SubnetMask ;if the SubnetMask contains a point, calculate IP-addresses, NetworkIDs ;or Yes-/No-is_in_subnet If InStr($SubnetMask,$dot) $dummy=Split($SubnetMask+$dot+$NetworkID,$dot) $MOAN="" ;if IP is provided, determine NetworkIDs If $IP ;calculate the NetworkID For $count=0 to 3 $MOAN=$MOAN+$dot+(0+$dummy[$count] & 0+Split($IP,$dot)[$count]) Next ;if IP=NetworkID there is no subnet, thus returning empty If $dot+Join(Split($IP),"")=$MOAN $MOAN="" EndIf ;if NetworkID is provided: ; - return .0 if the calculated NetworkID <> provided NetworkID, ; IP is not in subnet ; - return .1 if the calculated NetworkID = provided NetworkID ; IP is in subnet If $NetworkID $MOAN=$dot+Join(Split($NetworkID),"")=$MOAN EndIf ;determine array of IP numbers Else ;first octet For $first=$dummy[4] to 255 + $dummy[4] - $dummy[0] ;second octet For $second=$dummy[5] to 255 + $dummy[5] - $dummy[1] ;Third octet For $third=$dummy[6] to 255 + $dummy[6] - $dummy[2] ;Fourth octet For $fourth=1+$dummy[7] to 254 + $dummy[7] - $dummy[3] $MOAN = $MOAN+" "+$first+$dot+$second+$dot+$third+$dot+$fourth Next Next Next Next EndIf EndIf ;return the result $dummy=$MOAN,Split(SubStr($MOAN,2)) $MOAN=$dummy[Len($MOAN)>1] EndFunction ;! ;! ; end MOAN
{2003-06-06-11:45 changed after Jooel's suggestions} [ 06. June 2003, 11:38: Message edited by: MightyR1 ]
|
MightyR1
|
(MM club member)
|
2003-06-06 10:08 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
*Blob*
Jooel, Howard,
No comments???
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 10:10 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
well, at least you changed the code totally. or is this based on something else than the winning code?
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 10:37 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
k, re-read it... those source-comments makes it really really hard to read. indeed it's almost like the last code with some drawbacks.
like the size already says. many of the tricks has been removed for easy understandability... looks like rape but quess someone can read it and even understand a piece or even 2. but I bet most of the normal users still don't get it and they end up screwing it up.
well, that's not my problem so why not. didn't read the comments yet but bet there is something to work to get them "correct"
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 10:40 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
ctrl+h... replace all "point" with "dot"
if $dum is supposed to mean dummy write it totally. then $h should be $dummy2 or $help.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 10:47 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
quote: ;if all variables are "compatible", add the subnet to the array in CIDR notation
heh. afaik, it's not array. nor it's about all variables but matching mask with possibly given ip and subnet.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 10:50 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
also, now as you renamed some of the variables, for convenience and speed their place should be changed back to what they were.
example, $cidrarray and $point (dot) should be defined at the very beginning if used with their own separate variable-names.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 11:02 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
oh... I might ask for reviewing of: code:
$dum=Split($SubnetMask+$point+$NetworkID,$point)
hoby and all. this was just for golf-score and the score does not go so much up if devided "properly". as the code already does many compromises, this could be added to them.
|
MightyR1
|
(MM club member)
|
2003-06-06 11:43 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Thnx for the input,
Changed code a little, to make it more readable. The in the Golf reusing variables takes the char count down, but for "normal operation" re using variables may be confusing. Therefore adding some variables...
Will rename $dum, $point and $h.
Please clarify: quote: example, $cidrarray and $point (dot) should be defined at the very beginning if used with their own separate variable-names.
Updated code: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=14;t=000748;p=3#000074
|
Lonkero
|
(KiX Master Guru)
|
2003-06-06 03:56 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
code:
;**************************************************************************** ; ;SCRIPT/FUNCTION : MOAN() ; ;ACTION : Depending on the input, returns IP-addresses, Subnets, ; NetworkIDs or Yes-/No-is_in_subnet ; ;AUTHOR : Jooel Nieminen and Howard Bullock ; ;CONTRIBUTORS : Patrick Rutten (MightyR1@hotmail.com) ; - making the code readable ; ;VERSION : 1.0 ; - 2003-06-05 Initial Release ; ;SYNTAX : MOAN($IP, $NetworkID, $SubnetMask) ; ;PARAMETERS : ; ;RETURNS : Input: IP, NetworkID, SubnetMask ; Output: 1 If the IP is a member of a network defined ; by NetworkID AND SubnetMask, otherwise 0 ; ; Input: IP, NetworkID ; Output: Array of all potential SubnetMasks ; (CIDR notation) OR empty string If no match ; ; Input: IP, SubnetMask ; Output: NetworkID OR empty string If no match ; ; Input: NetworkID, SubnetMask ; Output: Array of all potential IP addresses OR ; empty string If no match ; ;REMARKS : This UDF is a result of a KiXGolf Tournament hosted by ; Sealeopard. Follow the links below to see how the game ; was played. ; ; Assumption: Network/broadcast addresses are NOT ; available as regular IP addresses though RFC3021 ; allows /31 networks (two IP addresses where the ; network/broadcast addresses are used as regular ; IP addresses) ; ; At least two input parameters must be provided. ; ; If the output consists of an array of IP addresses, ; then the IP addresses must be sorted In ascending order. ; ; The subnet mask $SubnetMask can be either the traditional ; four-octets OR the alternate CIDR number, ; e.g. 255.255.255.0 AND 24. ; ; The parameters can contain up to two spaces between the ; decimal points AND the number, e.g. 192.168.0.10 AND ; 192.168. 0. 10 should be treated the same. ; ;DEPENDENCIES : ; ;EXAMPLE(S) : ; [Example 1] ; IP=192.168.1.2 ; NetworkID=192.168.1.0 ; SubnetMask=255.255.255.0 ; MOAN=1 ; ; [Example 2] ; IP=192.168.0.1 ; NetworkID=192.168.1.0 ; SubnetMask=255.255.255.0 ; MOAN=0 ; ; [Example 3] ; IP= ; NetworkID=10.10.5.4 ; SubnetMask=255.255.255.252 ; MOAN=10.10.5.5,10.10.5.6 ; ; [Example 4] ; IP=192.10.128.55 ; NetworkID= ; SubnetMask=27 ; MOAN=192.10.128.32 ; ; [Example 5] ; IP=10.10.10.2 ; NetworkID= ; SubnetMask=255.255.255.254 ; MOAN= ; ; [Example 6] ; IP=10.10.10.2 ; NetworkID=10.10.10.0 ; SubnetMask= ; MOAN=/23,/24,/25,/26,/27,/28,/29,/30 ; ; [Example 7] ; IP=192.168.99.55 ; NetworkID=192.168.99.55 ; SubnetMask= ; MOAN= ; ;KNOWN ISSUES : ; ;KIXTART VER : 4.2x ; ;KIXTART BBS : KiXGolf: MOAN(), Mother Of All Networks --> ; - http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=14;t=000720 ; ; KixGolf: MOAN(), Part II --> ; - http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=14;t=000748 ; ;**************************************************************************** ; ;! Function MOAN($IP,$NetworkID,$SubnetMask) ;declaring variables Dim $cidrarray,$dot,$dummy,$subnetarray,$count,$help,$maskarray[3],$count2 Dim $first,$second,$third,$fourth $cidrarray=0,128,192,224,240,248,252,254 $dot="."
;build SubnetMask; starting from bit 8 through 31 For $count=8 to 31 $dummy=$count $help=1 ;determine each octet For $count2=0 to 3 ;if bitnumber/8 > 0, the octet is 255 else the mod must be determined ;255.255.248.0=11111111.11111111.11111000.00000000 $maskarray[$count2]=IIf($dummy/8,255,$cidrarray[$dummy mod 8]) ;8 must be substracted if one "moves" to the next octed $dummy=($dummy>8)*($dummy-8) ;& the IP, NetworkID and the SubnetMask octets to see if the are "compatible" If $IP & $NetworkID $help=$help & Split($NetworkID,$dot)[$count2]=(0+Split($IP,$dot)[$count2] & $maskarray[$count2]) EndIf Next ;if all variables are "compatible", add the bit number to the subnet string in CIDR notation If $help $subnetMask=$SubnetMask+" /"+$count EndIf ;if current bit=current subnetmask then convert the SubnetMask to ;normal notation, e.g. 255.255.248.0 If $count=$SubnetMask $SubnetMask=Join($maskarray,$dot) EndIf Next ;end Built subnet mask $MOAN=$SubnetMask ;if the SubnetMask contains a point, calculate IP-addresses, NetworkIDs ;or Yes-/No-is_in_subnet If InStr($SubnetMask,$dot) $dummy=Split($SubnetMask+$dot+$NetworkID,$dot) $MOAN="" ;if IP is provided, determine NetworkIDs If $IP ;calculate the NetworkID For $count=0 to 3 $MOAN=$MOAN+$dot+(0+$dummy[$count] & 0+Split($IP,$dot)[$count]) Next ;if IP=NetworkID there is no subnet, thus returning empty If $dot+Join(Split($IP),"")=$MOAN $MOAN="" EndIf ;if NetworkID is provided: ; - return .0 if the calculated NetworkID <> provided NetworkID, ; IP is not in subnet ; - return .1 if the calculated NetworkID = provided NetworkID ; IP is in subnet If $NetworkID $MOAN=$dot+Join(Split($NetworkID),"")=$MOAN EndIf ;determine array of IP numbers Else ;first octet For $first=$dummy[4] to 255 + $dummy[4] - $dummy[0] ;second octet For $second=$dummy[5] to 255 + $dummy[5] - $dummy[1] ;Third octet For $third=$dummy[6] to 255 + $dummy[6] - $dummy[2] ;Fourth octet For $fourth=1+$dummy[7] to 254 + $dummy[7] - $dummy[3] $MOAN = $MOAN+" "+$first+$dot+$second+$dot+$third+$dot+$fourth Next Next Next Next EndIf EndIf ;return the result $dummy=$MOAN,Split(SubStr($MOAN,2)) $MOAN=$dummy[Len($MOAN)>1] EndFunction ;! ;! ; end MOAN
this I mean. for proper explanation see the difference between the winning code and the previous ones. it's actually too messy with the comments to see where what looping do but looking the golf-codes you see immediately the difference
will explain properly, if you still can't see it
|
MightyR1
|
(MM club member)
|
2003-06-06 11:18 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
I see now, but how does this speed things up...
Why does KiX run faster if these lines are moved to the top???
|
Lonkero
|
(KiX Master Guru)
|
2003-06-07 01:07 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
as they are defined once. in the previous one they were defined again in each loop.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-07 04:29 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
once again, I think some of the golf-codes should be posted as it is. in the remarks we could write see next post for further examination of the code.
I don't see by any means any udf as teaching lab as they are not starters guides! they are UDFs! they have input and they output what they are supposed to output. none of even the coders need to understand what it does once it does what it's supposed to do!
thus, I don't see any reason for this re-write.
I think this pat's re-write could make a good standing point for referencing topic about the udf or supplementery post after the actual udf.
once again, UDF <> starters code clinic
and they never should be made "="!
|
NTDOC
|
(KiX Master)
|
2003-06-07 05:41 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
WOW!! I think I have to agree with Lonkero on that point.
|
MightyR1
|
(MM club member)
|
2003-06-10 07:35 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
OK...
Then Jooel/Howard, make it a UDF and please refer to this topic for explanation
Chris,
hope my comments are helpful...
|
Lonkero
|
(KiX Master Guru)
|
2003-06-10 07:56 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
pat, maybe... it might serve good as it was with real semi-coding explanation of what is happening.
this way the comments doesn't have to be so long and they surely will be understandable. and when they are not inside the code itself, it's easier to follow the code and the explanation...
|
Chris S.
|
(MM club member)
|
2003-06-10 02:04 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Pat, definitely helpful.
Lonk, quote:
UDF <> starters code clinic and they never should be made "="!
...but KiXGolf <> UDF forum either. While <> Starters forum either, I thought that the purpose was to advance KiX scripting methods. It'd be a shame for the brilliant coding that was done to be lost on the majority because no one understands what went on. At any rate, this is my last post on the subject.
|
Lonkero
|
(KiX Master Guru)
|
2003-06-10 03:36 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
chris, sure. that was not my argument...
and I bet you understood it too. we were discussing about posting the udf in udf forum. I don't stand against code explanations. just inline comments in udf-forum well... that is argumentary also, but anyway. I indeed see the point of making things clearer for more ppl to benefit.
specially all the tricks should be explained.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
A KiXGolf UDF can definitely be posted in the UDF forum. However, if you want ot put comments into the KiXGolf UDF, then you should not change the UDF code. KiXGolf UDFs are on the more compact side and thus use some KiXtart features that normal UDF do not use. Thus, the UDF comments should reflect these intricacies.
|
MightyR1
|
(MM club member)
|
2003-06-17 10:36 AM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
True,
but then I ask Jooel/Howard to write usefull comments in the winning code and post here...
|
Chris S.
|
(MM club member)
|
2003-06-20 03:07 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Just wanted to let you guys know that all of your hard work on this UDF has not been in vain. I'm going to use MOAN() to help move Computer objects in our AD to their proper OU based off of their IP address. I've really just started on the script, that is to say that I've got the logic framework down, but so far it's working like a champ.
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Just so you're aware of the limitations of MOAN(), but it might have a slight problem with Class-A networks under certain conditions. [ 20. June 2003, 17:56: Message edited by: sealeopard ]
|
Chris S.
|
(MM club member)
|
2003-06-20 06:32 PM
|
|
|
|
|
Re: KIXgolf: MOAN(), Part II
|
|
Thanks for the info, Jens. We're not using Class A so we should be OK in this instance.
|