Personal tools

Eth0:2008 Summer/Python Game

From Eth0Wiki

Revision as of 22:12, 9 July 2008 by Maze (talk | contribs)
Jump to: navigation, search

The Python Golf game.

Rules

The rules are quite straight-forward, they are as follows:

  • Every level is a working example of a problem
  • You have to make the shortest version (least amount of code-bytes)
  • Comments are ignored (for the points)
  • Whitespace characters are ignored (for the points)
  • lambda/map/reduce functions are allowed
  • Cheating is not allowed (writing the code in comment, and later eval(), etc.)
  • The code must generate exactly the same output as the example for the given input
  • Your code will be passed through a validator
  • All contributions must use the Python default library ONLY!

How to earn points:

  • The first contribution earns 5 points
  • Every contribution that has less characters, earns the difference of characters in points * 2, with a maximum of 10 points
  • Every following contribution will remove one point from your score (every stroke)

How to win:

  • Collect the most points :)
  • Write short code
  • Keep the code to yourself

Participation

You can send in your contributions, by the following channels:

All challenges will be available from http://10.42.122.52/~maze/

You can just modify gameXX.py, and start hacking from there (backup the original challenge!)

An example run may look like:

$ python game01_test.py 
checking number 6011000990139424: valid, good
checking number  378282246310005: valid, good
checking number  378734493671000: valid, good
checking number  371449635398442: invalid, good
checking number 7868936092868819: invalid, good
checking number   30569309025904: valid, good
checking number 4005550000000019: valid, good
checking number 4005550000000020: invalid, good
checking number      49927398716: valid, good
checking number  371449635398431: valid, good
checking number 6011111111111117: valid, good
checking number 3566002020360505: valid, good
checking number 2774118266696359: invalid, good
checking number 2465713360208684: invalid, good
checking number 3530111333300000: valid, good
checking number   38520000023237: valid, good
your script seems to be functioning correctly
your script size is 301 bytes

Getting help

There will be tutoring via IRC, if I have the time. Please join us on irc://irc.eth-0.nl/eth0 or use the web based chat.

Challenges

You need the game test framework from:

Game 1: The eleven-check

You will have until Wednesday 23:59:59 CEST to send in your contributions for this challenge.

 The creditcard validation algorithm.

 Most credit card numbers are encoded with a "Check Digit". A check digit is 
 a digit added to a number (either at the end or the beginning) that validates
 the authenticity of the number. A simple algorithm is applied to the other 
 digits of the number which yields the check digit. By running the algorithm, 
 and comparing the check digit you get from the algorithm with the check digit
 encoded with the credit card number, you can verify that you have correctly 
 read all of the digits and that they make a valid combination.

 We're going to use the LUHN Formula to check the credit card number's validity

  Step 1: Double the value of alternate digits of the primary account number 
          beginning with the second digit from the right (the first right-hand 
          digit is the check digit.)
  Step 2: Add the individual digits comprising the products obtained in Step 1 
          to each of the unaffected digits in the original number.
  Step 3: The total obtained in Step 2 must be a number ending in zero (30, 40, 
          50, etc.) for the account number to be validated.

 For example, to validate the primary account number 49927398716:

  Step 1:

         4  9  9  2  7  3  9  8  7  1  6
            x2    x2    x2    x2    x2 
         --------------------------------
            18    4     6     16    2

  Step 2:

         4 +(1+8)+ 9 + (4) + 7 + (6) + 9 +(1+6) + 7 + (2) + 6

  Step 3: 
 
          Sum = 70 : Card number is validated

  Note: Card is valid because the 70/10 yields no remainder.

Scores

User Size Points Date
VeXocide 88 5+1+1 2008-07-09 13:12
Floes 89 10 2008-07-09 14:43

Game 2: Field optimization

You will have until Friday 23:59:59 CEST to send in your contributions for this challenge.

The goal is to find the most sense area in a given field.

Price

Rp700.jpg

The winner of this contest will receive a CoolerMaster RealPower m700 (modular 700 watt atx psu)

Anyone who mails their result to tehmaze whilst being at eth0 is allowed to participate, the winning entry is selected by tehmaze.