Page 2 of 5 <12345>
Topic Options
#101693 - 2003-05-31 09:17 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I really like the:

code:
if $e=$c
$c=$m[$e]
endif

reduction. It is so logical.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101694 - 2003-05-31 10:12 PM Re: KIXgolf: MOAN(), Part II
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

Top
#101695 - 2003-05-31 10:34 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I am glad to see everyone likes my code. [Big Grin] 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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101696 - 2003-06-01 12:20 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

_________________________
!

download KiXnet

Top
#101697 - 2003-06-01 12:34 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

_________________________
!

download KiXnet

Top
#101698 - 2003-06-01 01:11 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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 [Wink]
_________________________
!

download KiXnet

Top
#101699 - 2003-06-01 02:04 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

_________________________
!

download KiXnet

Top
#101700 - 2003-06-01 06:31 AM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101701 - 2003-06-01 08:00 AM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101702 - 2003-06-01 11:17 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

_________________________
!

download KiXnet

Top
#101703 - 2003-06-01 11:34 AM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Nice job...

Will try to nibble some strokes of the latest code...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#101704 - 2003-06-01 11:59 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

_________________________
!

download KiXnet

Top
#101705 - 2003-06-01 02:09 PM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Does the Lonk never stop???

Waiting for someone to break the 700-border...
Could it be me??
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#101706 - 2003-06-01 03:34 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This is sheer madness! [Wink] Will I never be the master of my own code? [Confused] [Frown] [Mad] Back to the drawing the board. [Big Grin]

Good job Lonk
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101707 - 2003-06-01 04:03 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Lonk, take that! Pat, you too! [Big Grin] Just a cheap couple strokes, but it is enough for now. [Razz]
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101708 - 2003-06-01 04:09 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Make that 709! [Big Grin]
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

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101709 - 2003-06-01 04:32 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101710 - 2003-06-01 05:15 PM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK


[ 01. June 2003, 17:17: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#101711 - 2003-06-01 05:16 PM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
shit!

you are too quick to post!
_________________________
!

download KiXnet

Top
#101712 - 2003-06-01 05:18 PM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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 ]
_________________________
!

download KiXnet

Top
Page 2 of 5 <12345>


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

Who's Online
0 registered and 608 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.075 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org