GithubHelp home page GithubHelp logo

aoc2019-python's Introduction

AOC 2019 solutions

About

This repo contains solutions to the advent of code 2019 edition.

Now requires Python >= 3.8!

How to use

The files under the days directory are most conveniently run as python modules:

python3 -m days.d01p1 <input file>

The input directory is conveniently included to store your personal input and test files.

utils.parse

This utility module provides code with a uniform way to get input, including argument parsing.

That is, it provides an optional argument for specifying an input file. If this argument is not specified, input is read from stdin.

from utils.parse import Parser

# mimics the cat utility
parser = Parser(desc="Optional assignment description")
with parser.input as input:
    stripped = (l.strip() for l in input)
    print(*stripped, sep='\n')

misc.disic

Intcode

In this edition some tasks operate on a special Intcode language.

This module prettifies an Intcode program by adding named operations, visual address modes and opcode positions.

Example

For a comma-separated Intcode (wrapping added for readability):

3,52,
1001,52,-5,52,
3,53,
1,52,56,54,
1007,54,5,55,
1005,55,26,
1001,54,-5,54,
1105,1,12,
1,53,54,53,
1008,54,0,55,
1001,55,1,55,
2,53,55,53,
4,53,
1001,56,-1,56,
1005,56,6,
99,
0,
0,
0,
0,
10

python3 -m misc.disic <input file> outputs:

00000000: INP 52
00000002: ADD 52 #-5 52
00000006: INP 53
00000008: ADD 52 56 54
00000012: TLT 54 #5 55
00000016: JNZ 55 #26
00000019: ADD 54 #-5 54
00000023: JNZ #1 #12
00000026: ADD 53 54 53
00000030: TEQ 54 #0 55
00000034: ADD 55 #1 55
00000038: MUL 53 55 53
00000042: OUT 53
00000044: ADD 56 #-1 56
00000048: JNZ 56 #6
00000051: HLT
00000052: ??? (0)
00000053: ??? (0)
00000054: ??? (0)
00000055: ??? (0)
00000056: ??? (10)

aoc2019-python's People

Contributors

tranzystorekk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.