Skip Navigation

Posts
421
Comments
594
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/

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

    (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

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

  • 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

    (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

  • 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

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

  • The 118k is half year aka 6 months

    The one around 35k is month

  • Dont have access to those stats in the database so adding on voting is the best I can do

    Theres a post read table but its only people who have explicitly marked something as read and is way less than the post likes

  • For anybody interested, the monthly active users including voters is 131,150 (131k)

    The one in the graph only takes into account people who have made a post or comment

    Edit: The halfyear active users including voters is 253,166 (253k)

  • I changed the algorithms in programming.dev to take into account voters in the activity. Since stats are all calculated locally you can view any community from programming.dev to get the monthly active users including that change

    e.g. https://programming.dev/c/technology@lemmy.world shows 27.8k users/month on p.d which is almost as much as the value here for all of lemmy excluding voters

  • Note you can put this on a separate post and should get some responses from that

    (this is supposed to be for solutions only so people arent browsing it to solve help requests)

  • Yeah tried to golf it a bit so its not very readable

    Seems like the site doesn't track characters though so won't do that for future days

    It basically just loops through every character on a line, if it's a number it sets last to that and if its not a number it checks if theres a substring starting on that point that equals one of the 10 strings that are numbers

  • Started a bit late due to setting up the thread and monitoring the leaderboard to open it up but still got it decently quick for having barely touched rust

    Probably able to get it down shorter so might revisit it

  • [Rust] 11157/6740

     
        
    use std::fs;
    
    const m: [(&str, u32); 10] = [
        ("zero", 0),
        ("one", 1),
        ("two", 2),
        ("three", 3),
        ("four", 4),
        ("five", 5),
        ("six", 6),
        ("seven", 7),
        ("eight", 8),
        ("nine", 9)
    ];
    
    fn main() {
        let s = fs::read_to_string("data/input.txt").unwrap();
    
        let mut u = 0;
    
        for l in s.lines() {
            let mut h = l.chars();
            let mut f = 0;
            let mut a = 0;
    
            for n in 0..l.len() {
                let u = h.next().unwrap();
    
                match u.is_numeric() {
                    true => {
                        let v = u.to_digit(10).unwrap();
                        if f == 0 {
                            f = v;
                        }
                        a = v;
                    },
                    _ => {
                        for (t, v) in m {
                            if l[n..].starts_with(t) {
                                if f == 0 {
                                    f = v;
                                }
                                a = v;
                            }
                        }
                    },
                }
            }
    
            u += f * 10 + a;
        }
    
        println!("Sum: {}", u);
    }
    
      

    Link

  • they start out easy and get harder as time goes on. Theyre intended for all levels due to that and theres two different difficulties per day (the harder one being unlocked when you do the easy one). Basically anyone can do day 1

    Heres stats for how many people completed each day last year https://adventofcode.com/2022/stats

  • Update: Ive make a new leaderboard with code 3316962-6587d422 that has a name that isnt just my username (for some reason AoC only lets the leaderboard be an account name) since theres not many people on it currently and so its easy to find when the events going on

    If you joined the last one rejoin this new one

  • yep, you can do them anytime after theyre unlocked and you dont have to do all of them

  • mostly different forms of edm for the 5 tracks there

    • nichibotsu - edm, chiptune
    • ba-da-ba - electronic, hip-hop
    • re:run - speedrun (drum and bass)
    • bring the madness noisestorm remix - breakbeat, edm
    • apocalypse - edm, chiptune

    the majority of things I listen to are indie game soundtracks

  • Top artist: Toby Fox as is usual every year for me lol (Undertale/Deltarune developer)Top song: Nichibotsu by EX-LYD

    Artists

    1. Toby Fox
    2. 2 Mello
    3. Waterflame
    4. EX-LYD
    5. Danny Baranowsky

    Songs

    1. Nichibotsu by EX-LYD
    2. Ba-Da-Ba by 2 Mello
    3. RE:RUN (Original Soundtrack) by Neo Nomen
    4. Bring the madness - Noisestorm Remix by Pegboard Nerds, Excision, Mayor Apeshit, Noisestorm
    5. Apocalypse by Thomas Happ (Axiom Verge)
  • Each country has their own date they celebrate thanksgiving on. In Canadas case its early october since that lines up with the end of the harvest season and it avoids cold weather that usually arrives end of october/november. Just assumed you asked the question cause most peoples thanksgiving just happened

  • I'm in canada so last week wasn't Thanksgiving for me, it was in October

    But it was pretty good, visited some family in Toronto

  • Unity @programming.dev

    Game Development Communities

  • Game Development @programming.dev

    Game Development Communities

  • Programming Horror @programming.dev

    If only there was a better way

  • Godot @programming.dev

    Do this Before You Publish Your Godot Game

  • Godot @programming.dev

    Godot Sunday Showcase

  • Programming Horror @programming.dev

    Curly bracket chain

  • Game Development @programming.dev

    UK Games Fund nets extra £5 million to offer more support to devs

    www.gamedeveloper.com /business/uk-games-fund-nets-extra-5-million-to-offer-more-support-to-developers
  • Unity @programming.dev

    Feedback Friday

  • Unity @programming.dev

    Summer Fediverse Jam

    itch.io /jam/summer-fediverse-jam
  • Godot @programming.dev

    Summer Fediverse Jam

    itch.io /jam/summer-fediverse-jam
  • Game Development @programming.dev

    Summer Fediverse Jam

    itch.io /jam/summer-fediverse-jam
  • Game Development @programming.dev

    Fediverse Jam Team Finder

  • Unreal Engine @programming.dev

    Unreal Engine Animation Sizzle Reel 2023

  • Programmer Humor @programming.dev

    The horror

  • New Communities @lemmy.world

    A community for posting programming related memes, jokes, etc.

    programming.dev /c/programmer_humor
  • Unreal Engine @programming.dev

    Welcome to the Unreal Engine community!

  • Unity @programming.dev

    Welcome to Unity!

  • No Stupid Questions (Developer Edition) @programming.dev

    Welcome to No Stupid Questions

  • Programmer Humor @programming.dev

    How to detect if a number is even

  • Programming @programming.dev

    English is a Terrible Programming Language

    orbistertius.substack.com /p/english-is-a-terrible-programming