Skip to content

Instantly share code, notes, and snippets.

View Butjok's full-sized avatar

Viktor Fedotov Butjok

View GitHub Profile
@Butjok
Butjok / Day20.cs
Last active December 20, 2021 21:35
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Butjok.Aoc.Aoc2021.Day20
{
public static class Solution
{
[TestCase(Inputs.example, 2, ExpectedResult = 35)]
[TestCase(Inputs.example, 50, ExpectedResult = 3351)]
@Butjok
Butjok / Day18.cs
Last active December 19, 2021 02:00
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Butjok.Aoc.Aoc2021.Day18
{
/*
* Делаю все операции explode и split на связанном списке токенов: по сути как работа со строками.
* Когда все готово - выстраиваю двоичное дерево и подсчитываю магнитуду рекурсивно.
@Butjok
Butjok / Day17.cs
Last active December 17, 2021 18:12
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Butjok.Aoc.Aoc2021.Day17
{
public static class Solution
{
public const int maxYSpeed = 9999;
@Butjok
Butjok / Day16.cs
Last active December 17, 2021 02:02
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Butjok.Aoc2021.Day16
{
public abstract record Packet(long Version, long TypeId);
public record LiteralValuePacket(long Version, long TypeId, long Value) : Packet(Version, TypeId);
public record OperatorPacket(long Version, long TypeId, IList<Packet> SubPackets) : Packet(Version, TypeId);
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
internal class Program
{
public static void Main(string[] args) {
var lines = File.ReadLines("input.txt").Select(line => {
var numbers = line.Replace(" -> ", ",").Split(',').Select(int.Parse).ToList();
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
internal class Program
{
private class Board
{
public const int size = 5;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public class Db
{
public static Db instance = new Db();
public Dictionary<int, object> entities = new Dictionary<int, object>();
public int nextEntityId;
using System;
using System.Collections.Generic;
public static class Observers
{
public static Dictionary<int, HashSet<Action>> observers = new Dictionary<int, HashSet<Action>>();
public static List<Action> list = new List<Action>();
public static void Notify(int entityId)
{
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Pool<T> where T : Component, ISpawnable
{
public HashSet<T> freeInstances = new HashSet<T>();
public Transform parent;
public T prefab;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
[JsonObject(MemberSerialization.OptIn)]
public class CircularStack<T>
{
[JsonProperty] public int maxVirtualCount;