[Init] Add day one and two for AdventOfCode + KnowIt
This commit is contained in:
commit
f2bcde4a3b
475
.gitignore
vendored
Normal file
475
.gitignore
vendored
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
##########################################
|
||||||
|
# JavaScript
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
## C# / Visual Studio
|
||||||
|
##########################################
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
34
AdventOfCode/2020/01/README.md
Normal file
34
AdventOfCode/2020/01/README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
## --- Day 1: Report Repair ---
|
||||||
|
|
||||||
|
After saving Christmas [five years in a row](https://adventofcode.com/events), you've decided to take a vacation at a nice resort on a tropical island. <span title="WHAT COULD GO WRONG">Surely</span>, Christmas will go on without you.
|
||||||
|
|
||||||
|
The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture of a starfish; the locals just call them _stars_. None of the currency exchanges seem to have heard of them, but somehow, you'll need to find fifty of these coins by the time you arrive so you can pay the deposit on your room.
|
||||||
|
|
||||||
|
To save your vacation, you need to get all _fifty stars_ by December 25th.
|
||||||
|
|
||||||
|
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants _one star_. Good luck!
|
||||||
|
|
||||||
|
Before you leave, the Elves in accounting just need you to fix your _expense report_ (your puzzle input); apparently, something isn't quite adding up.
|
||||||
|
|
||||||
|
Specifically, they need you to _find the two entries that sum to `2020`_ and then multiply those two numbers together.
|
||||||
|
|
||||||
|
For example, suppose your expense report contained the following:
|
||||||
|
|
||||||
|
1721
|
||||||
|
979
|
||||||
|
366
|
||||||
|
299
|
||||||
|
675
|
||||||
|
1456
|
||||||
|
|
||||||
|
In this list, the two entries that sum to `2020` are `1721` and `299`. Multiplying them together produces `1721 * 299 = 514579`, so the correct answer is `_514579_`.
|
||||||
|
|
||||||
|
Of course, your expense report is much larger. _Find the two entries that sum to `2020`; what do you get if you multiply them together?_
|
||||||
|
|
||||||
|
## --- Part Two ---
|
||||||
|
|
||||||
|
The Elves in accounting are thankful for your help; one of them even offers you a starfish coin they had left over from a past vacation. They offer you a second one if you can find _three_ numbers in your expense report that meet the same criteria.
|
||||||
|
|
||||||
|
Using the above example again, the three entries that sum to `2020` are `979`, `366`, and `675`. Multiplying them together produces the answer, `_241861950_`.
|
||||||
|
|
||||||
|
In your expense report, _what is the product of the three entries that sum to `2020`?_
|
200
AdventOfCode/2020/01/input.txt
Normal file
200
AdventOfCode/2020/01/input.txt
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
1941
|
||||||
|
1887
|
||||||
|
1851
|
||||||
|
1874
|
||||||
|
1612
|
||||||
|
1960
|
||||||
|
1971
|
||||||
|
1983
|
||||||
|
1406
|
||||||
|
1966
|
||||||
|
1554
|
||||||
|
1892
|
||||||
|
1898
|
||||||
|
1926
|
||||||
|
1081
|
||||||
|
1992
|
||||||
|
1073
|
||||||
|
1603
|
||||||
|
177
|
||||||
|
1747
|
||||||
|
1063
|
||||||
|
1969
|
||||||
|
1659
|
||||||
|
1303
|
||||||
|
1759
|
||||||
|
1853
|
||||||
|
1107
|
||||||
|
1818
|
||||||
|
1672
|
||||||
|
1352
|
||||||
|
2002
|
||||||
|
1838
|
||||||
|
1985
|
||||||
|
1860
|
||||||
|
1141
|
||||||
|
1903
|
||||||
|
1334
|
||||||
|
1489
|
||||||
|
1178
|
||||||
|
1823
|
||||||
|
1499
|
||||||
|
1951
|
||||||
|
1225
|
||||||
|
1503
|
||||||
|
1417
|
||||||
|
1724
|
||||||
|
1165
|
||||||
|
1339
|
||||||
|
1816
|
||||||
|
1504
|
||||||
|
1588
|
||||||
|
1997
|
||||||
|
1946
|
||||||
|
1324
|
||||||
|
1771
|
||||||
|
1982
|
||||||
|
1272
|
||||||
|
1367
|
||||||
|
1439
|
||||||
|
1252
|
||||||
|
1902
|
||||||
|
1940
|
||||||
|
1333
|
||||||
|
1750
|
||||||
|
1512
|
||||||
|
1538
|
||||||
|
1168
|
||||||
|
2001
|
||||||
|
1797
|
||||||
|
1233
|
||||||
|
972
|
||||||
|
1306
|
||||||
|
1835
|
||||||
|
1825
|
||||||
|
1822
|
||||||
|
1880
|
||||||
|
1732
|
||||||
|
1785
|
||||||
|
1727
|
||||||
|
1275
|
||||||
|
1355
|
||||||
|
1793
|
||||||
|
1485
|
||||||
|
1297
|
||||||
|
1932
|
||||||
|
1519
|
||||||
|
1587
|
||||||
|
1382
|
||||||
|
1914
|
||||||
|
1745
|
||||||
|
1087
|
||||||
|
1996
|
||||||
|
1746
|
||||||
|
1962
|
||||||
|
1573
|
||||||
|
2008
|
||||||
|
1868
|
||||||
|
1278
|
||||||
|
1386
|
||||||
|
1238
|
||||||
|
1242
|
||||||
|
1170
|
||||||
|
1476
|
||||||
|
1161
|
||||||
|
1754
|
||||||
|
1807
|
||||||
|
1514
|
||||||
|
1189
|
||||||
|
1916
|
||||||
|
1884
|
||||||
|
1535
|
||||||
|
1217
|
||||||
|
1911
|
||||||
|
1861
|
||||||
|
1493
|
||||||
|
1409
|
||||||
|
1783
|
||||||
|
1222
|
||||||
|
1955
|
||||||
|
1673
|
||||||
|
1502
|
||||||
|
607
|
||||||
|
2010
|
||||||
|
1846
|
||||||
|
1819
|
||||||
|
1500
|
||||||
|
1799
|
||||||
|
1475
|
||||||
|
1146
|
||||||
|
1608
|
||||||
|
1806
|
||||||
|
1660
|
||||||
|
1618
|
||||||
|
1904
|
||||||
|
978
|
||||||
|
1762
|
||||||
|
1925
|
||||||
|
1185
|
||||||
|
1154
|
||||||
|
1239
|
||||||
|
1843
|
||||||
|
1986
|
||||||
|
533
|
||||||
|
1509
|
||||||
|
1913
|
||||||
|
287
|
||||||
|
1707
|
||||||
|
1115
|
||||||
|
1699
|
||||||
|
1859
|
||||||
|
1077
|
||||||
|
1915
|
||||||
|
1412
|
||||||
|
1360
|
||||||
|
1646
|
||||||
|
1973
|
||||||
|
1627
|
||||||
|
1755
|
||||||
|
1748
|
||||||
|
1769
|
||||||
|
1886
|
||||||
|
1422
|
||||||
|
1686
|
||||||
|
950
|
||||||
|
100
|
||||||
|
1372
|
||||||
|
1068
|
||||||
|
1370
|
||||||
|
1428
|
||||||
|
1870
|
||||||
|
1108
|
||||||
|
190
|
||||||
|
1891
|
||||||
|
1794
|
||||||
|
1228
|
||||||
|
1128
|
||||||
|
1365
|
||||||
|
1740
|
||||||
|
1888
|
||||||
|
1460
|
||||||
|
1758
|
||||||
|
1906
|
||||||
|
1917
|
||||||
|
1989
|
||||||
|
1251
|
||||||
|
1866
|
||||||
|
1560
|
||||||
|
1921
|
||||||
|
1777
|
||||||
|
1102
|
||||||
|
1850
|
||||||
|
1498
|
||||||
|
683
|
||||||
|
1840
|
||||||
|
1800
|
||||||
|
1112
|
||||||
|
1908
|
||||||
|
1442
|
||||||
|
1082
|
||||||
|
1071
|
36
AdventOfCode/2020/01/puzzle-one.js
Normal file
36
AdventOfCode/2020/01/puzzle-one.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
const { readFile } = require('../../../helpers');
|
||||||
|
const file = readFile('./input.txt');
|
||||||
|
|
||||||
|
// Split file into an array
|
||||||
|
// Convert each line from string to int.
|
||||||
|
const numbers = file.split('\n').map(x => parseInt(x, 10));
|
||||||
|
|
||||||
|
for (const first of numbers)
|
||||||
|
{
|
||||||
|
for (const second of numbers)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* We can just assume that we're not supposed to add together the same numbers.
|
||||||
|
*/
|
||||||
|
if (first === second)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the number equals to 2020, which is the only condition for puzzle one.
|
||||||
|
*/
|
||||||
|
const addition = first + second;
|
||||||
|
if (addition !== 2020) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Once the condition is filled, we can submit the
|
||||||
|
* multiplication result as our answer (the product).
|
||||||
|
*/
|
||||||
|
const multiplication = first * second;
|
||||||
|
console.log(`${first} + ${second} = 2020`);
|
||||||
|
console.log(`${first} * ${second} = ${multiplication}`);
|
||||||
|
}
|
||||||
|
}
|
55
AdventOfCode/2020/01/puzzle-two.js
Normal file
55
AdventOfCode/2020/01/puzzle-two.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
const { readFile } = require('../../../helpers');
|
||||||
|
const file = readFile('./input.txt');
|
||||||
|
|
||||||
|
// Split file into an array
|
||||||
|
// Convert each line from string to int.
|
||||||
|
const numbers = file.split('\n').map(x => parseInt(x, 10));
|
||||||
|
|
||||||
|
for (const first of numbers)
|
||||||
|
{
|
||||||
|
for (const second of numbers)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* We can just assume that we're not supposed to add together the same numbers.
|
||||||
|
*/
|
||||||
|
if (first === second)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list has no negative numbers, so if the first or second
|
||||||
|
* numbers add up to more than 2020, it's impossible for them
|
||||||
|
* to be valid to begin with.
|
||||||
|
*/
|
||||||
|
const firstAddition = first + second;
|
||||||
|
if (firstAddition >= 2020) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const third of numbers) {
|
||||||
|
/**
|
||||||
|
* We can just assume (again) that we're not supposed to add together the same numbers.
|
||||||
|
*/
|
||||||
|
if (first === third || first === second) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Condition for puzzle two is similar to puzzle one.
|
||||||
|
* Adding all numbers should equal to 2020.
|
||||||
|
*/
|
||||||
|
const finalAddition = firstAddition + third;
|
||||||
|
if (finalAddition !== 2020) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number we submit is the multiplication result (the product).
|
||||||
|
*/
|
||||||
|
const multiplication = first * second * third;
|
||||||
|
console.log(`${first} + ${second} + ${third} = 2020`);
|
||||||
|
console.log(`${first} * ${second} * ${third} = ${multiplication}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
AdventOfCode/2020/02/README.md
Normal file
37
AdventOfCode/2020/02/README.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
## --- Day 2: Password Philosophy ---
|
||||||
|
|
||||||
|
Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via [toboggan](https://en.wikipedia.org/wiki/Toboggan).
|
||||||
|
|
||||||
|
The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with our computers; we can't log in!" You ask if you can take a look.
|
||||||
|
|
||||||
|
Their password database seems to be a little corrupted: some of the passwords wouldn't have been allowed by the <span title="To ensure your safety, your password must be the following string...">Official Toboggan Corporate Policy</span> that was in effect when they were chosen.
|
||||||
|
|
||||||
|
To try to debug the problem, they have created a list (your puzzle input) of _passwords_ (according to the corrupted database) and _the corporate policy when that password was set_.
|
||||||
|
|
||||||
|
For example, suppose you have the following list:
|
||||||
|
|
||||||
|
1-3 a: abcde
|
||||||
|
1-3 b: cdefg
|
||||||
|
2-9 c: ccccccccc
|
||||||
|
|
||||||
|
Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, `1-3 a` means that the password must contain `a` at least `1` time and at most `3` times.
|
||||||
|
|
||||||
|
In the above example, `_2_` passwords are valid. The middle password, `cdefg`, is not; it contains no instances of `b`, but needs at least `1`. The first and third passwords are valid: they contain one `a` or nine `c`, both within the limits of their respective policies.
|
||||||
|
|
||||||
|
_How many passwords are valid_ according to their policies?
|
||||||
|
|
||||||
|
## --- Part Two ---
|
||||||
|
|
||||||
|
While it appears you validated the passwords correctly, they don't seem to be what the Official Toboggan Corporate Authentication System is expecting.
|
||||||
|
|
||||||
|
The shopkeeper suddenly realizes that he just accidentally explained the password policy rules from his old job at the sled rental place down the street! The Official Toboggan Corporate Policy actually works a little differently.
|
||||||
|
|
||||||
|
Each policy actually describes two _positions in the password_, where `1` means the first character, `2` means the second character, and so on. (Be careful; Toboggan Corporate Policies have no concept of "index zero"!) _Exactly one of these positions_ must contain the given letter. Other occurrences of the letter are irrelevant for the purposes of policy enforcement.
|
||||||
|
|
||||||
|
Given the same example list from above:
|
||||||
|
|
||||||
|
* `1-3 a: _a_b_c_de` is _valid_: position `1` contains `a` and position `3` does not.
|
||||||
|
* `1-3 b: _c_d_e_fg` is _invalid_: neither position `1` nor position `3` contains `b`.
|
||||||
|
* `2-9 c: c_c_cccccc_c_` is _invalid_: both position `2` and position `9` contain `c`.
|
||||||
|
|
||||||
|
_How many passwords are valid_ according to the new interpretation of the policies?
|
1000
AdventOfCode/2020/02/input.txt
Normal file
1000
AdventOfCode/2020/02/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
33
AdventOfCode/2020/02/puzzle-one.js
Normal file
33
AdventOfCode/2020/02/puzzle-one.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
const { readFile } = require('../../../helpers');
|
||||||
|
const file = readFile('./input.txt').trim();
|
||||||
|
|
||||||
|
const passwords = file.split('\n').map((line) => {
|
||||||
|
const split = line.split(' ');
|
||||||
|
|
||||||
|
const minMax = split[0].split('-');
|
||||||
|
const min = parseInt(minMax[0], 10);
|
||||||
|
const max = parseInt(minMax[1], 10);
|
||||||
|
const letter = split[1].replace(':', '');
|
||||||
|
const password = split[2];
|
||||||
|
|
||||||
|
return {min, max, letter, password};
|
||||||
|
});
|
||||||
|
|
||||||
|
const valid = passwords.filter((i) => {
|
||||||
|
const {min, max, letter, password} = i;
|
||||||
|
|
||||||
|
const regex = new RegExp(`${letter}`, 'g');
|
||||||
|
const match = password.match(regex);
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const passwordLetters = match.length;
|
||||||
|
if (passwordLetters > max || passwordLetters < min) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
console.log(valid.length);
|
34
AdventOfCode/2020/02/puzzle-two.js
Normal file
34
AdventOfCode/2020/02/puzzle-two.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
const { readFile } = require('../../../helpers');
|
||||||
|
const file = readFile('./input.txt').trim();
|
||||||
|
|
||||||
|
const passwords = file.split('\n').map((line) => {
|
||||||
|
const split = line.split(' ');
|
||||||
|
|
||||||
|
const minMax = split[0].split('-');
|
||||||
|
const min = parseInt(minMax[0], 10);
|
||||||
|
const max = parseInt(minMax[1], 10);
|
||||||
|
const letter = split[1].replace(':', '');
|
||||||
|
const password = split[2];
|
||||||
|
|
||||||
|
return {min, max, letter, password};
|
||||||
|
});
|
||||||
|
|
||||||
|
const valid = passwords.filter((i) => {
|
||||||
|
const {min, max, letter, password} = i;
|
||||||
|
|
||||||
|
const first = password[min - 1];
|
||||||
|
const second = password[max - 1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First letter matches, second does not.
|
||||||
|
*/
|
||||||
|
const matchFirst = first === letter && second !== letter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The opposite: First letter does not match, second letter matches.
|
||||||
|
*/
|
||||||
|
const matchSecond = first !== letter && second === letter;
|
||||||
|
|
||||||
|
return matchFirst || matchSecond;
|
||||||
|
});
|
||||||
|
console.log(valid.length);
|
5
AdventOfCode/README.md
Normal file
5
AdventOfCode/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# AdventOfCode
|
||||||
|
|
||||||
|
I am 100% going to give up on day 3 of each year.
|
||||||
|
|
||||||
|
https://adventofcode.com/
|
1
KnowItJulekalender/2020/01/README.md
Normal file
1
KnowItJulekalender/2020/01/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
I [denne fila](./numbers.txt) ligg alle tala frå og med 1 til og med 100 000 hulter til bulter, med unntak av eit tal. Kva for eit?
|
15
KnowItJulekalender/2020/01/check-numbers.js
Normal file
15
KnowItJulekalender/2020/01/check-numbers.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const { readFile } = require('../../../helpers');
|
||||||
|
const file = readFile('./numbers.txt').trim();
|
||||||
|
|
||||||
|
// Split file into an array
|
||||||
|
// Convert each entry from string to int.
|
||||||
|
const numbers = file.split(',').map(i => parseInt(i, 10));
|
||||||
|
|
||||||
|
for (let i = 1; i < 100000; i++)
|
||||||
|
{
|
||||||
|
if (numbers.includes(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(i);
|
||||||
|
}
|
1
KnowItJulekalender/2020/01/numbers.txt
Normal file
1
KnowItJulekalender/2020/01/numbers.txt
Normal file
File diff suppressed because one or more lines are too long
21
KnowItJulekalender/2020/02/README.md
Normal file
21
KnowItJulekalender/2020/02/README.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Julenissens sinneproblem
|
||||||
|
|
||||||
|
> Av Alfred Sollie Rønning
|
||||||
|
|
||||||
|
Julenissen skal levere pakker til alle snille barn. For å holde styr på pakkene merker alvene hver pakke med et unikt tall. Den første pakken får tallet 0 (alvene nullindekserer selvsagt), den andre pakken 1 osv. Julenissen drar alltid opp pakkene i numerisk rekkefølge fra sekken.
|
||||||
|
|
||||||
|
Julenissen hater av en eller annen grunn sifferet 7, og reagerer sterkt når han ser en pakke med dette sifferet. Hans reaksjon er at han kaster pakken i søpla, og i ukontrollert sinne også kaster de P neste pakkene, hvor P er nermeste primtall som er mindre eller lik tallet på pakken.
|
||||||
|
|
||||||
|
## Oppgave
|
||||||
|
|
||||||
|
Julenissen skal levere pakker til alle de snille barna i Norge. Terskelen er ganske lav for hva Julenissen anser som et snilt barn, vi er alle snille barn i Julenissens øyne. Dvs. hele norges befolkning på 5433000, skal få en pakke levert. Hvor mange av disse pakkene vil faktisk bli levert?
|
||||||
|
|
||||||
|
## Eksempel
|
||||||
|
|
||||||
|
Når julenissen drar opp pakke nr. 27, vil julenissen kaste pakke nr 27 + de 23 neste pakkene. Dvs. pakkene 27-50 vil aldri bli levert.
|
||||||
|
|
||||||
|
For 10 pakker vil 7 bli levert. Pakkene med nr 0, 1, 2, 3, 4, 5 og 6.
|
||||||
|
|
||||||
|
For 20 pakker vil 9 bli levert. Pakkene med nr 0, 1, 2, 3, 4, 5, 6, 15, 16.
|
||||||
|
|
||||||
|
For 10 000 Pakker vil 32 bli levert.
|
43
KnowItJulekalender/2020/02/gifts.js
Normal file
43
KnowItJulekalender/2020/02/gifts.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
const min = 0;
|
||||||
|
const max = 5433000;
|
||||||
|
let total = 0;
|
||||||
|
|
||||||
|
function isPrime(number)
|
||||||
|
{
|
||||||
|
if (number <= 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number % 2 === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i= 2; i < number; i++) {
|
||||||
|
if (number % i === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = min; i < max; i++) {
|
||||||
|
// HEHE.
|
||||||
|
const hasSeven = i.toString().includes('7');
|
||||||
|
|
||||||
|
if (!hasSeven) {
|
||||||
|
total++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let p = i; p > 1; p--) {
|
||||||
|
if (!isPrime(p)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(total);
|
2
KnowItJulekalender/README.md
Normal file
2
KnowItJulekalender/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# KnowItJulekalender
|
||||||
|
https://julekalender.knowit.no/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Alex Thomassen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
10
helpers.js
Normal file
10
helpers.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
function readFile(filename)
|
||||||
|
{
|
||||||
|
return fs.readFileSync(filename, 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
readFile,
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user