Skip Navigation

Posts
421
Comments
589
Joined
3 yr. ago

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/ Socials: https://ategon.carrd.co/

  • 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)

  • Thanks for merging in some of my changes <3

    Code block support should be great for posts coming from programming.dev and the active user change should help communities feel a bit more alive and be more accurate to actual activity

  • 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
  • Alright, if you make an account and make a post or comment in the cscareerquestions community then I can mod you

    Usually like to start communities off with two mods so this post will still be open until theres a second response

  • Thats already handled by lemmy ui currently. The same link posts will collapse into the same one

    Just isn't supported by some frontends since its a frontend specific feature (mostly the apps)

    Comments merging isn't supported though but the post mirrors can be toggled between relatively easily

  • Yeah ill be editing it and trying to relaunch it in the new year with a different format

  • 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

  • Small warning, the change to change how lemmy as a whole calculates active users just got pushed so instances may mess up the stats as they upgrade to 0.19 when thats stable (and instances using it rn when they upgrade to a more recent release client) (Makes how programming.dev and lemmynsfw calculate community stats the default)

  • It doesn't, still spams low upvote posts, just slightly tweaked ordering

  • btw if you put the url to nim as /c/nim@programming.dev I dont think the url bot will trigger since it does the same thing the ! format does

     
        
    [Nim](/c/nim@programming.dev)
    
      

    Nim

    Edit: yeah looks like it didnt reply to me so this format works

  • Looks like a camelCase variable to me so its likely just a temporary word they replace with the actual bot name but something went wrong and it didn't replace it properly leading to the temporary text showing instead

    There could be some other reasons but the actual cause cant really be determined without looking at the source code

  • Congrats on the alpha 🎉

  • Advent of code is an coding advent calendar where a new puzzle is released every day for people to solve

    The numbers there (apart from the timer) in the site that was linked can be clicked to bring you to specific puzzles (1 aka Day 1 for the puzzle on the 1st of december, 2 aka Day 2 for the 2nd of december, etc.)

  • Weve got a go community in the site that you might get some answers from rather than the general community here !golang@programming.dev

  • This is more a community for the development side being activitypub instead of fediverse

    Theres communities like !fediverse@lemmy.world though

    I haven't touched friendica much so dont know the answer to that

  • 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

     
        
    // 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 };
    
    
      
  • Uses typescript but can be used for both js and ts, I make bots in Javascript using it

  • [JavaScript] Relatively easy one today

    Paste

     
        
    function part1(input) {
      const split = input.split("\n");
      const times = split[0].match(/\d+/g).map((x) => parseInt(x));
      const distances = split[1].match(/\d+/g).map((x) => parseInt(x));
    
      let sum = 0;
    
      for (let i = 0; i < times.length; i++) {
        const time = times[i];
        const recordDistance = distances[i];
    
        let count = 0;
    
        for (let j = 0; j < time; j++) {
          const timePressed = j;
          const remainingTime = time - j;
    
          const travelledDistance = timePressed * remainingTime;
    
          if (travelledDistance > recordDistance) {
            count++;
          }
        }
    
        if (sum == 0) {
          sum = count;
        } else {
          sum = sum * count;
        }
      }
    
      return sum;
    }
    
      
     
        
    function part2(input) {
      const split = input.split("\n");
      const time = parseInt(split[0].split(":")[1].replace(/\s/g, ""));
      const recordDistance = parseInt(split[1].split(":")[1].replace(/\s/g, ""));
    
      let count = 0;
    
      for (let j = 0; j < time; j++) {
        const timePressed = j;
        const remainingTime = time - j;
    
        const travelledDistance = timePressed * remainingTime;
    
        if (travelledDistance > recordDistance) {
          count++;
        }
      }
    
      return count;
    }
    
      

    Was a bit late with posting the solution thread and solving this since I ended up napping until 2am, if anyone notices theres no solution thread and its after the leaderboard has been filled (can check from the stats page if 100 people are done) feel free to start one up (I just copy paste the text in each of them)

  • Theres a lot of different frameworks to use for creating them

    The most popular one is lemmy-bot which uses js (and has descriptions for how to use it on the page)

    Theres also one in python though here with a couple examples in its repo

  • Game Development @programming.dev

    Easy Releasy by Jannik Boysen gives you one less thing to think about when releasing games on Itch

  • Game Development @programming.dev

    The Best Games from GMTK Game Jam 2023

  • Lemmy Bots and Tools @programming.dev

    Score Bot: A lemmy bot that detects when posts reach an upvote total

    github.com /Ategon/Lemmy-Score-Bot
  • Lemmy Bots and Tools @programming.dev

    List of Active Lemmy Bots + Sources

  • Lemmy Bots and Tools @programming.dev

    The RemindMe Bot! A lemmy bot that reminds you after an amount of time

    github.com /Ategon/Lemmy-RemindMe-Bot
  • Lemmy Bots and Tools @programming.dev

    The Guardian Bot: A lemmy bot that deletes messages containing blacklisted links

    github.com /Ategon/Lemmy-Guardian-Bot
  • Programming Books @programming.dev

    Welcome to the programming books community!

  • Lemmy Bots and Tools @programming.dev

    The lemmy rss feed bot has been updated to handle V0.18

    github.com /Ategon/Lemmy-Mega-Bot/releases/tag/v2.0.0
  • Game Design @programming.dev

    How Games Use Feedback Loops

  • Godot @programming.dev

    Forest River 2 - Godot 3D Concept Scenes

  • Godot @programming.dev

    The godot community forums are closed

  • Game Design @programming.dev

    How Video Game Economies are Designed

  • Godot @programming.dev

    Hitscan Guns, Weapon Switching and Crosshairs - 3D Godot 4 FPS Tutorial

  • Godot @programming.dev

    10 more Indie Games Made in the Godot Engine

  • Godot @programming.dev

    The Summer Fediverse Game Jam has Started!

  • GameDev @lemmy.blahaj.zone

    The Summer Fediverse Game Jam has Started!

  • Game Development @programming.dev

    The Summer Fediverse Game Jam has Started!

  • Game Design @programming.dev

    How To Think Like A Game Designer

  • Formal Methods @programming.dev

    Welcome to /c/formal_methods!

  • Godot @programming.dev

    It Takes Two, lava lamps, Raymarching in Godot 4.1.