Skip to content

Instantly share code, notes, and snippets.

@CarlQLange
Created March 14, 2012 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlQLange/2033803 to your computer and use it in GitHub Desktop.
Save CarlQLange/2033803 to your computer and use it in GitHub Desktop.
A shell script to set up a new project euler problem, directory structure and problem text included
#!/usr/bin/env sh
number=$1
if [[ $number ]]; then
mkdir ./$number
cd ./$number
python3 -c "\
from bs4 import BeautifulSoup
from urllib.request import urlopen
with urlopen('http://projecteuler.net/problem='+str($number)) as f:
soup = BeautifulSoup(f.readall())
for el in soup.find_all('div'):
if el.get('role') == 'problem':
print(el.get_text())
" >> problem.txt
echo "\
#!/usr/bin/env python3
def main():
return 0
print(main()) \
" >> solution.py
chmod +x ./solution.py
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment