├── .gitignore ├── LICENSE ├── README.md ├── project-euler-offline.py ├── project-euler-offline.sh ├── requirements.txt └── solutions-encrypted /.gitignore: -------------------------------------------------------------------------------- 1 | # python 2 | venv 3 | 4 | # osx noise 5 | .DS_Store 6 | profile 7 | 8 | # xcode noise 9 | build/* 10 | *.mode1 11 | *.mode1v3 12 | *.mode2v3 13 | *.perspective 14 | *.perspectivev3 15 | *.pbxuser 16 | *.xcworkspace 17 | xcuserdata 18 | 19 | # svn & cvs 20 | .svn 21 | CVS -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Christopher Su 2 | 3 | 4 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 10 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project Euler Offline 2 | This is a quick program I threw together before getting on a plane so I would be able to solve PE problems and check solutions without having internet access. The program decrypts an encrypted file that contains the solutions, so there are no spoilers in plain text. 3 | 4 | ## Usage 5 | Just run `python project-euler-offline.py` or first `chmod +x` it and then use `./project-euler-offline.py`. Whatever floats your boat. 6 | 7 | ## Getting the problems offline 8 | 1. Register and login to PE 9 | 2. Go to 10 | 3. Save the page to your computer 11 | -------------------------------------------------------------------------------- /project-euler-offline.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | project-euler-offline.py 4 | Christopher Su 5 | Checks solutions to Project Euler problems offline. 6 | ''' 7 | 8 | import os 9 | import json 10 | from pyDes import * 11 | 12 | def loadJSON(jsonStr): 13 | try: 14 | data = json.loads(jsonStr) 15 | except ValueError: 16 | logging.exception("Error parsing %s." % json_file) 17 | sys.exit(1) 18 | return data 19 | 20 | def main(): 21 | dir = os.path.dirname(__file__) 22 | txtFile = open(os.path.join(dir, "solutions-encrypted"), "rb") 23 | txtStr = txtFile.read() 24 | txtFile.close() 25 | plain_text = triple_des('03b5660c7c16a07b').decrypt(txtStr, padmode=2) 26 | solutions = loadJSON(plain_text) 27 | 28 | current = input("What problem are you currently working on? ") 29 | 30 | while True: 31 | proposed = input("\nEnter solution: ") 32 | if proposed == "exit": 33 | break 34 | elif proposed == solutions[current]: 35 | print("Correct!") 36 | current = input("\nWhat problem are you working on? ") 37 | if current == "exit": 38 | break 39 | else: 40 | print("Sorry, that is incorrect.") 41 | 42 | if __name__ == "__main__": 43 | dir = os.path.dirname(__file__) 44 | main() 45 | -------------------------------------------------------------------------------- /project-euler-offline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VENV="venv" 3 | if [[ ! -d "$VENV" ]]; then 4 | python -m venv "$VENV" 5 | "$VENV"/bin/python -m pip install -r requirements.txt 6 | fi 7 | "$VENV"/bin/python project-euler-offline.py 8 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyDes==2.0.1 2 | -------------------------------------------------------------------------------- /solutions-encrypted: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csu/project-euler-offline/9a3c5d6c12f743ef44d12224e0ce8963430af4b8/solutions-encrypted --------------------------------------------------------------------------------