Categorize Solutions for Different Languages
-
kataruna
- Posts: 1
- Joined: Tue Feb 16, 2010 8:28 am
Categorize Solutions for Different Languages
Hey. When we find the answer to a problem we are allowed to see the forum for that particular problem where programmers have their solutions submitted in different programming languages. So, as you see the solutions are very untidy. When somebody wants to see other programmers' solutions in one particular programming language he has to search all over the posts. Why don't we categorize these solution posts for different programming languages with a drop down list for example, so when someone wants to see solutions in Delphi he can choose Delphi from the list and see solutions only in Delphi. What about that?
-
wrongrook
- Posts: 745
- Joined: Sat Oct 17, 2009 10:39 pm
Re: Categorize Solutions for Different Languages
This sounds almost like a Project Euler challenge in itself 
Here's my Python attempt (it's a bit dodgy as it won't always produce correctly formatted html):
If you run
forum(200,'myusername','mypassword','Python')
then it should save out an HTML file containing all the responses that include the word Python for problem 200 for the first forum page.
Note, of course, that you need to substitute your own name and password.
Here's my Python attempt (it's a bit dodgy as it won't always produce correctly formatted html):
Code: Select all
def forum(problem_id, username, password, lang):
params = urllib.urlencode({'username': username, 'password': password, 'login':'Login'})
page = urllib.urlopen('http://projecteuler.net/index.php?section=forum&id=%d&page=1' %problem_id, params).read()
B = re.split('(<div class="forum_box)',page)
fd=open('out.html','w')
fd.write(B[0])
for p in range(1,len(B),2):
if re.search(lang,B[p+1]):
fd.write(B[p]+B[p+1])
fd.close()
forum(200,'myusername','mypassword','Python')
then it should save out an HTML file containing all the responses that include the word Python for problem 200 for the first forum page.
Note, of course, that you need to substitute your own name and password.