Personal tools

Difference between revisions of "Eth0:2008 Summer/Python Game"

From Eth0Wiki

Jump to: navigation, search
(New page: 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 ...)
 
Line 28: Line 28:
 
You can send in your contributions, by the following channels:
 
You can send in your contributions, by the following channels:
 
* Paste your code in a PRIVATE paste on http://qna.nu, http://paste-it.net, or whatever, give [[User:Maze|me]] the URL.
 
* Paste your code in a PRIVATE paste on http://qna.nu, http://paste-it.net, or whatever, give [[User:Maze|me]] the URL.
* Mail your code to mailto:games-eth0@tehmaze.com
+
* Mail your code to [mailto:games-eth0XX@XXtehmaze.com games-eth0XX@XXtehmaze.com] (remove both XX)
  
 
All challenges will be available from http://10.42.122.52/~maze/
 
All challenges will be available from http://10.42.122.52/~maze/

Revision as of 19:01, 8 July 2008

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
  • 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

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.