FAQ  •  Login

Level 2

Moderators: UncleTimmy, mjpieters

Enjoying the challenge? Need a hint?
Make a donation and help keep the site running! -thesamet
<<

sheerfox

Posts: 3

Joined: Tue Oct 27, 2009 10:25 pm

Post Wed Oct 28, 2009 10:07 pm

alright, the problem-solving part here isn't difficult. What is difficult is understanding what is being asked of you. For example, if you dont know for certain what is the "page source" (and i didn't until a few minutes ago) you wont even be able to start.

Look up on youtube how to find the page source code.

Once you look at the source code yourself, you'll see more directions as to what to do.
<<

Xionicwaste

Posts: 2

Joined: Wed Oct 28, 2009 9:48 am

Post Wed Oct 28, 2009 11:42 pm

lol no I do know what the page source is. To my understanding I am supposed to take that massively long jumble of "source code" and implement it into python. I was going to use string.translate and replace the things I dont think I need such as !@#$%^&*() ect... When I copy the page source nonsense it comes up like I am just documenting things on python, "teal" color, I want it to be green... I manually changed it but now I cannot put all of the source code inside of the python win editor. Is there a maximum I can enter such as 7000 characters? or X amount of lines? I am a noob to Python but would really like to learn this language.
<<

sheerfox

Posts: 3

Joined: Tue Oct 27, 2009 10:25 pm

Post Thu Oct 29, 2009 8:07 pm

haha... I'm also fairly new to python, but I've been noticing that these riddles are much more about puzzling us than testing our programming skills.

So yea, copy/paste is quite susceptible to error. What I did was paste the jumble into a .txt file and read that into python to construct a huge string. Check out these python commands, they should help...

open()
readline()
partition()
<<

tacit

Posts: 1

Joined: Sat Nov 07, 2009 4:16 am

Post Sat Nov 07, 2009 4:19 am

The reason that the 'jumble' turns 'teal' or your color for comments is that the 'jumble' includes '#' the python comment character. Also because there are returns in the text you have to use ''' or """ tripple quotes(multiline strings).
<<

HTB

Posts: 1

Joined: Thu Mar 04, 2010 10:03 am

Post Thu Mar 04, 2010 10:11 am

Re: Level 2

okay so you get the source code

get that comment bit at the end

get all the unique characters out of it

rearrange them to what exactly???

I hope this is not a spoiler but this is my scripts output.

  Code:
IRC:#pycgFrNd


I'm a meant to use a dictionary attack to re-arrange this characters into English or something or what?

I'm stumped totally! please someone tell me where I messed up. or at least tell me I'm close... even a tiny weeny little hint.
<<

Peetoon

Posts: 2

Joined: Thu Apr 01, 2010 10:57 am

Post Thu Apr 01, 2010 11:02 am

Re: Level 2

You could use an anagram generator off the internet, although they are already in the correct order in the source, so you could just write another small script to print the correct sequence out once you've found the unique characters. :)
<<

pai

Posts: 1

Joined: Mon Jun 21, 2010 8:10 am

Post Mon Jun 21, 2010 8:12 am

Re: Level 2

I think I have got the answer.You should find the all characters in that mess.
<<

birdchan

Posts: 3

Joined: Thu Sep 09, 2010 3:22 pm

Post Thu Sep 09, 2010 3:23 pm

Re: Level 2

I got it finally... don't over-analyze... this is only level 2...
<<

Jawsattack100

Posts: 2

Joined: Thu Sep 30, 2010 4:09 pm

Post Thu Sep 30, 2010 4:11 pm

Re: Level 2

i figured out levels 0 and 1 by hand but i need someone to explain Python to me please. . . e-mail me with basic instructions please i couldn't figure it out i grasp stuff easily so one e-mail should do :cry: :?:
<<

renegade

Posts: 3

Joined: Wed Nov 03, 2010 3:44 pm

Post Wed Nov 03, 2010 4:14 pm

Re: Level 2

What great puzzles and a fun way to learn python!
<<

renegade

Posts: 3

Joined: Wed Nov 03, 2010 3:44 pm

Post Wed Nov 03, 2010 4:26 pm

Re:

piro wrote:well well well

might look a bit lame but here goes ma code


file = open('crypt.txt', 'r')
outf = open('output.txt', 'w')

while 1:
char = file.read(1)
if char == '#' or char == '&' or char == '@' or char == '$' or char == '!' or char == '*' or char == '^' or char == '{' or char == '}' or char == '_' or char == '(' or char == ')' or char == '*' or char == '+' or char == '[' or char == ']' or char == '%' :
char = '_'
outf.write(char)
if not char: break
# print char

file.close()
outf.close()

import sys
sys.exit()


I used a dictionary to count the symbols; it does not preserve order though... maybe even easier is to take prio's code idea but use:

  Code:
f = open('crypt.txt', 'r')
         chars = '\n!#%$&()+*@[]_^{}'
         str = f.read()  # this reads whole file as a string into str
         for c in str:
            if str not in chars:
              print c
         

Saves a lot of typing!!
<<

Joe Batt

Posts: 2

Joined: Fri Nov 04, 2011 5:32 am

Post Fri Nov 04, 2011 5:38 am

Re: Level 2

Hi all I am new to here and to programming as well so please feel free to comment on my code

I have a solution but I don't know how to get to the next URL using it….can anyone help please….


My code is


###########################################################################
# Python Challenge 2 --- http://www.pythonchallenge.com/pc/def/ocr.html
# Program to find unique characters in a source file in .txt format on desktop
# and write the unique characters back to new file
# Author: Joe Batt 4 Nov 2011
###########################################################################

textFileDecode=open('///Users/joebatt/Desktop/messdecode.txt','a+') #opens file for storing decode
textFile=open('///Users/joebatt/Desktop/mess.txt','r') #opens file holding source code needing decode
contents=textFile.read() #contents holds source code needing decode


fileSize=len(contents) #Get length of file to detirmine size of contents to be sorted
filePosit=0 #defime start position in file to get character to be checked from


while filePosit<=fileSize-1: #<----loop back to here to check next character

char=(contents[filePosit]) #Gets 'char' the individual character to check


# IF ELSE checks if the 'char' is in the 'contents' file

if contents.count(char,0,fileSize)>1: #if 'char' is in the file more than 1 time it is not unique
filePosit+=1

else: #'char' is NOT in the file
textFileDecode.write(str(char))
filePosit+=1


else:
textFile.close() #closes source code file
textFileDecode.close()#closes decoded file

#Prints the file with the decoded text
textFileDecode=open('///Users/joebatt/Desktop/messdecode.txt','r')
contents=textFileDecode.read() #contents holds decoded file
print ("The decode is : "+contents)

textFileDecode.close()


input("Please press 'ENTER' to quit")
<<

Joe Batt

Posts: 2

Joined: Fri Nov 04, 2011 5:32 am

Post Fri Nov 04, 2011 5:59 am

Re: Level 2

Its OK I figured where to add my solution, I was changing the pc in the url…..not the xxxx.html

Getting there slowly!
<<

blast_hardcheese

Posts: 32

Joined: Wed Aug 17, 2011 12:52 am

Post Tue Jan 17, 2012 5:42 pm

Re: Level 2

Awesome! Just a tip, if you have questions in the future, feel free to ask for help, just not the answers :)

The goal here is to have fun with Python, but it is also a challenge. All of these challenges are possible without spoilers.
<<

ultrazoid_

Posts: 1

Joined: Wed Feb 15, 2012 3:29 am

Post Wed Feb 15, 2012 3:59 am

Re: Level 2

Hi I've work out how to get the characters but can't seem to work out how to get a word from them...
PreviousNext

Return to Python Challenge Hints

Who is online

Users browsing this forum: Google [Bot] and 9 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.