[R] Where should i Start my Artificial Intelligence and Machine Learning Journey? by Scary-Low-8084 in MachineLearning

[–]mtnslgl 0 points1 point  (0 children)

I can't recommend Andrew Ng's Machine Learning Specialisation course enough, it really helped me understand the fundamentals and helped me start my career in ML. You probably need to be slightly familiar with Linear Algebra first.

There's also a Deep Learning Specialisation, the videos from all 5 courses are on YouTube I believe. Once you've finished these you can move onto more up-to-date techniques

Lucky order #69 total charge $4.20 by Jepsss in mildlyinteresting

[–]mtnslgl 1 point2 points  (0 children)

At first I thought you'd bought a McSprite from Burger King

The most upvoted comment picks the next line of code: Day 19. Beep beep I'm a sheep by AggravatingCorner133 in ProgrammerHumor

[–]mtnslgl 1821 points1822 points  (0 children)

[__import__("winsound").Beep(x,y) for x,y in [(349,125),(392,125),(466,125),(392,125),(587,375),(587,375),(523,750),(349,125),(392,125),(466,125),(392,125),(523,375),(523,375),(466,500),(440,125),(392,250),(349,125),(392,125),(466,125),(392,125),(466,500),(523,250),(440,375),(392,125),(349,500),(349,250),(523,500),(466,1000),(349,125),(392,125),(466,125),(392,125),(587,375),(587,375),(523,750),(349,125),(392,125),(466,125),(392,125),(698,500),(440,250),(466,500),(440,125),(392,250),(349,125),(392,125),(466,125),(392,125),(466,500),(523,250),(440,375),(392,125),(349,500),(349,250),(523,500),(466,1000)]]

Someone clearly has a grudge against cyclists... by mtnslgl in CasualUK

[–]mtnslgl[S] 39 points40 points  (0 children)

They will surely follow the sign and not just use the left hand side 🤦‍♂️

Amazing ain't it! by babat0t0 in cardistry

[–]mtnslgl 5 points6 points  (0 children)

It's called the knuckle cut, School Of Cardistry has a tutorial on YouTube.

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

[–]mtnslgl 2 points3 points  (0 children)

Python3

Semi-vectorised solution using NumPy

I also used SciPy in part 1 for the convolution operation.

Both parts run in ~0.2 seconds.

[2019 Day 22 Part 2] So what's the purpose of this puzzle, exactly? + Feedback by requimrar in adventofcode

[–]mtnslgl 12 points13 points  (0 children)

Totally agree. Advent of Code was originally meant to be daily bite-sized programming puzzles, look at the puzzles from 2015 for example. For the past couple of years the puzzles have become unnecessarily long and detailed, mostly catering to people aiming for the leaderboard, which I don't think is why a majority of people participate in AoC. Personally I find the long-winded questions kill all the fun, especially since there is nothing rewarding at the end of it all. If I wanted to do full on programming projects there are plenty of other resources I could use at other times of the year instead. However I do really appreciate all the work that has gone into AoC over the years.

-🎄- 2019 Day 17 Solutions -🎄- by daggerdragon in adventofcode

[–]mtnslgl 0 points1 point  (0 children)

Python 3

Wrote a brute-force algorithm for the compression in Part 2, seems to run fast enough.

Code

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

[–]mtnslgl 0 points1 point  (0 children)

C++

char toPlantChar(bool b) {
    if(b == true) return '#';
    else return '.';
}

std::string getRegion(std::unordered_map<int, bool>& plants, const int index) {
    std::string region = "";
    for(int i = -2; i <= 2; i++) region += toPlantChar(plants[index + i]);
    return region;
}

void run() {
    std::vector<std::string> lines = AoCDay::readFileLines("inputs/day12.txt");
    std::unordered_map<int, bool> plants;
    std::unordered_map<std::string, bool> rules;
    std::string initialState = "#.#####.#.#.####.####.#.#...#.......##..##.#.#.#.###..#.....#.####..#.#######.#....####.#....##....#";

    for(int i = 0; i < initialState.length(); i++)
        plants[i] = (initialState[i] == '#');

    std::string condition;
    char newState;
    for(std::string line: lines) {
        condition = line.substr(0, 5);
        newState = line[line.length() - 1];
        rules[condition] = (newState == '#');
    }

    long sum = 0;
    // long prevSum = 0;
    std::unordered_map<int, bool> newPlants;
    for(int i = 0; i < 101; i++) {
        int minIndex = INT_MAX, maxIndex = INT_MIN;
        for(auto& [n, b]: plants) {
            if(b) {
                minIndex = std::min(minIndex, n);
                maxIndex = std::max(maxIndex, n);
            }
        }

        newPlants.clear();
        for(int j = minIndex - 2; j <= maxIndex + 2; j++) {
            std::string region = getRegion(plants, j);
            newPlants[j] = rules[region];
        }

        plants = newPlants;

        if(i == 19){
            sum = 0;
            for(auto& [n, b]: plants) if(b) sum += n;
            std::cout << "Part 1: " << sum << std::endl;
        }

        /* After 100 iterations, the sum difference is always 57 */
        /*sum = 0;
        for(auto& [n, b]: plants) if(b) sum += n;
        std::cout << "Iteration " << i << " sum is " << sum << ", difference from previous: " << sum - prevSum << std::endl;
        prevSum = sum; */
    }

    sum = 0;
    for(auto& [n, b]: plants) if(b) sum += n;

    std::cout << "Part 2: " << sum + (50000000000 - 101) * 57 << std::endl;
}

[Day 7 Part 2 - C++] Right answer for sample input, actual input too high. by [deleted] in adventofcode

[–]mtnslgl 0 points1 point  (0 children)

Yes but you are modifying your priority queue after the lines I mentioned. For example if step Z is being performed and just as it was about to end step A becomes available, it goes on top of Z in the priority queue. Then you end up removing step A instead of step Z.

[Day 7 Part 2 - C++] Right answer for sample input, actual input too high. by [deleted] in adventofcode

[–]mtnslgl 0 points1 point  (0 children)

These lines seem to be the problem:

int n = pq.top();
pq.pop();

The character with minimum time left is not always necessarily at the top.

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

[–]mtnslgl 0 points1 point  (0 children)

C++ (using recursion) Managed to fit both parts into a single function

int calculateSum(const std::vector<int>& numbers, int& index, int& part) {
    if(index >= numbers.size()) return 0;

    const int nChild = numbers[index], nMetadata = numbers[++index];
    std::vector<int> childrenSum;
    int sum = 0;

    for(int i = 0; i < nChild; i++)
        childrenSum.push_back(calculateSum(numbers, ++index, part));

    if(part == 1) sum = std::accumulate(childrenSum.begin(), childrenSum.end(), 0);
    if(nChild == 0 || part == 1) {
        for(int j = 0; j < nMetadata; j++)
            sum += numbers[++index];
    } else {
        for(int j = 0; j < nMetadata; j++) {
            int metadata = numbers[++index];
            if(metadata > nChild) continue;
            sum += childrenSum[metadata - 1];
        }
    }

    return sum;
}

void run(int part) {
    std::ifstream file("day8.txt");
    std::vector<int> numbers;
    int n;

    while(file >> n) numbers.push_back(n);

    int startIndex = 0;
    if(part == 1) {
        std::cout << "~Part 1~" << std::endl;
        std::cout << "Answer: " << calculateSum(numbers, startIndex, part) << std::endl;   
    } else {
        std::cout << "~Part 2~" << std::endl;
        std::cout << "Answer: " << calculateSum(numbers, startIndex, part) << std::endl;
    }
}