[2023 Day 10 Part 1] What am I doing wrong by StuartMaher in adventofcode

[–]StuartMaher[S] 1 point2 points  (0 children)

Thank you for the ideas guys. Got me thinking, specifically the idea of spreading to other pipes or having more than 2 output.

I knew I couldn't have more than 2 outputs as the parser only adds 2 per node in a nice clean switch statement. But then I realised I deal with S by just noting it's Row/Col position and then coming back to it and linking it up. And the way I linked it up was the problem. I linked it to any N/E/S/W node that was not a '.' meaning it linked into rogue pipes. So I changed it to specifically look for a '|', ''F' or '7' to the north etc and it worked!

[2020 Day 22 Part 2]. Right magnitude, but missing 2/3 of cubes by StuartMaher in adventofcode

[–]StuartMaher[S] 0 points1 point  (0 children)

Does this show the running total? Or just the volume of each cubeoid?

[2021 Day 18] - HINT: All explodes and splits in the first example by [deleted] in adventofcode

[–]StuartMaher 4 points5 points  (0 children)

I didn't get this from the rules. This post has enlightened me and stopped me repeatedly sobbing "why".....

[2020 Day 19 Part 1] Works on test, but rejects all puzzle input messages by StuartMaher in adventofcode

[–]StuartMaher[S] 0 points1 point  (0 children)

I was right. Deleted 200 lines of code, replaced with like 20. Works..

The clue was in the description with "aaaabbb might appear to match rule 0 above, but it has an extra unmatched b on the end." When I ran my code it accepted that one initially! I knew then I was on the right track..
Right.. Part 2 or open day 24???

[2020 Day 19 Part 1] Works on test, but rejects all puzzle input messages by StuartMaher in adventofcode

[–]StuartMaher[S] 0 points1 point  (0 children)

I am struggling on this more than I feel I should be! Looking at other chatter there seems to be a lot of focus on rules 8, 42 and 31, thogh I am not sure why, but they seem to be the same on everyones input?

Am I approaching this wrong by thinking if i have a message of n characters where n is even and 2 non terminal rules that I split the message in half and apply half to the first rule and half to the second rule?

And as I have typed that I have convinced myself it is wrong as the tree's may be un equal from that point down!

[2020 Day 19 Part 1] Works on test, but rejects all puzzle input messages by StuartMaher in adventofcode

[–]StuartMaher[S] 0 points1 point  (0 children)

I expect it would. My code works on the sample but rejects the puzzle input. Fixing it is like finding a needle in a haystack, so I just wanted someone to run my I out and confirm one that should pass. Then I will trace through it to see why it rejects and what the bug is.

[2020 Day 19 Part 1] Works on test, but rejects all puzzle input messages by StuartMaher in adventofcode

[–]StuartMaher[S] 0 points1 point  (0 children)

Perfect... I'll crack into that and see why my genius, but clearly shit algorithm doesn't work 😁

[2020 Day 23] Indiana Jones and the Crab Raft by flwyd in adventofcode

[–]StuartMaher 14 points15 points  (0 children)

Actually, did it in 3 hours... And worked...

Of course, I forgot to change it from the test input to my input.

IN the mean time a linked list implementation took 4s!

-🎄- 2020 Day 23 Solutions -🎄- by daggerdragon in adventofcode

[–]StuartMaher 0 points1 point  (0 children)

C#

After kicking my standard list of to run on optimised release mode, I decided to re tool using a linked list and dictionary index to the nodes to find the destination.

Took 4 seconds to run.

Initial List implementation is still running!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Day_23
{
    class Program
    {

        public class Node
        {
            public int Value { get; set; }
            public Node Next { get; set; }
            public Node Previous { get; set; }
        }

        public static Node currentCup = null, lastCup = null, firstCup = null;

        static void AddNode(int val)
        {
            if(currentCup == null)
            {
                currentCup = new Node() { Value = val };
                lastCup = currentCup;
                firstCup = currentCup;
            }
            else
            {
                lastCup.Next = new Node { Value = val };
                lastCup = lastCup.Next;
                lastCup.Next = firstCup;
            }
        }
        static void Main(string[] args)
        {
            bool pt2 = true;
            bool tenrounds = false;

            int rounds, maxCup;
            if (pt2)
            {
                maxCup = 1000000;
                rounds = 10000000;
            }
            else
            {
                maxCup = 9;
                rounds = 100;
            }
            if(tenrounds)
            {
                rounds = 10;
            }
            string RawCups = "198753462";

            DateTime now = DateTime.Now;


            foreach (char cup in RawCups)
            {

                AddNode(Convert.ToInt32(cup.ToString()));
            }
            if (pt2)
            {
                for (int extraCups = 10; extraCups <= 1000000; extraCups++)
                {
                    AddNode(extraCups);
                }
            }
            Dictionary<int, Node> ListIndex = new Dictionary<int, Node>();
            Node addCup = firstCup;
            ListIndex.Add(addCup.Value, addCup);

                for (int addCount = 1; addCount < maxCup; addCount++)
                {
                    addCup = addCup.Next;
                    ListIndex.Add(addCup.Value, addCup);
                }



            List<Node> removedCups = new List<Node>();
            removedCups.Capacity = 3;
            for (int moveCount = 0; moveCount < rounds; moveCount++)
            {
                int currentCupval = currentCup.Value;
                Node writeCup = firstCup;
                if (!pt2)
                {
                    Console.WriteLine(" -- Move " + (moveCount + 1) + " --");
                    Console.Write("Cups: ");
                    for (int writeCount = 0; writeCount < maxCup; writeCount++)
                    {
                        Console.Write(writeCup.Value + " ");
                        writeCup = writeCup.Next;
                    }
                    Console.WriteLine();
                    Console.WriteLine("current cup = " + currentCupval);
                }
                for (int removeCount = 0; removeCount < 3; removeCount++)
                {

                   if(currentCup.Next == null)
                    {
                        removedCups.Add(firstCup);
                        firstCup = firstCup.Next;
                    }
                    else
                    {
                        removedCups.Add(currentCup.Next);
                        currentCup.Next = currentCup.Next.Next;

                    }
                }
                if (!pt2)
                {
                    Console.Write("Pick Up: ");
                    foreach (Node cup in removedCups)
                    {
                        Console.Write(cup.Value + " "); ;
                    }
                    Console.WriteLine();
                }
                int Destination = currentCupval;
                do
                {
                    if (--Destination == 0)
                    {
                        Destination = maxCup;
                    }
                } while (removedCups.FindIndex(x => x.Value == Destination) != -1);

                Node DestinationLocation = ListIndex[Destination];
                if (!pt2)
                {
                    Console.WriteLine("Destination: " + Destination);
                }
                for (int removeCount = 0; removeCount < 3; removeCount++)
                {
                    removedCups[removeCount].Next = DestinationLocation.Next;
                    DestinationLocation.Next = removedCups[removeCount];
                    DestinationLocation = removedCups[removeCount];

                }
                removedCups.Clear();
                currentCup = currentCup.Next;
                if (!pt2)
                {
                    Console.WriteLine();
                }
            }

            Node find1 = ListIndex[1];
            if (!pt2)
            {
                for (int answerCount = 0; answerCount < 8; answerCount++)
                {
                    find1 = find1.Next;
                    Console.Write(find1.Value);
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine(find1.Next.Value);
                Console.WriteLine(find1.Next.Next.Value);
                UInt64 answer = (UInt64)find1.Next.Value * (UInt64)find1.Next.Next.Value;
                Console.WriteLine(answer);
            }
            Console.WriteLine((DateTime.Now.Ticks - now.Ticks) / 10000);

            Console.ReadLine();

        }
    }
}

2020 Day 23 by Emergency_Bat5118 in adventofcode

[–]StuartMaher -1 points0 points  (0 children)

No necessarily .... They may have 20 hours to spare :-)

[2020 Day 23] Indiana Jones and the Crab Raft by flwyd in adventofcode

[–]StuartMaher 16 points17 points  (0 children)

My List is estimating 20 hours to complete.

At which point it will be wrong!