Ategon

joined 2 years ago
MODERATOR OF
[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

[JavaScript] Swapped over to javascript from rust since I want to also practice some js. Managed to get part 1 in 4 minutes and got top 400 on the global leaderboard. Second part took a bit longer and took me 13 mins since I messed up by originally trying to append to the card array. (eventually swapped to keeping track of amounts in a separate array)

Part 1

// Part 1
// ======

function part1(input) {
  const lines = input.split("\n");
  let sum = 0;

  for (const line of lines) {
    const content = line.split(":")[1];
    const winningNums = content.split("|")[0].match(/\d+/g);
    const myNums = content.split("|")[1].match(/\d+/g);

    let cardSum = 0;

    for (const num of winningNums) {
      if (myNums.includes(num)) {
        if (cardSum == 0) {
          cardSum = 1;
        } else {
          cardSum = cardSum * 2;
        }
      }
    }

    sum = sum + cardSum;
  }

  return sum;
}

Part 2

// Part 2
// ======

function part2(input) {
  let lines = input.split("\n");
  let amount = Array(lines.length).fill(1);

  for (const [i, line] of lines.entries()) {
    const content = line.split(":")[1];
    const winningNums = content.split("|")[0].match(/\d+/g);
    const myNums = content.split("|")[1].match(/\d+/g);

    let cardSum = 0;

    for (const num of winningNums) {
      if (myNums.includes(num)) {
        cardSum += 1;
      }
    }

    for (let j = 1; j <= cardSum; j++) {
      if (i + j >= lines.length) {
        break;
      }
      amount[i + j] += amount[i];
    }
  }

  return lines.reduce((acc, line, i) => {
    return acc + amount[i];
  }, 0);
}

Code Link

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

yeah that was updated a bit ago to let first requests be free. Looks like for some reason this post didnt federate to p.d until recently though

~~Ill check out the code later in the week~~ Edit: exams are taking too much of my time, maybe after exams

[–] [email protected] 10 points 1 year ago

had some trolls who made an account there and started spamming nsfl content in a bunch of comment sections

[–] [email protected] 20 points 1 year ago

Update: Ada is back and banned them, im refederating

[–] [email protected] 2 points 1 year ago

Ive temporarily defederated programming.dev from blahaj until the spam wave is sorted and deleted all the comments so we shouldnt get any more of them

When the accounts are dealt with im refederating

[–] [email protected] 23 points 1 year ago* (last edited 1 year ago) (1 children)

Im going to temporarily defederate for now until they get the spam bot problem under control but once the admin comes online and gets everything sorted im refererating

[–] [email protected] 2 points 1 year ago

Lemmy doesn't handle certain characters well currently such as left angle brackets and ampersands due to some sanitization in the back end to stop scripting attacks

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

[Rust] Harder one today, for part 1 I ended up getting stuck for a bit since I wasnt taking numbers at the end of lines into account and in part 2 I defined my gears vector in the wrong spot and spent a bit debugging that

Code(lemmy removes some chars, all chars are in code link)

use std::fs;

fn part1(input: String) -> u32 {
    let lines = input.lines().collect::>();
    let mut sum = 0;

    for i in 0..lines.len() {
        let mut num = 0;
        let mut valid = false;
        let chars = lines[i].chars().collect::>();

        for j in 0..chars.len() {
            let character = chars[j];
            let parts = ['*', '#', '+', '$', '/', '%', '=', '-', '&', '@'];

            if character.is_digit(10) {
                num = num * 10 + character.to_digit(10).unwrap();

                if i > 0 {
                    if parts.contains(&lines[i - 1].chars().collect::>()[j]) {
                        valid = true;
                    }

                    if j > 0 {
                        if parts.contains(&lines[i - 1].chars().collect::>()[j - 1]) {
                            valid = true;
                        }
                    }

                    if j < chars.len() - 1 {
                        if parts.contains(&lines[i - 1].chars().collect::>()[j + 1]) {
                            valid = true;
                        }
                    }
                }

                if i < lines.len() - 1 {
                    if parts.contains(&lines[i + 1].chars().collect::>()[j]) {
                        valid = true;
                    }

                    if j > 0 {
                        if parts.contains(&lines[i + 1].chars().collect::>()[j - 1]) {
                            valid = true;
                        }
                    }

                    if j < chars.len() - 1 {
                        if parts.contains(&lines[i + 1].chars().collect::>()[j + 1]) {
                            valid = true;
                        }
                    }
                }

                if j > 0 {
                    if parts.contains(&lines[i].chars().collect::>()[j - 1]) {
                        valid = true;
                    }
                }

                if j < chars.len() - 1 {
                    if parts.contains(&lines[i].chars().collect::>()[j + 1]) {
                        valid = true;
                    }
                }
            }
            else {
                if valid == true {
                    sum += num;
                }

                num = 0;
                valid = false;
            }

            if j == chars.len() - 1 {
                if valid == true {
                    sum += num;
                }

                num = 0;
                valid = false;
            }
        }
    }

    return sum;
}

fn part2(input: String) -> u32 {
    let lines = input.lines().collect::>();
    let mut gears: Vec<(usize, usize, u32)> = Vec::new();
    let mut sum = 0;

    for i in 0..lines.len() {
        let mut num = 0;
        let chars = lines[i].chars().collect::>();
        let mut pos: (usize, usize) = (0, 0);
        let mut valid = false;

        for j in 0..chars.len() {
            let character = chars[j];
            let parts = ['*'];

            if character.is_digit(10) {
                num = num * 10 + character.to_digit(10).unwrap();

                if i > 0 {
                    if parts.contains(&lines[i - 1].chars().collect::>()[j]) {
                        valid = true;
                        pos = (i - 1, j);
                    }

                    if j > 0 {
                        if parts.contains(&lines[i - 1].chars().collect::>()[j - 1]) {
                            valid = true;
                            pos = (i - 1, j - 1);
                        }
                    }

                    if j < chars.len() - 1 {
                        if parts.contains(&lines[i - 1].chars().collect::>()[j + 1]) {
                            valid = true;
                            pos = (i - 1, j + 1);
                        }
                    }
                }

                if i < lines.len() - 1 {
                    if parts.contains(&lines[i + 1].chars().collect::>()[j]) {
                        valid = true;
                        pos = (i + 1, j);
                    }

                    if j > 0 {
                        if parts.contains(&lines[i + 1].chars().collect::>()[j - 1]) {
                            valid = true;
                            pos = (i + 1, j - 1);
                        }
                    }

                    if j < chars.len() - 1 {
                        if parts.contains(&lines[i + 1].chars().collect::>()[j + 1]) {
                            valid = true;
                            pos = (i + 1, j + 1);
                        }
                    }
                }

                if j > 0 {
                    if parts.contains(&lines[i].chars().collect::>()[j - 1]) {
                        valid = true;
                        pos = (i, j - 1);
                    }
                }

                if j < chars.len() - 1 {
                    if parts.contains(&lines[i].chars().collect::>()[j + 1]) {
                        valid = true;
                        pos = (i, j + 1);
                    }
                }
            }
            else {
                if valid == true {
                    let mut current_gear = false;
                    
                    for gear in &gears {
                        if gear.0 == pos.0 && gear.1 == pos.1 {
                            sum += num * gear.2;
                            current_gear = true;
                            break;
                        }
                    }
                    
                    if !current_gear {
                        let tuple_to_push = (pos.0.clone(), pos.1.clone(), num.clone());
                        gears.push((pos.0.clone(), pos.1.clone(), num.clone()));
                    }
                }

                num = 0;
                valid = false;
            }

            if j == chars.len() - 1 {
                if valid == true {
                    let mut current_gear = false;
                    
                    for gear in &gears {
                        if gear.0 == pos.0 && gear.1 == pos.1 {
                            sum += num * gear.2;
                            current_gear = true;
                            break;
                        }
                    }
                    
                    if !current_gear {
                        let tuple_to_push = (pos.0.clone(), pos.1.clone(), num.clone());
                        gears.push((pos.0.clone(), pos.1.clone(), num.clone()));
                    }
                }

                num = 0;
                valid = false;
            }
        }
    }

    return sum;
}

fn main() {
    let input = fs::read_to_string("data/input.txt").unwrap();

    println!("{}", part1(input.clone()));
    println!("{}", part2(input.clone()));
}

Code Link

[–] [email protected] 56 points 1 year ago* (last edited 1 year ago) (3 children)

Zoomed out graph including some months before the join wave

Users/month are relatively stable now at 33x users/month compared to pre join wave (users/month is people who have posted or commented)

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

Rust (Rank 7421/6311) (Time after start 00:32:27/00:35:35)

Extremely easy part 2 today, I would say easier than part 1 but they share the same sort of framework

Code Block(Note lemmy removed some characters, code link shows them all)

use std::fs;

fn part1(input: String) -> i32 {
    const RED: i32 = 12;
    const GREEN: i32 = 13;
    const BLUE: i32 = 14;

    let mut sum = 0;

    for line in input.lines() {
        let [id, content] = line.split(": ").collect::>()[0..2] else { continue };
        let id = id.split(" ").collect::>()[1].parse::().unwrap();

        let marbles = content.split("; ").map(|x| { x.split(", ").collect::>() }).collect::>>();
        let mut valid = true;

        for selection in marbles {
            for marble in selection {
                let marble_split = marble.split(" ").collect::>();
                let marble_amount = marble_split[0].parse::().unwrap();
                let marble_color = marble_split[1];

                if marble_color == "red" && marble_amount > RED {
                    valid = false;
                    break;
                }

                if marble_color == "green" && marble_amount > GREEN {
                    valid = false;
                    break;
                }

                if marble_color == "blue" && marble_amount > BLUE {
                    valid = false;
                    break;
                }
            }
        }

        if !valid {
            continue;
        }

        sum += id;
    }

    return sum;
}

fn part2(input: String) -> i32 {
    let mut sum = 0;

    for line in input.lines() {
        let [id, content] = line.split(": ").collect::>()[0..2] else { continue };
        let id = id.split(" ").collect::>()[1].parse::().unwrap();

        let marbles = content.split("; ").map(|x| { x.split(", ").collect::>() }).collect::>>();
        
        let mut red = 0;
        let mut green = 0;
        let mut blue = 0;

        for selection in marbles {
            for marble in selection {
                let marble_split = marble.split(" ").collect::>();
                let marble_amount = marble_split[0].parse::().unwrap();
                let marble_color = marble_split[1];

                if marble_color == "red" && marble_amount > red {
                    red = marble_amount;
                }

                if marble_color == "green" && marble_amount > green {
                    green = marble_amount;
                }

                if marble_color == "blue" && marble_amount > blue {
                    blue = marble_amount;
                }
            }
        }

        sum += red * green * blue;
    }

    return sum;
}

fn main() {
    let input = fs::read_to_string("data/input.txt").unwrap();

    println!("{}", part1(input.clone()));
    println!("{}", part2(input.clone()));
}

Code Link

[–] [email protected] 2 points 1 year ago

Im not sure how lemm.ee handles it but a lot of instances that aren't lemm.ee dont have uploads disabled

For example this post has an image uploaded to .world

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

I dug through the code and turns out the post read table does store when its read (with number of comments when it was read stored in a person post aggregates table), it just only stores it for people from your instance so I cant get accurate numbers from all of lemmy (and why it seemed like there was a low amount)

 

cross-posted from: https://programming.dev/post/653659

The theme of the game jam voted on by participants is Parallel Worlds

Feel free to share progress of games you're working for it around the fediverse. We have a hashtag on the microblogging platforms #FediverseJam and there are engine specific communities like godot, unity, unreal, etc. that you can find on programming.dev

The jam will last for nine days before submissions to the itch.io page close https://itch.io/jam/summer-fediverse-jam

Ill be streaming games submitted to the jam and will do a video showcasing the entries once results are out

Hope you enjoy! Ill be aiming to run these twice a year as a way to encourage some more game dev activity around the fediverse

 

cross-posted from: https://programming.dev/post/653659

The theme of the game jam voted on by participants is Parallel Worlds

Feel free to share progress of games you're working for it around the fediverse. We have a hashtag on the microblogging platforms #FediverseJam and there are engine specific communities like godot, unity, unreal, etc. that you can find on programming.dev

The jam will last for nine days before submissions to the itch.io page close https://itch.io/jam/summer-fediverse-jam

Ill be streaming games submitted to the jam and will do a video showcasing the entries once results are out

Hope you enjoy! Ill be aiming to run these twice a year as a way to encourage some more game dev activity around the fediverse

31
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 

The theme of the game jam voted on by participants is Parallel Worlds

Feel free to share progress of games you're working for it around the fediverse. We have a hashtag on the microblogging platforms #FediverseJam and there are engine specific communities like godot, unity, unreal, etc. that you can find on programming.dev

The jam will last for nine days before submissions to the itch.io page close https://itch.io/jam/summer-fediverse-jam

Ill be streaming games submitted to the jam and will do a video showcasing the entries once results are out

Hope you enjoy! Ill be aiming to run these twice a year as a way to encourage some more game dev activity around the fediverse

3
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 

The community currently has no mods (as the person who requested it in the request community did not want to mod it).

If anyone wants to be a mod feel free to dm me or reply here

 

Crown Gambit, The Isolated Town, Time Handlers, The Last Root, The Mirror, Rixas, Fair and Square, Out For Delivery, Dreaming Diorama, Planetary Life

 

Hey everyone. The instance has recently updated to 0.18.1 which changed the default shape of icons for users and communities. As circles won the poll before when I polled for what shape people want things to be ill be working on reverting those back to circles as soon as possible. Ill aim to eventually have a setting you can set in your user settings to swap to whatever you want (square, circle, hexagon, etc.)

Will take a bit as im in the middle of the gmtk game jam but just wanted to get a post out just for transparency on why they changed

27
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 

Hey everyone, the content vote ended and here are the results of what people voted for

Reminder that voting was single transferable vote. If two options were tied the one with a worse average placement in all votes was eliminated

(if someone didnt give a second choice then no other options get their vote)

Crosspost community was eliminated first with no first place votes, then main community (second place votes represented in dark blue), then general community (second place votes represented in light blue)

The overall most voted option was Option 2: People catching community. This means that for the community all content relating to the instance is allowed but people will be directed towards more specific communities relevant to their post in the replies. This should then let people be able to post here with no friction and then get filtered down into the proper communities to help make them more active

As there was significantly less votes than the amount of subscribers in the community I will be running a follow up poll in a week to see if people like how the community is being run or if we need to do another poll to change the instance content again.

Linker Bot

Ive been making a bot for the instance called Linker that posts links to communities in the replies when someone posts a non relative instance link. That feature got implemented into lemmy itself in v18 (it will give autocomplete options when you start typing !insertcommunitynamehere on web) so ill be adapting the bot to fit this community to help with the people catching. The bot api is a bit broken right now so it unfortunately wont be able to work for a bit but until then it would be a huge help if you guys do links to mentioned communities in the comments (it only has to be done once so it doesnt spam the replies)

The format im using for bot messages is something similar to

Hey! Here are some possibly relevant communities in the instance based on what was mentioned

- Link to community 1
- etc for any other communities

I am a bot and this message was created automatically

Feel free to adapt that or make your own

Community Request

Just wanted to do a quick advertisement for the community request community here in the instance at [email protected] . The community is always open to suggest communities to be added to the instance and make sure to upvote ideas there you want added to show the interest in them. Since the discussion community option didnt win if you feel the discussion posts are getting buried by the other content you can suggest a new community for that (or for whatever topic the discussion is about if its general enough)

Mods

If anyone is interested in helping mod the community feel free to reach out to me. Ideally want at least one other person to moderate this community so I can stop moderating and focus on some more admin tasks around the instance including developing some new features for it

 

Welcome to the weekly discussion! This is place where you can chat about anything that may not deserve its own post

Hopefully last one I make manually before I get my bots back up

 

Hey everyone! Figured I would do an AMA to kick off some activity in the IAmA community over here. Feel free to throw down some questions below and ill answer them

I'm currently a student in university and have been doing both web development and game development recently (web for internships, game on my own). Out of the four admins ive been the one mainly handling community creation and managing in the instance to make sure everythings running smoothly

Some other misc topics that I can answer about: I compose music & make pixel art, and my favorite games are minecraft, SCP:SL, everhood, battlerite, and metal slug 3

If anyone else wants to do an AMA feel free to start one up in the community (assuming it fits the instance). Any activity helps get the ball rolling for getting it active

47
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 

Hey everyone

Theres been some discussion recently about the content allowed in this community so I wanted to make a quick poll to gauge what is wanted in terms of what people see here

The current description of the community is a bit ambiguous so this will determine whether everything is allowed here or if only more general programming topics are

You can just dm me with options ranked based on your preference (its ranked voting) to vote and ill share the results in a day of the overall vote tallies


1: Allow all posts relevant to the instance (main community)

This will let pretty much any post be able to be posted in here whether that be a help question, discussion, news, etc.

Allowed:

  • What is your favorite music to listen to while programming?
  • Has anyone else seen this interesting “challenge site” when googling a programming topic?
  • Intellij and docker on vm memory issues
  • [HELP][Python] How to use Selenium correctly
  • Announcing TypeScript 5.2 Beta
  • Discussion ES6 Classes. Good or Evil?

Disallowed

  • Things not relevant to the instance

2: Allow any posts and direct people in the comments to more specific communities for their future posts (people catching community)

This will also let any post be able to be posted in here like the previous option but will guide people towards the more specific communities in the future to make them then post the content in those

Allowed:

  • What is your favorite music to listen to while programming?
  • Has anyone else seen this interesting “challenge site” when googling a programming topic?
  • Intellij and docker on vm memory issues
  • [HELP][Python] How to use Selenium correctly
  • Announcing TypeScript 5.2 Beta
  • Discussion ES6 Classes. Good or Evil?

Disallowed

  • Things not relevant to the instance

3: Only allow topics that arent limited to one language, library, etc. (general topic community)

This will let posts such as: what is your favorite music to listen to while coding? or Here is some details about functional programming be able to be posted while something like a library for python will instead be posted in the python community

Allowed:

  • What is your favorite music to listen to while programming?
  • Has anyone else seen this interesting “challenge site” when googling a programming topic?

Disallowed

  • Things not relevant to the instance
  • Intellij and docker on vm memory issues
  • [HELP][Python] How to use Selenium correctly
  • Announcing TypeScript 5.2 Beta
  • Discussion ES6 Classes. Good or Evil?

4: Dont allow questions of how to do X in X language but allow actual discussions or news about the language in addition to general topics (general & discussion community)

Like above but also allows conversations about specific languages in the community as long as its not a question on how to do X in the language

Allowed:

  • What is your favorite music to listen to while programming?
  • Has anyone else seen this interesting “challenge site” when googling a programming topic?
  • Announcing TypeScript 5.2 Beta
  • Discussion ES6 Classes. Good or Evil?

Disallowed

  • Things not relevant to the instance
  • Intellij and docker on vm memory issues
  • [HELP][Python] How to use Selenium correctly

5: Only allow crossposts into the community with things like news being posted in the specific community first (crosspost community)

This will ONLY let crossposts be made. All other options also allow crossposts but this makes it so that the post will fill up the specific community while c/programming is a main post feed for people who want to see many different topics from the specific communities

Allowed

  • anything as long as its crossposted

Disallowed

  • anything not crossposted
  • things not relevant to the instance

You can find some past discussion here https://programming.dev/post/388375 to see some points for the different options

Based on whats voted some other communities may be created or adapted to fit the new niche of people

(ill reply to your dm when your vote is counted, if I havent responded in awhile I may not have gotten it or im asleep)

view more: ‹ prev next ›