Skip to content

qwesda/aoc2023-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AOC 2023 スたん + どが + クウェスダ [python edition]

This is the repository for the Advent of Code 2023 (https://adventofcode.com/2023).

Basic rules

  • try to solve it by yourself first
  • this is not about speed, it is good to let the problem stew for a few hours (or days), while the brain is working on it in the background
  • ask for hints if you get stuck
  • don't use any non-standard library packages (e.g. numpy, pandas, scipy, sympy, ...)
  • don't use code assistants like github copilot, tabnine, ...

頑張ってね!

Basic setup

  1. have a macbook (other computer work as well, but I can not help with setup)
  2. have a github account, you don't need a payed/subscription plan
  3. get a copy of pycharm https://www.jetbrains.com/pycharm/. As a student you can get a free license for the professional version (https://www.jetbrains.com/community/education/#students)
  4. install homebrew https://brew.sh/
  5. install python3 via homebrew brew install python3 5.1) if you already had homebrew and python installed, update them brew update and then brew upgrade
  6. create a Repositories folder in your home directory
  7. you can use the github app https://desktop.github.com to clone this repository into the Repositories folder
  8. run the following code in the root directory of this repository to create a virtual environment and install the required packages
  • fish shell:
rm -Rfv .venv; /opt/homebrew/bin/python3 -m venv --prompt=\"(basename (pwd))\" .venv; source .venv/bin/activate.fish; python -m pip install --upgrade pip setuptools wheel; pip install -U -r requirements.txt
  • bash shell or z-shell:
rm -Rvf .env .venv; /opt/homebrew/bin/python3 -m venv --prompt="`basename $(pwd)`" .venv; source .venv/bin/activate; python -m pip install --upgrade pip setuptools wheel; pip install -U -r requirements.txt
  1. open pycharm and drag the aoc2023-python folder from the finder on to the pycharm icon in the dock
  2. pycharm should figure out what virtual envoroment to use by itself
  3. create a debug configuration:

  1. download your input files to the correct folder. everybody gets different inputs, so they are separated by user.

  2. start writing your code

  3. execute/debug your solution with by hitting the little play or debug button in the top right part of the window

  4. have fun

Notes on code style

Consistency is very important to quickly read/parse code, follow the same style you choose everywhere!

Stuff that work very well for me:

Use descriptive variable/function names

This is often ignored in university settings, where the exact opposite is taught. Variables are names x, y, a, b and it is left to the reader (often a future version of oneself) to figure out what the fuck they mean. There are a few exceptions to this, like f for an opened file or x, y in list comprehension ...

Sometimes thinking of a fitting name is already half of the solution! As the saying goes:

There are only two hard problems in computer science: 0) Cache invalidation

  1. Naming things
  2. Off-by-one errors

Don't write stupid comments

Again 大学先生 will disagree, but do not put obvious stuff in comments. Comments are for non-obvious stuff that can't be easily from the code itself. If the function is well named it should be obvious what is supposed to happen.

Code should be layed like text

Think of it like sentences, paragraphs and chapters. Use whitespace (newlines) to separate them.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages