Page 4 of 5 <12345>
Topic Options
#101733 - 2003-06-04 08:49 PM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ding dong.
closed are we?
_________________________
!

download KiXnet

Top
#101734 - 2003-06-04 09:10 PM Re: KIXgolf: MOAN(), Part II
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes, we're closed, but I'll be busy with stuff for at least another hour.
_________________________
There are two types of vessels, submarines and targets.

Top
#101735 - 2003-06-04 10:49 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Good job Lonkero.

Some of the feeling this outing caused? [Smile] [Frown] [Mad] [Confused] [Cool]

thanks Jens.

[ 04. June 2003, 22:50: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#101736 - 2003-06-04 11:10 PM Re: KIXgolf: MOAN(), Part II
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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.
Top
#101737 - 2003-06-05 12:09 AM Re: KIXgolf: MOAN(), Part II
Sealeopard Offline
KiX Master
*****

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

Top
#101738 - 2003-06-05 12:14 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

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

download KiXnet

Top
#101739 - 2003-06-05 12:17 AM Re: KIXgolf: MOAN(), Part II
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I'll come up with something easier for the next round.
_________________________
There are two types of vessels, submarines and targets.

Top
#101740 - 2003-06-05 09:22 AM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Nice Tournament, had a lot of fun...

Liked the battle between the 'Giants'... [Big Grin] [Big Grin] [Big Grin]
_________________________
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
#101741 - 2003-06-05 02:40 PM Re: KIXgolf: MOAN(), Part II
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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?

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
comment?
damn, there is almost as many comment lines as code lines! [Big Grin]
what else you want? [Wink]
_________________________
!

download KiXnet

Top
#101743 - 2003-06-05 06:22 PM Re: KIXgolf: MOAN(), Part II
Howard Bullock Offline
KiX Supporter
*****

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

Top
#101744 - 2003-06-05 10:15 PM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
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...
_________________________
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
#101745 - 2003-06-05 10:42 PM Re: KIXgolf: MOAN(), Part II
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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.

Top
#101746 - 2003-06-05 11:13 PM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

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

not sure am I sober enough to provide even the semi-code but maybe hoby is [Razz]
_________________________
!

download KiXnet

Top
#101747 - 2003-06-05 11:53 PM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Chris, here ye go...

I added some variables to make things more clear.
This version passes the tests with a score of 1184 [Wink]

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 ]
_________________________
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
#101748 - 2003-06-06 10:08 AM Re: KIXgolf: MOAN(), Part II
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
*Blob*

Jooel, Howard,

No comments???
_________________________
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
#101749 - 2003-06-06 10:10 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, at least you changed the code totally.
or is this based on something else than the winning code?
_________________________
!

download KiXnet

Top
#101750 - 2003-06-06 10:37 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

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

download KiXnet

Top
#101751 - 2003-06-06 10:40 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ctrl+h...
replace all "point" with "dot"

if $dum is supposed to mean dummy write it totally.
then $h should be $dummy2 or $help.
_________________________
!

download KiXnet

Top
#101752 - 2003-06-06 10:47 AM Re: KIXgolf: MOAN(), Part II
Lonkero Administrator Offline
KiX Master Guru
*****

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

download KiXnet

Top
Page 4 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 610 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.086 seconds in which 0.034 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