Created
March 14, 2012 03:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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