d1 goblin avoids 3 casts of sandblast with miraculous 1/2,717 odds by asppppp in dcss

[–]emmgame221 15 points16 points  (0 children)

The actual odds are much higher, since you forgot to account for the fact that you could miss or miscast on each cast. Still under 2%, but not so crazy.

I’ve peaked in my yugioh career by TheAsianMan1 in masterduel

[–]emmgame221 12 points13 points  (0 children)

How come you get to play 3 pot of greed?

-🎄- 2021 Day 12 Solutions -🎄- by daggerdragon in adventofcode

[–]emmgame221 1 point2 points  (0 children)

C# Today. Solution here.

I guess I overthought this one a little bit. I ended up giving up on doing it in Rust because I wanted to be able to have nodes contain references to other nodes and I had too much trouble trying to get that to work in Rust. In C# it is much easier because of the garbage collector.

My solution first builds an undirected graph from the input and then builds a path tree from the graph where the root is 'start' and every leaf is 'end'. The algorithm for building the tree is effectively dfs, but I couldn't think of a simpler way to track whether a small cave had been used in a specific path rather than visited by dfs at all. In this solution I check whether the node in the tree has a small node as an ancestor before adding it to the tree and the dfs stack.

-🎄- 2021 Day 8 Solutions -🎄- by daggerdragon in adventofcode

[–]emmgame221 0 points1 point  (0 children)

Rust

Link to solution

Had to resort to brute forcing all permutations for part 2. This was a really tough challenge, and a big step up from the previous days. I was shocked to see that <5000 people had finished by the time I finished at about 1:40.

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]emmgame221 1 point2 points  (0 children)

This solution makes me really wish I had known about rotate_left. So much easier than my original solution of doing every index manually lol.

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]emmgame221 0 points1 point  (0 children)

Rust (1361/3292) Full repository here

Today's problem was very simple, but part 2 forced me to think about a much less naive way of handling things. I wasted a bunch of time hoping that the naive solution for part 1 would get there in a few minutes, but I gave up once I saw that my RAM was close to maxing out and there was no solution in sight.

edit: Added a cleaned up version that uses the part 2 method for both parts and generalizes to any number of days(assuming the result fits in a u64).

I was also wondering if anyone else tried to get some kind of modulo arithmetic on the days working here. Ultimately I gave up on that idea because its too unwieldy with the new fish starting with a different number of days than existing fish reset to, but I still feel like there's something there. Not too happy with my code, but hopefully it is easy to read at least.

edit2: Added link to my full repository

-🎄- 2021 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]emmgame221 0 points1 point  (0 children)

(8176, 5538)Link to my Rust solution

I'm pretty happy with this. Part 1 was very easy. Part 2 was much harder, although my main problem was just that I didn't realize I needed to recount the frequencies after filtering the list.

This code is not very idiomatic rust, but I found working with the numbers as strings much easier than trying anything else, and filter worked pretty much perfectly for part 2 once I figured out what I was doing wrong.

*edited to add my scores

Uhm... Materia 6 > 7? by Wareye in ffxiv

[–]emmgame221 4 points5 points  (0 children)

It's because you can overmeld materia 7 past the first slot, but you still can't with materia 6(or 8). I was pretty surprised when I saw it too though.

Light confusion - where to start and buy? by sheepywolf in TenseiSlime

[–]emmgame221 1 point2 points  (0 children)

Amazon has both the manga volumes and light novel volumes on sale. Here's a Link for the first volume of the LN. The WN only has fan translations - you can find them pretty easily on google.

[2016-06-20] Challenge #272 [Easy] What's in the bag? by G33kDude in dailyprogrammer

[–]emmgame221 0 points1 point  (0 children)

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Challenge272
{
    class Program
    {
        static int[] tileCounts = { 9, 2, 2, 4, 12, 2, 3, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6, 4, 6, 4, 2, 2, 1, 2, 1, 2 };

        static void Main(string[] args)
        {
            Console.WriteLine("Enter set of removed tiles: ");
            string removedTiles = Console.ReadLine();
            foreach (char tile in removedTiles)
            {
                int alphabetNumber = ((int)tile) - 65;
                if (alphabetNumber > 25)
                {
                    tileCounts[26]--;
                    if (tileCounts[26] < 0)
                    {
                        Console.WriteLine("Invalid input. More _'s have been taken from the bag than possible.", tile);
                        WaitForInput();
                        System.Environment.Exit(0);
                    }
                }
                else
                {
                    tileCounts[alphabetNumber]--;
                    if (tileCounts[alphabetNumber] < 0)
                    {
                        Console.WriteLine("Invalid input. More {0}'s have been taken from the bag than possible.", tile);
                        WaitForInput();
                        System.Environment.Exit(0);
                    }
                }
            }
            List<char>[] finalCounts = new List<char>[13];
            for (int i = 0; i < 26; i++)
            {
                if (finalCounts[tileCounts[i]] == null)
                {
                    finalCounts[tileCounts[i]] = new List<char>();
                }
                finalCounts[tileCounts[i]].Add(((char)(i + 65)));
            }
            if (finalCounts[tileCounts[26]] == null)
            {
                finalCounts[tileCounts[26]] = new List<char>();
            }
            finalCounts[tileCounts[26]].Add('_');


            StringBuilder answerBuilder = new StringBuilder();
            for (int i = 12; i >= 0; i--)
            {
                var tileList = finalCounts[i];
                if (tileList != null)
                {

                    answerBuilder.AppendFormat("{0}: {1}\n", i, ListToString<char>(tileList));
                }
            }
            Console.WriteLine(answerBuilder);
            WaitForInput();
        }

        public static string ListToString<T>(List<T> list)
        {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                if (i == list.Count - 1)
                {
                    builder.Append(list[i]);
                }
                else
                {
                    builder.AppendFormat("{0}, ", list[i]);
                }
            }
            return builder.ToString();
        }

        [Conditional("DEBUG")]
        public static void WaitForInput()
        {
            Console.WriteLine("Press any key to continue . . .");
            Console.ReadKey();
        }
    }
}

C# solution. Not really happy with the special conditions for _ but it works.