Indie game developer 🇨🇦

Working on some games for game jams in my free time

Admin of programming.dev and frontend developer for sublinks

Account has automation for some scheduled posts

Site: https://ategon.dev/

  • 48 Posts
  • 44 Comments
Joined 3 years ago
cake
Cake day: June 8th, 2023

help-circle
  • im saying the posts and content are fine, just dont swamp every other type of content with it. Give breathing room for other communities and other people in this community to be able to have things surface. You can still post things hence why you havent gotten any moderation action here past getting your flood of posts removed.

    some users can like attribution to reddit a lot of others dont. Not everyone has the same opinion or is the same person



  • 4 posts were still left up from your batch after I cleaned up some to clean the home instance feeds and them the mods trimmed it down more (from 19 within the same small window of time). Just make sure to spread posts out so theyre not all posted in a chunk (and dont use camelcase for titles or have connections to reddit). This post is more than a day after the other ones so would be fine




  • When posting in communities in the instance please follow the automation guidelines (Section 2 and 3 match the most) https://legal.programming.dev/docs/automation-guidelines/

    Notably the section that says 75% of recent content should be human created not automatic and accounts with automation should be marked as such

    It tends to make each individual post do worse as well when theyre spammed like this at once

    edit: Just saying this here for transparency, I removed half of the posts so that theres 9 now instead of 19. Leaving the rest this time but if theres more feed spam I would be reducing that to match the guidelines more instead of leaving a bunch like here (mods of the community can determine whether to handle this batch more but this clears up the general instance feeds)



























  • Alright ive modded you

    Heres my copy paste for the days (every day I switch the day and the title at the top (if I send it before the challenge drops I just do insert name here and then edit it later). When https://adventofcode.com/2023/stats hits 100 for both nums then I unlock the thread and put an edit at the bottom saying its unlocked

    (text here is slightly different since 0.19 dropped now so my warning about that is gone)

    # Day 15: Lens Library
    
    ## Megathread guidelines
    - Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    - You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
    
    ## FAQ
    - What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    - Where do I participate?: https://adventofcode.com/
    - Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    
    ---
    
    🔒 Thread is locked until there's at least 100 2 star entries on the global leaderboard
    

    I also add a link to the new post on the sidebar calendar when I post it

    Title is in the format

    🎄 - 2023 DAY 15 SOLUTIONS -🎄

    The title emojis ive been rotating through 7 different ones based on the day of the week, can see past days for ones ive used or you can do your own thing

    You should get options in the format

    When clicking on the three dots on a post (bar the local pin since thats admins only). Community pin pins it / unpins it and the lock locks / unlocks the thread to prevent people from posting in it

    Will unmod myself from here after I see its going fine

    (If I dont get a reply back by the stats hitting 100 for both puzzles today then ill just post the megathread to catch it for today)



  • For modding in general, baseline is checking and handling reports made by users. In addition to that though there can be looking over posts in the instance to make sure none break the rules (sometimes theres stuff like off topic posts made that arent reported)

    This community specifically in addition to the above has the solution threads that would require to be posted when the new puzzle drops while AoC runs throughout december

    Daily tasks:

    • checking reports once a day or something similar and dealing with them
    • while AoC is running at midnight ET post a solution megathread and lock it. When the two numbers for the day at https://adventofcode.com/2023/stats get above 100 unlock it (done to prevent cheating on the global leaderboard, only the first 100 scores count there). Usually takes at most 30 mins to reach 100, was much shorter in the early days of the month


  • The issue with that and reason why AoC doesnt use that for the leaderboard is they dont have access to the code people write, just the final result

    Adding that as an option would mean having something that takes into account differences in base runtimes of code for different languages (e.g. scripting languages taking longer) so that its feasible to code it in anything, and having the ability to execute many different kinds of code which can be a pain to set up (and would mean youre then running arbitrary code unless you sandbox it)

    I used that as the way to rank people in !challenges@programming.dev when I was running that and its been on hiatus for awhile due to the effort needed to run it since I havent had time due to building up things in the instance such as !pangora@programming.dev

    It could work if self reported but then its easy to cheat





  • JavaScript

    Ended up misreading the instructions due to trying to go fast. Built up a system to compare hand values like its poker before I realized its not poker

    Likely last day im going to be able to write code for due to exams coming up

    Code Link

    Code Block
    // Part 1
    // ======
    
    function part1(input) {
      const lines = input.replaceAll("\r", "").split("\n");
      const hands = lines.map((line) => line.split(" "));
    
      const sortedHands = hands.sort((a, b) => {
        const handA = calculateHandValue(a[0]);
        const handB = calculateHandValue(b[0]);
    
        if (handA > handB) {
          return -1;
        } else if (handA < handB) {
          return 1;
        } else {
          for (let i = 0; i < 5; i++) {
            const handACard = convertToNumber(a[0].split("")[i]);
            const handBCard = convertToNumber(b[0].split("")[i]);
            if (handACard > handBCard) {
              return 1;
            } else if (handACard < handBCard) {
              return -1;
            }
          }
        }
      });
    
      return sortedHands
        .filter((hand) => hand[0] != "")
        .reduce((acc, hand, i) => {
          return acc + hand[1] * (i + 1);
        }, 0);
    }
    
    function convertToNumber(card) {
      switch (card) {
        case "A":
          return 14;
        case "K":
          return 13;
        case "Q":
          return 12;
        case "J":
          return 11;
        case "T":
          return 10;
        default:
          return parseInt(card);
      }
    }
    
    function calculateHandValue(hand) {
      const dict = {};
    
      hand.split("").forEach((card) => {
        if (dict[card]) {
          dict[card] += 1;
        } else {
          dict[card] = 1;
        }
      });
    
      // 5
      if (Object.keys(dict).length === 1) {
        return 1;
      }
    
      // 4
      if (Object.keys(dict).filter((key) => dict[key] === 4).length === 1) {
        return 2;
      }
    
      // 3 + 2
      if (
        Object.keys(dict).filter((key) => dict[key] === 3).length === 1 &&
        Object.keys(dict).filter((key) => dict[key] === 2).length === 1
      ) {
        return 3;
      }
    
      // 3
      if (Object.keys(dict).filter((key) => dict[key] === 3).length === 1) {
        return 4;
      }
    
      // 2 + 2
      if (Object.keys(dict).filter((key) => dict[key] === 2).length === 2) {
        return 5;
      }
    
      // 2
      if (Object.keys(dict).filter((key) => dict[key] === 2).length === 1) {
        return 6;
      }
    
      return 7;
    }
    
    // Part 2
    // ======
    
    function part2(input) {
      const lines = input.replaceAll("\r", "").split("\n");
      const hands = lines.map((line) => line.split(" "));
    
      const sortedHands = hands.sort((a, b) => {
        const handA = calculateHandValuePart2(a[0]);
        const handB = calculateHandValuePart2(b[0]);
    
        if (handA > handB) {
          return -1;
        } else if (handA < handB) {
          return 1;
        } else {
          for (let i = 0; i < 5; i++) {
            const handACard = convertToNumberPart2(a[0].split("")[i]);
            const handBCard = convertToNumberPart2(b[0].split("")[i]);
            if (handACard > handBCard) {
              return 1;
            } else if (handACard < handBCard) {
              return -1;
            }
          }
        }
      });
    
      return sortedHands
        .filter((hand) => hand[0] != "")
        .reduce((acc, hand, i) => {
          console.log(acc, hand, i + 1);
          return acc + hand[1] * (i + 1);
        }, 0);
    }
    
    function convertToNumberPart2(card) {
      switch (card) {
        case "A":
          return 14;
        case "K":
          return 13;
        case "Q":
          return 12;
        case "J":
          return 1;
        case "T":
          return 10;
        default:
          return parseInt(card);
      }
    }
    
    function calculateHandValuePart2(hand) {
      const dict = {};
    
      let jokers = 0;
    
      hand.split("").forEach((card) => {
        if (card === "J") {
          jokers += 1;
          return;
        }
        if (dict[card]) {
          dict[card] += 1;
        } else {
          dict[card] = 1;
        }
      });
    
      // 5
      if (jokers === 5 || Object.keys(dict).length === 1) {
        return 1;
      }
    
      // 4
      if (
        jokers === 4 ||
        (jokers === 3 &&
          Object.keys(dict).filter((key) => dict[key] === 1).length >= 1) ||
        (jokers === 2 &&
          Object.keys(dict).filter((key) => dict[key] === 2).length === 1) ||
        (jokers === 1 &&
          Object.keys(dict).filter((key) => dict[key] === 3).length === 1) ||
        Object.keys(dict).filter((key) => dict[key] === 4).length === 1
      ) {
        return 2;
      }
    
      // 3 + 2
      if (
        (Object.keys(dict).filter((key) => dict[key] === 3).length === 1 &&
          Object.keys(dict).filter((key) => dict[key] === 2).length === 1) ||
        (Object.keys(dict).filter((key) => dict[key] === 2).length === 2 &&
          jokers === 1)
      ) {
        return 3;
      }
    
      // 3
      if (
        Object.keys(dict).filter((key) => dict[key] === 3).length === 1 ||
        (Object.keys(dict).filter((key) => dict[key] === 2).length === 1 &&
          jokers === 1) ||
        (Object.keys(dict).filter((key) => dict[key] === 1).length >= 1 &&
          jokers === 2) ||
        jokers === 3
      ) {
        return 4;
      }
    
      // 2 + 2
      if (
        Object.keys(dict).filter((key) => dict[key] === 2).length === 2 ||
        (Object.keys(dict).filter((key) => dict[key] === 2).length === 1 &&
          jokers === 1)
      ) {
        return 5;
      }
    
      // 2
      if (
        Object.keys(dict).filter((key) => dict[key] === 2).length === 1 ||
        jokers
      ) {
        return 6;
      }
    
      return 7;
    }
    
    export default { part1, part2 };