IPB

Welcome Guest ( Log In | Register )


> python challenge
pebkac
post Mar 10 2008, 01:18 PM
Post #1


From Atlantis to Interzone


Group: Global Moderators
Posts: 2,512
Joined: 23-February 06
From: Somewhere in space and time
Member No.: 65



www.pythonchallenge.com

Has anyone else tried this? It's a pretty good way to learn python (but it can be done in any language).


--------------------
QUOTE (Spectatrix @ Oct 13 2006, 09:51 PM) *
Holy shit, pebkac, you're awesome!



"Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." - Theodor Seuss Geisel (AKA Dr. Seuss)

"An idea that is not dangerous is unworthy of being called an idea at all." - Oscar Wilde
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
pebkac
post Mar 11 2008, 09:21 PM
Post #2


From Atlantis to Interzone


Group: Global Moderators
Posts: 2,512
Joined: 23-February 06
From: Somewhere in space and time
Member No.: 65



Here's a simple script I wrote to open a text file, increment all the letters in it by two and save them to another text file:

CODE
import sys
import string

in_file = open("encrypt", "r")
text = in_file.read()
in_file.close()

def increment(char, by=2): return chr(ord(char)+by)

out_text = ""
for char in text:
    if char.isalpha():
        if char.startswith(("y","z","Y","Z")):
            out_text = out_text + increment(char, -24)
        else:
            out_text = out_text + increment(char)        
    else:
        out_text = out_text + char
    
out_file = open("py.out", "w")
out_file.write(out_text)


--------------------
QUOTE (Spectatrix @ Oct 13 2006, 09:51 PM) *
Holy shit, pebkac, you're awesome!



"Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." - Theodor Seuss Geisel (AKA Dr. Seuss)

"An idea that is not dangerous is unworthy of being called an idea at all." - Oscar Wilde
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 19th December 2025 - 11:38 PM
Skin made by: skeedio.com