#101334 - 2003-05-23 08:59 PM
KiXgolf: MOAN - Mother Of All Networks
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
============= The Challenge =============
You are to create the Mother Of All Networks (MOAN) UDF. This UDF will provide certain network information depending on the parameters passed to it. The challenge will be run as a private coding challenge from Friday, May 23, 3pm EST to Friday, May 30, 3pm EST. A second public coding phase will start on Friday, May 30 and end on Wednesday, June 4, 3pm EST. The task is to generate the corresponding output based on the input of either two or three of the parameters IP Address, Network ID, and Subnet Mask. Specifics are provided in section "Inputs & Outputs".
A download is available at http://people.bu.edu/jenmeyer/kixtart/kixgolf_moan.zip
============= Specification =============
The Moan UDF has the following prototype
code:
Function MOAN($IP, $NetworkID, $SubnetMask) EndFunction
All functionality of the UDF must be contained within the FUNCTION/ENDFUNCTION commands. You are not allowed to call code located outside the UDF. 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.
============= Inputs & Outputs ============= Assumtion: 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)
- Input: IP, NetworkID, Subnet Mask
Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0 - Input: IP, NetworkID
Output: Array of all potential subnet masks or empty string if no match - Input: IP, Subnet Mask
Output: Network ID or empty string if no match - Input: NetworkID, Subnet Mask
Output: Array of all potential IP addresses or empty string if no match - 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. ======== Example ======= Input: IP=192.168.10.123,NetworkID=192.168.10.0,SubnetMask=255.255.255.192 Output: MOAN=1
Input: NetworkID=10.10.5.4,SubnetMask=255.255.255.252 Output: Moan[0]=10.10.5.5 Moan[1]=10.10.5.6
Input: IP=192.10.128.55, SubnetMask=27 Output: MOAN=192.10.128.32
======= Scoring =======
Your results will be compared with the solutions provided in the kixgolf_moan.ini. You must pass all tests in order to have a valid KiXgolf score.
============= General rules =============
- The UDF must be written as one or more lines.
- The UDF is expected to finish in a reasonable time, e.g. if it gets started when the challenge opens, it's expected to be finished by the time the challenge closes even on a somewhat slow computer. The UDF has to be valid during the period that the challenge runs.
- You can submit scores as often as you want to until the deadline, no reason to wait until the last minute. In fact, other people want to see the score to beat. So don't be a spoilsport by hoarding your score. Submit early and often.
- The UDF may only use the KiXtart commands/functions/macros, no other code fragments are allowed. COM-calls that are part part of a standard default Windows installation are allowed.
- The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site.
- You may assume ASCII as character set.
- You are not allowed to use additional code that is external to the MOAN UDF. All code must be contained within the MOAN UDF.
When posting KiXtart Golf Scores, please include the KIXGOLF_MOAN.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on. ======== Deadline ========
Private coding starts Friday, May 23, 3pm EST Private coding ends Friday, May 30, 3pm EST Public coding start Friday, May 30, 3pm EST Public coding ends Wednesday, June 4, 3pm EST
============ Test program ============
A test program is provided to help screen entries and to provide the Golf Score. Any program that passes the test program can be submitted. If you are surprised that your solution passed the test program, please submit it anyway! That will help me identify bugs in the test program.
================================================================ KiXtart GOLF - How To Play ================================================================
Most importantly, anybody can play, no age restrictions, no penalties, no handicap!
The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.
Example: How many positive elements are in array $a?
Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]
One approach:
code:
for $b=0 to ubound($a) if $a[$b]>0 $c=$c+1 endif next
for a score of 45.
Another solution is:
code:
DO $b=$b+1 if $a[$b]>0 $c=$c+1 endif UNTIL $b>(UBOUND($a)+1)
for a score of 53.
Better approach: Code sample 1
================================================================ KiXtart GOLF - The Rules ================================================================
1) The goal of KiXtart Golf is to score the lowest strokes.
2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5.
3) Code can be constructed any way you like, as long as it is syntactically correct with KiXtart.
4) The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge.
5) The use of '$' as a variable is allowed.
6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.
7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.
8) During the public coding phase, code should be posted, reused, and borrowed from other players.
9) The following script can be used to count the KiXtart Golf score: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003608
================================================================ KiXtart GOLF - The Duration of the Competition ================================================================
1) Private coding phase: From date/time of posting the tournament challenge to the following Friday, 3pm EST (BBS+6 time)
2) Public coding phase: From Friday, 3pm EST (BBS+6 time) to the following Wednesday, 3pm EST (BBS+6 time)
3) Final results: Wednesday, 3pm EST (BBS+6 time)
You will need the complete package from http://people.bu.edu/jenmeyer/kixtart/kixgolf_moan.zip. [ 25. May 2003, 18:58: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#101335 - 2003-05-23 09:10 PM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Jens, just to be clear... quote: The UDF may only use the KiXtart commands/functions/macros, no other code fragments are allowed.
Does this prohibit the use of COM?
|
Top
|
|
|
|
#101340 - 2003-05-23 11:46 PM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
If Lonk can't understand, then I have a chance [ 23. May 2003, 23:46: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#101341 - 2003-05-23 11:52 PM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Jens, I thought you sais this one wouldn't include any math?
Well, looks like another outing where I won't even make the cut.
|
Top
|
|
|
|
#101345 - 2003-05-24 12:38 AM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Lonk. Come on... Read CalcLogicalSubnet()
You break the address into octets (4 x 1 byte (4 sets of 8 bits)) 1.2.3.4 = 1 2 3 4
Subnet mask is 255.255.255.0 255 255 255 0
Now logical bitwise operations on each octet pair 1&255 = 1 2&255 = 2 3&255 = 3 4&0 = 0 [ 24. May 2003, 00:39: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#101347 - 2003-05-24 12:51 AM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The logical subnet is 1.2.3.0
The ip address 1.2.3.4 is on logical subnet 1.2.3.0
if the mask was 255.255.255.128
Ip 1.2.3.4 is on subnet 1.2.3.0
IP 1.2.3.150 is on subnet 1.2.3.128
just bitwise and each number together 1&255, 2&255, 3&255, 150&128
|
Top
|
|
|
|
#101350 - 2003-05-24 03:41 PM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Jens, would your terminology be a little clearer if you changed the input term "Subnet" to "Subnet Mask" or just "Mask"?
|
Top
|
|
|
|
#101352 - 2003-05-24 09:06 PM
Re: KiXgolf: MOAN - Mother Of All Networks
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 255 anonymous users online.
|
|
|