Initial commit
This commit is contained in:
commit
8fd936789f
|
@ -0,0 +1,885 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/jetbrains,intellij+iml,eclipse,visualstudio,sublimetext,windows,macos,emacs,vim,linux,c,c++,cmake,python,csharp,java
|
||||
|
||||
### Vim ###
|
||||
# swap
|
||||
[._]*.s[a-w][a-z]
|
||||
[._]s[a-w][a-z]
|
||||
# session
|
||||
Session.vim
|
||||
# temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# auto-generated tag files
|
||||
tags
|
||||
|
||||
|
||||
### JetBrains ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources/
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
.gradle
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
### JetBrains Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
|
||||
|
||||
### Csharp ###
|
||||
## 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
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
*.vcxproj.filters
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
**/Properties/launchSettings.json
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp_proj
|
||||
*.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
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# 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
|
||||
# TODO: 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
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable 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
|
||||
|
||||
# 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
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# 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
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# 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/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/
|
||||
|
||||
|
||||
### SublimeText ###
|
||||
# cache files for sublime text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using SublimeText
|
||||
# *.sublime-project
|
||||
|
||||
# sftp configuration file
|
||||
sftp-config.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
|
||||
### Windows ###
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
|
||||
### macOS ###
|
||||
*.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
# Thumbnails
|
||||
._*
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
### Emacs ###
|
||||
# -*- mode: gitignore; -*-
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
||||
|
||||
### Intellij+iml ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
|
||||
# Gradle:
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
|
||||
## File-based project format:
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
|
||||
# JIRA plugin
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
|
||||
### Intellij+iml Patch ###
|
||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||
|
||||
*.iml
|
||||
modules.xml
|
||||
.idea/misc.xml
|
||||
*.ipr
|
||||
|
||||
|
||||
### Linux ###
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
|
||||
### C ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
|
||||
# Precompiled Headers
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
|
||||
# Executables
|
||||
|
||||
|
||||
### CMake ###
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
CTestTestfile.cmake
|
||||
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
local_settings.py
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# dotenv
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
.venv/
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
|
||||
### Java ###
|
||||
*.class
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
|
||||
### VisualStudio ###
|
||||
## 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
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
|
||||
# Build results
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
|
||||
# NUNIT
|
||||
|
||||
# Build Results of an ATL Project
|
||||
|
||||
# .NET Core
|
||||
|
||||
|
||||
# Chutzpah Test files
|
||||
|
||||
# Visual C++ cache files
|
||||
|
||||
# Visual Studio profiler
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
|
||||
# TeamCity is a build add-in
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
|
||||
# Visual Studio code coverage results
|
||||
|
||||
# NCrunch
|
||||
|
||||
# MightyMoose
|
||||
|
||||
# Web workbench (sass)
|
||||
|
||||
# Installshield output folder
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
|
||||
# Click-Once directory
|
||||
|
||||
# Publish Web Output
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
|
||||
# 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
|
||||
|
||||
# NuGet Packages
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
# except build/, which is used as an MSBuild target.
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
|
||||
# Windows Store app package directories and files
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
# but keep track of directories ending in .cache
|
||||
|
||||
# Others
|
||||
|
||||
# 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
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
|
||||
# SQL Server files
|
||||
|
||||
# Business Intelligence projects
|
||||
|
||||
# Microsoft Fakes
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
|
||||
# Visual Studio 6 build log
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
|
||||
# Paket dependency manager
|
||||
|
||||
# FAKE - F# Make
|
||||
|
||||
# JetBrains Rider
|
||||
|
||||
# CodeRush
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/
|
||||
|
||||
### VisualStudio Patch ###
|
|
@ -0,0 +1,23 @@
|
|||
Individual files may be licensed differently, as noted in those files.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 individual contributors
|
||||
|
||||
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.
|
|
@ -0,0 +1,24 @@
|
|||
# Advent of Code 2017
|
||||
|
||||
## About
|
||||
|
||||
These are my solutions to the Advent of Code 2017.
|
||||
|
||||
## Author
|
||||
|
||||
Brandon Scott
|
||||
|
||||
## What is Advent of Code?
|
||||
|
||||
[Advent of Code](https://adventofcode.com/) is an Advent calendar of small programming
|
||||
puzzles for a variety of skill sets and skill levels that can be solved in any
|
||||
programming language you like. People use them as a speed contest, interview prep,
|
||||
company training, university coursework, practice problems, or to challenge
|
||||
each other.
|
||||
|
||||
## License
|
||||
|
||||
By default, all code in this project is licensed under the MIT license,
|
||||
copyright the individual contributor(s). Comments in individual files
|
||||
may specify an alternate license as chosen by a particular individual
|
||||
for their code. If not specified, the file is MIT.
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay1 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 1: Inverse Captcha";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string input = "1122";
|
||||
Console.WriteLine($"Example 1: {CalculateSumPart1(input)}");
|
||||
|
||||
input = "1111";
|
||||
Console.WriteLine($"Example 2: {CalculateSumPart1(input)}");
|
||||
|
||||
input = "1234";
|
||||
Console.WriteLine($"Example 3: {CalculateSumPart1(input)}");
|
||||
|
||||
input = "91212129";
|
||||
Console.WriteLine($"Example 4: {CalculateSumPart1(input)}");
|
||||
|
||||
input = File.ReadAllText("BScottDay1.txt");
|
||||
Console.WriteLine($"Part 1 Answer: {CalculateSumPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {CalculateSumPart2(input)}");
|
||||
}
|
||||
|
||||
static long CalculateSumPart1(string input)
|
||||
{
|
||||
long sum = 0;
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
if (input[i] == input[(i + 1) % input.Length])
|
||||
sum += int.Parse(input[i].ToString());
|
||||
return sum;
|
||||
}
|
||||
|
||||
static long CalculateSumPart2(string input)
|
||||
{
|
||||
long sum = 0;
|
||||
int step = input.Length / 2;
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
if (input[i] == input[(i + step) % input.Length])
|
||||
sum += int.Parse(input[i].ToString());
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
818275977931166178424892653779931342156567268946849597948944469863818248114327524824136924486891794739281668741616818614613222585132742386168687517939432911753846817997473555693821316918473474459788714917665794336753628836231159578734813485687247273288926216976992516314415836985611354682821892793983922755395577592859959966574329787693934242233159947846757279523939217844194346599494858459582798326799512571365294673978955928416955127211624234143497546729348687844317864243859238665326784414349618985832259224761857371389133635711819476969854584123589566163491796442167815899539788237118339218699137497532932492226948892362554937381497389469981346971998271644362944839883953967698665427314592438958181697639594631142991156327257413186621923369632466918836951277519421695264986942261781256412377711245825379412978876134267384793694756732246799739464721215446477972737883445615664755923441441781128933369585655925615257548499628878242122434979197969569971961379367756499884537433839217835728263798431874654317137955175565253555735968376115749641527957935691487965161211853476747758982854811367422656321836839326818976668191525884763294465366151349347633968321457954152621175837754723675485348339261288195865348545793575843874731785852718281311481217515834822185477982342271937155479432673815629144664144538221768992733498856934255518875381672342521819499939835919827166318715849161715775427981485233467222586764392783699273452228728667175488552924399518855743923659815483988899924199449721321589476864161778841352853573584489497263216627369841455165476954483715112127465311353411346132671561568444626828453687183385215975319858714144975174516356117245993696521941589168394574287785233685284294357548156487538175462176268162852746996633977948755296869616778577327951858348313582783675149343562362974553976147259225311183729415381527435926224781181987111454447371894645359797229493458443522549386769845742557644349554641538488252581267341635761715674381775778868374988451463624332123361576518411234438681171864923916896987836734129295354684962897616358722633724198278552339794629939574841672355699222747886785616814449297817352118452284785694551841431869545321438468118
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay10 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 10: Knot Hash";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string input = File.ReadAllText("BScottDay10.txt");
|
||||
Console.WriteLine($"Part 1 Answer: {KnotHashPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {KnotHashPart2(input)}");
|
||||
|
||||
Console.WriteLine($"Part 2 Example Answer #1 (blank): {KnotHashPart2("")}");
|
||||
Console.WriteLine($"Part 2 Example Answer #2 (AoC 2017): {KnotHashPart2("AoC 2017")}");
|
||||
Console.WriteLine($"Part 2 Example Answer #3 (1,2,3): {KnotHashPart2("1,2,3")}");
|
||||
Console.WriteLine($"Part 2 Example Answer #4 (1,2,4): {KnotHashPart2("1,2,4")}");
|
||||
}
|
||||
|
||||
private int KnotHashPart1(string input)
|
||||
{
|
||||
int[] lengths = Array.ConvertAll(input.Split(','), s => int.Parse(s));
|
||||
byte[] list = new byte[256];
|
||||
int pos = 0, skipSize = 0;
|
||||
|
||||
// initialize list
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
list[i] = (byte)i;
|
||||
|
||||
for (int i = 0; i < lengths.Length; i++)
|
||||
{
|
||||
byte[] buff = new byte[lengths[i]];
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
buff[j] = list[(pos + j) % list.Length];
|
||||
|
||||
Array.Reverse(buff);
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
list[(pos + j) % list.Length] = buff[j];
|
||||
|
||||
pos += (lengths[i] + skipSize) % list.Length; // wrap around
|
||||
skipSize++; // increase skip size
|
||||
}
|
||||
|
||||
return list[0] * list[1];
|
||||
}
|
||||
|
||||
private string KnotHashPart2(string input)
|
||||
{
|
||||
String suffix = Encoding.ASCII.GetString(new byte[] { 17, 31, 73, 47, 23 });
|
||||
byte[] lengths = Encoding.ASCII.GetBytes(input + suffix); //string of bytes and add a suffix
|
||||
byte[] list = new byte[256];
|
||||
byte[] denseHash = new byte[16];
|
||||
int pos = 0, skipSize = 0;
|
||||
|
||||
// initialize list
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
list[i] = (byte)i;
|
||||
|
||||
// 64 rounds of fun
|
||||
for (int x = 0; x < 64; x++)
|
||||
{
|
||||
for (int i = 0; i < lengths.Length; i++)
|
||||
{
|
||||
byte[] buff = new byte[lengths[i]];
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
buff[j] = list[(pos + j) % list.Length];
|
||||
|
||||
Array.Reverse(buff);
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
list[(pos + j) % list.Length] = buff[j];
|
||||
|
||||
pos += (lengths[i] + skipSize) % list.Length; // wrap around
|
||||
skipSize++; // increase skip size
|
||||
}
|
||||
}
|
||||
|
||||
// do the Xor magic
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
denseHash[i] ^= list[i * 16 + j];
|
||||
}
|
||||
|
||||
return BitConverter.ToString(denseHash).Replace("-", "").ToLower();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
94,84,0,79,2,27,81,1,123,93,218,23,103,255,254,243
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay11 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 11: Hex Ed";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
Console.WriteLine($"Part 1 Example Answer #1 (ne,ne,ne):\t\t{CalculateDistances("ne,ne,ne").Item1}");
|
||||
Console.WriteLine($"Part 1 Example Answer #2 (ne,ne,sw,sw):\t\t{CalculateDistances("ne,ne,sw,sw").Item1}");
|
||||
Console.WriteLine($"Part 1 Example Answer #3 (ne,ne,s,s):\t\t{CalculateDistances("ne,ne,s,s").Item1}");
|
||||
Console.WriteLine($"Part 1 Example Answer #4 (se,sw,se,sw,sw):\t{CalculateDistances("se,sw,se,sw,sw").Item1}");
|
||||
|
||||
string input = File.ReadAllText("BScottDay11.txt");
|
||||
Console.WriteLine($"Part 1 Answer:\t{CalculateDistances(input).Item1}");
|
||||
Console.WriteLine($"Part 2 Answer:\t{CalculateDistances(input).Item2}");
|
||||
}
|
||||
|
||||
private static Tuple<int,int> CalculateDistances(string input)
|
||||
{
|
||||
string[] commands = input.Split(',');
|
||||
|
||||
int x = 0, y = 0, distance = 0, maxDistance = 0;
|
||||
foreach (string cmd in commands)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case "n":
|
||||
y--;
|
||||
break;
|
||||
case "s":
|
||||
y++;
|
||||
break;
|
||||
|
||||
case "ne":
|
||||
x++;
|
||||
break;
|
||||
case "sw":
|
||||
x--;
|
||||
break;
|
||||
|
||||
case "se":
|
||||
y++;
|
||||
x++;
|
||||
break;
|
||||
|
||||
case "nw":
|
||||
y--;
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
|
||||
distance = Math.Max(Math.Abs(y), Math.Max(Math.Abs(x), Math.Abs((x - y) * -1)));
|
||||
|
||||
if (distance > maxDistance)
|
||||
maxDistance = distance;
|
||||
}
|
||||
|
||||
return Tuple.Create(distance,maxDistance);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay12 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 12: Digital Plumber";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string[] exampleInput = new[] {
|
||||
"0 <-> 2",
|
||||
"1 <-> 1",
|
||||
"2 <-> 0, 3, 4",
|
||||
"3 <-> 2, 4",
|
||||
"4 <-> 2, 3, 6",
|
||||
"5 <-> 6",
|
||||
"6 <-> 4, 5"
|
||||
};
|
||||
|
||||
Console.WriteLine($"Part 1 Example Answer: {DigitalPlumberPart1(exampleInput)}");
|
||||
Console.WriteLine($"Part 2 Example Answer: {DigitalPlumberPart2(exampleInput)}");
|
||||
|
||||
string[] input = File.ReadAllLines("BScottDay12.txt");
|
||||
|
||||
Console.WriteLine($"Part 1 Answer: {DigitalPlumberPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {DigitalPlumberPart2(input)}");
|
||||
}
|
||||
|
||||
private int DigitalPlumberPart1(string[] input)
|
||||
{
|
||||
Dictionary<int, int[]> programDictionary = ParseInput(input);
|
||||
List<int> connected = new List<int>();
|
||||
GetConnectedPrograms(programDictionary, connected, 0, 0);
|
||||
return connected.Count;
|
||||
}
|
||||
|
||||
private int DigitalPlumberPart2(string[] input)
|
||||
{
|
||||
Dictionary<int, int[]> programDictionary = ParseInput(input);
|
||||
List<int> connected = new List<int>();
|
||||
int groups = 0;
|
||||
foreach (var programId in programDictionary.Keys)
|
||||
{
|
||||
if (!connected.Contains(programId))
|
||||
{
|
||||
GetConnectedPrograms(programDictionary, connected, programId, 0);
|
||||
groups++;
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
private void GetConnectedPrograms(Dictionary<int, int[]> programDictionary, List<int> connected, int start, int level)
|
||||
{
|
||||
// stack overflow protection
|
||||
if (level > 100)
|
||||
return;
|
||||
|
||||
foreach (var programId in programDictionary[start])
|
||||
{
|
||||
if (!connected.Contains(programId))
|
||||
{
|
||||
connected.Add(programId);
|
||||
GetConnectedPrograms(programDictionary, connected, programId, ++level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, int[]> ParseInput(string[] input)
|
||||
{
|
||||
Dictionary<int, int[]> programDictionary = new Dictionary<int, int[]>();
|
||||
Regex regex = new Regex(@"([\d]+) <-> (?:([\d]+)*(?:, )?)*");
|
||||
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
Match match = regex.Match(input[i]);
|
||||
if (match.Success)
|
||||
{
|
||||
List<int> programList = new List<int>();
|
||||
|
||||
foreach (Capture capture in match.Groups[2].Captures)
|
||||
programList.Add(int.Parse(capture.Value));
|
||||
|
||||
programDictionary.Add(int.Parse(match.Groups[1].Value), programList.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
return programDictionary;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay13 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 13: Packet Scanners";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string[] exampleInput = new[] {
|
||||
"0: 3",
|
||||
"1: 2",
|
||||
"4: 4",
|
||||
"6: 4"
|
||||
};
|
||||
|
||||
Console.WriteLine($"Part 1 Example Answer: {PacketScannerPart1(exampleInput)}");
|
||||
Console.WriteLine($"Part 2 Example Answer: {PacketScannerPart2(exampleInput)}");
|
||||
|
||||
string[] input = File.ReadAllLines("BScottDay13.txt");
|
||||
|
||||
Console.WriteLine($"Part 1 Answer: {PacketScannerPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {PacketScannerPart2(input)}");
|
||||
|
||||
}
|
||||
|
||||
private int PacketScannerPart1(string[] input)
|
||||
{
|
||||
Dictionary<int, Layer> firewallList = new Dictionary<int, Layer>();
|
||||
|
||||
foreach (var layer in input)
|
||||
{
|
||||
int[] args = Array.ConvertAll(layer.Split(':'), s => int.Parse(s.Trim()));
|
||||
firewallList.Add(args[0], new Layer(args[0], args[1]));
|
||||
}
|
||||
|
||||
int totalSeverity = 0;
|
||||
foreach (int key in firewallList.Keys)
|
||||
{
|
||||
if (key % (2 * firewallList[key].Range - 2) == 0)
|
||||
totalSeverity += firewallList[key].Severity;
|
||||
}
|
||||
|
||||
return totalSeverity;
|
||||
}
|
||||
|
||||
private int PacketScannerPart2(string[] input)
|
||||
{
|
||||
Dictionary<int, Layer> firewallList = new Dictionary<int, Layer>();
|
||||
|
||||
foreach (var layer in input)
|
||||
{
|
||||
int[] args = Array.ConvertAll(layer.Split(':'), s => int.Parse(s.Trim()));
|
||||
firewallList.Add(args[0], new Layer(args[0], args[1]));
|
||||
}
|
||||
|
||||
for (int delay = 10; delay < int.MaxValue; delay++)
|
||||
{
|
||||
bool isCaught = false;
|
||||
foreach (int key in firewallList.Keys)
|
||||
{
|
||||
if ((key + delay) % (2 * firewallList[key].Range - 2) == 0)
|
||||
{
|
||||
isCaught = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCaught)
|
||||
return delay;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
class Layer
|
||||
{
|
||||
public int Depth { get; private set; }
|
||||
public int Range { get; private set; }
|
||||
public int Severity => Depth * Range;
|
||||
|
||||
public Layer(int depth, int range)
|
||||
{
|
||||
Depth = depth;
|
||||
Range = range;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
0: 4
|
||||
1: 2
|
||||
2: 3
|
||||
4: 4
|
||||
6: 6
|
||||
8: 5
|
||||
10: 6
|
||||
12: 6
|
||||
14: 6
|
||||
16: 8
|
||||
18: 8
|
||||
20: 9
|
||||
22: 12
|
||||
24: 8
|
||||
26: 8
|
||||
28: 8
|
||||
30: 12
|
||||
32: 12
|
||||
34: 8
|
||||
36: 12
|
||||
38: 10
|
||||
40: 12
|
||||
42: 12
|
||||
44: 10
|
||||
46: 12
|
||||
48: 14
|
||||
50: 12
|
||||
52: 14
|
||||
54: 14
|
||||
56: 12
|
||||
58: 14
|
||||
60: 12
|
||||
62: 14
|
||||
64: 18
|
||||
66: 14
|
||||
68: 14
|
||||
72: 14
|
||||
76: 14
|
||||
82: 14
|
||||
86: 14
|
||||
88: 18
|
||||
90: 14
|
||||
92: 17
|
|
@ -0,0 +1,134 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay14 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 14: Disk Defragmentation";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string input = "flqrgnkx";
|
||||
Console.WriteLine($"Part 1 Example Answer: {DiskDefragmentationPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Example Answer: {DiskDefragmentationPart2(input)}");
|
||||
|
||||
input = "oundnydw";
|
||||
Console.WriteLine($"Part 1 Answer: {DiskDefragmentationPart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {DiskDefragmentationPart2(input)}");
|
||||
}
|
||||
|
||||
private int DiskDefragmentationPart1(string input)
|
||||
{
|
||||
byte[][] disk = new byte[128][];
|
||||
for (int i = 0; i < 128; i++)
|
||||
disk[i] = KnotHash($"{input}-{i}");
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 128; i++)
|
||||
for (int j = 0; j < 128; j++)
|
||||
sum += disk[i][j];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private int DiskDefragmentationPart2(string input)
|
||||
{
|
||||
byte[][] disk = new byte[128][];
|
||||
for (int i = 0; i < 128; i++)
|
||||
disk[i] = KnotHash($"{input}-{i}");
|
||||
|
||||
List<Tuple<int, int>> map = new List<Tuple<int, int>>();
|
||||
for (int i = 0; i < 128; i++)
|
||||
for (int j = 0; j < 128; j++)
|
||||
if (disk[i][j] == 1)
|
||||
map.Add(new Tuple<int, int>(i, j));
|
||||
|
||||
int regions = 0;
|
||||
while (map.Count > 0)
|
||||
{
|
||||
FindRegion(map);
|
||||
regions++;
|
||||
}
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
private void FindRegion(List<Tuple<int, int>> map)
|
||||
{
|
||||
Stack<Tuple<int, int>> stack = new Stack<Tuple<int, int>>();
|
||||
|
||||
stack.Push(map[map.Count - 1]);
|
||||
map.RemoveAt(map.Count - 1);
|
||||
|
||||
int[,] deltas = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
Tuple<int, int> fragment = stack.Pop();
|
||||
for (int i = 0; i < deltas.GetLength(0); i++)
|
||||
{
|
||||
int dy = fragment.Item1 + deltas[i, 0];
|
||||
int dx = fragment.Item2 + deltas[i, 1];
|
||||
|
||||
if (dy < 0 || dy >= 128 || dx < 0 || dy >= 128)
|
||||
continue;
|
||||
|
||||
int index = map.FindIndex(eri => eri.Item1 == dy && eri.Item2 == dx);
|
||||
if (index != -1)
|
||||
{
|
||||
stack.Push(map[index]);
|
||||
map.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// from day 10
|
||||
private byte[] KnotHash(string input)
|
||||
{
|
||||
String suffix = Encoding.ASCII.GetString(new byte[] { 17, 31, 73, 47, 23 });
|
||||
byte[] lengths = Encoding.ASCII.GetBytes(input + suffix); //string of bytes and add a suffix
|
||||
byte[] list = new byte[256];
|
||||
byte[] denseHash = new byte[16];
|
||||
int pos = 0, skipSize = 0;
|
||||
|
||||
// initialize list
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
list[i] = (byte)i;
|
||||
|
||||
// 64 rounds of fun
|
||||
for (int x = 0; x < 64; x++)
|
||||
{
|
||||
for (int i = 0; i < lengths.Length; i++)
|
||||
{
|
||||
byte[] buff = new byte[lengths[i]];
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
buff[j] = list[(pos + j) % list.Length];
|
||||
|
||||
for (int j = 0; j < buff.Length; j++)
|
||||
list[(pos + j) % list.Length] = buff[(buff.Length - 1) - j];
|
||||
|
||||
pos += (lengths[i] + skipSize++) % list.Length; // wrap around, increase skipsize
|
||||
}
|
||||
}
|
||||
|
||||
// do the Xor magic
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
denseHash[i] ^= list[i * 16 + j];
|
||||
}
|
||||
|
||||
byte[] output = new byte[128];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 8; j++)
|
||||
output[i * 8 + (7 - j)] = (byte)((denseHash[i] >> j) & 0x1);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay15 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 15: Dueling Generators";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
int sampleSize = 40000000;
|
||||
int inputA = 679;
|
||||
int inputB = 771;
|
||||
|
||||
Console.WriteLine($"Part 1 Example Answer: {DuelingGeneratorsPart1(sampleSize, 65, 8921)}");
|
||||
Console.WriteLine($"Part 1 Answer: {DuelingGeneratorsPart1(sampleSize, inputA, inputB)}");
|
||||
|
||||
Console.WriteLine($"Part 2 Example Answer: {DuelingGeneratorsPart2(sampleSize, 65, 8921)}");
|
||||
Console.WriteLine($"Part 2 Answer: {DuelingGeneratorsPart2(sampleSize, inputA, inputB)}");
|
||||
}
|
||||
|
||||
private int DuelingGeneratorsPart1(int sampleSize, int generatorA, int generatorB)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < sampleSize; i++)
|
||||
{
|
||||
generatorA = (int)(((ulong) generatorA * 16807ul) % int.MaxValue);
|
||||
generatorB = (int)(((ulong) generatorB * 48271ul) % int.MaxValue);
|
||||
|
||||
if ((generatorA & 0xffff) == (generatorB & 0xffff))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private int DuelingGeneratorsPart2(int sampleSize, int generatorA, int generatorB)
|
||||
{
|
||||
int count = 0;
|
||||
List<int> cmpA = new List<int>();
|
||||
List<int> cmpB = new List<int>();
|
||||
|
||||
for (int i = 0; i < sampleSize; i++)
|
||||
{
|
||||
generatorA = (int)(((ulong)generatorA * 16807ul) % int.MaxValue);
|
||||
generatorB = (int)(((ulong)generatorB * 48271ul) % int.MaxValue);
|
||||
|
||||
if (generatorA % 4 == 0) cmpA.Add(generatorA);
|
||||
if (generatorB % 8 == 0) cmpB.Add(generatorB);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Math.Min(cmpA.Count, cmpB.Count); i++)
|
||||
{
|
||||
if ((cmpA[i] & 0xffff) == (cmpB[i] & 0xffff))
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AOC2017
|
||||
{
|
||||
class BScottDay16 : BScottSolution
|
||||
{
|
||||
public override string Name => "Day 16: Permutation Promenade";
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
string[] input = File.ReadAllText("BScottDay16.txt").Split(',');
|
||||
|
||||
Console.WriteLine($"Part 1 Answer: {PermutationPromenadePart1(input)}");
|
||||
Console.WriteLine($"Part 2 Answer: {PermutationPromenadePart2(input)}");
|
||||
}
|
||||
|
||||
private string PermutationPromenadePart1(string[] instructions)
|
||||
{
|
||||
char[] programs = new char[16];
|
||||
|
||||
for (int i = 0; i < programs.Length; i++)
|
||||
programs[i] = (char)('a' + i);
|
||||
|
||||
for (int i = 0; i < instructions.Length; i++)
|
||||
{
|
||||
string[] args = instructions[i].Substring(1).Split('/');
|
||||
int a, b;
|
||||
char tmp;
|
||||
switch (instructions[i][0])
|
||||
{
|
||||
case 's': // Spin
|
||||
int startPos = 16 - int.Parse(args[0]);
|
||||
char[] temp = new char[16];
|
||||
for (int j = 0; j < temp.Length; j++)
|
||||
temp[j] = programs[(j + startPos) % temp.Length];
|
||||
for (int j = 0; j < temp.Length; j++)
|
||||
programs[j] = temp[j];
|
||||
break;
|
||||
|
||||
case 'x': // Exchange
|
||||
a = int.Parse(args[0]);
|
||||
b = int.Parse(args[1]);
|
||||
tmp = programs[b];
|
||||
programs[b] = programs[a];
|
||||
programs[a] = tmp;
|
||||
break;
|
||||
|
||||
case 'p': // Partner
|
||||
a = Array.IndexOf(programs, args[0][0]);
|
||||
b = Array.IndexOf(programs, args[1][0]);
|
||||
tmp = programs[b];
|
||||
programs[b] = programs[a];
|
||||
programs[a] = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new String(programs);
|
||||
}
|
||||
|
||||
private string PermutationPromenadePart2(string[] instructions)
|
||||
{
|
||||
char[] programs = new char[16];
|
||||
|
||||
List<string> cache = new List<string>();
|
||||
|
||||
for (int i = 0; i < programs.Length; i++)
|
||||
programs[i] = (char)('a' + i);
|
||||
|
||||
// add initial state to cache
|
||||
cache.Add(new string(programs));
|
||||
|
||||
for (int x = |