Awesome! Joined!
MicroPython sounds interesting, I targeted embedded as well with my first one - but just used C
I’d like to try at least a few in Go and Rust this year
Awesome! Joined!
MicroPython sounds interesting, I targeted embedded as well with my first one - but just used C
I’d like to try at least a few in Go and Rust this year
One hour to the next reveal! I’m going to try to do it fast
I believe in you! Youre crushing our two-person leaderboard
I just completed “Rucksack Reorganization” - Day 3 - Advent of Code 2022 #AdventOfCode
Whew, that was a hard one to wrap my head around. Was happy to finish in ~15 min (~8 for part 1) but not nearly fast enough to get on the leaderboard
Did it this morning! Not nearly that fast and I feel like this time I made substantial changes between part 1 and part 2 which ive been trying to minimize…
Did you see someone was able to get the AI to solve it in 10s?? Crazy world we live in!
Edit: heres a blog post, but i dont think thats the person at the top of the leaderboard who seems to be automating the submissions… Ai solves Advent of Code 2022
Just a few minutes to go for the next one! I’m going to try abandoning all principles of software development and just doing everything directly at the Ruby command line.
That seemed a lot faster but I got tripped up on all the levels of nested brackets and parentheses and wasted a few minutes untangling it. 8:24 was slow enough that almost 2000 people finished before me!
eval(p.sub('-','..')).to_a
Idea for tomorrow: set up guard to run my script and output the value on every change, so I can just hit Ctrl+S to see the result in another window and keep editing.
runme = proc do |_, _, files|
files.each do |f|
p eval(File.read(f))
end
end
guard :yield, run_on_modifications: runme do
watch(%r{\.rb$})
end
By the way, looks like our leaderboard has a new member! Who are you?
If anyone else wants to join, you can still use code 2516370-4dd8a512
. I’ve adjusted the leaderboard to sort by total stars, so there’s no penalty for being slow.
First Rust solution! And this time the there was just a ~10 character diff between part 1 and part 2!
use lazy_static::lazy_static;
use regex::Regex;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
lazy_static! {
static ref RE: Regex = Regex::new(r"([\d]+)-([\d]+),([\d]+)-([\d]+)").unwrap();
}
fn one_contains_other(s: String) -> i32 {
let caps = RE.captures(&s).unwrap();
let val_at = |i| caps.get(i).unwrap().as_str().parse::<i32>().unwrap();
let a_start = val_at(1);
let a_end = val_at(2);
let b_start = val_at(3);
let b_end = val_at(4);
if a_start <= b_start && a_end >= b_start {
1
} else if b_start <= a_start && b_end >= a_start {
1
} else {
0
}
}
fn main() {
let f = File::open("input4.txt").unwrap();
let reader = BufReader::new(f);
let total: i32 = reader
.lines()
.map(Result::unwrap)
.map(one_contains_other)
.sum();
println!("Total: {}", total);
}
guard sounds like a great idea, fast feedback is so good. It looks like there’s a Cargo package that does the same, I’ll have to try it out!
lololol at exec
, but that is actually very creative!
I think exec
might be the programming equivalent of an empty triangle, almost always a terrible idea. Actually I like your idea of splitting into all four parts first but it always ends up being clumsy when I try to do that at the command prompt.
Okay, for the record here are my Ruby one-liners (line breaks added afterward):
File.read('input.txt').split
.map { |l| (l1,l2) = l.split(',').map { |p| eval(p.sub('-','..')) } }
.map { |a, b| (a.to_a - b.to_a == [] || b.to_a - a.to_a == []) ? 1 : 0 }
.sum
File.read('input.txt').split
.map { |l| (l1,l2) = l.split(',').map { |p| eval(p.sub('-','..')) } }
.map { |a, b| (a.to_a & b.to_a != []) ? 1 : 0 }
.sum
And here’s a prettier way to do the comparisons that of course I wouldn’t have come up with on the spot:
File.read('input.txt').split
.map { |l| (l1,l2) = l.split(',').map { |p| eval(p.sub('-','..')).to_set } }
.count { |a, b| a >= b || b >= a }
File.read('input.txt').split
.map { |l| (l1,l2) = l.split(',').map { |p| eval(p.sub('-','..')).to_set } }
.count { |a, b| !a.disjoint?(b) }
Okay, I played around with ChatGPT a bit:
Easy one today. I was 3x slower than the leaderboard.
I tried pasting the problem into ChatGPT later and it generated a fine program with one bug, so I told it about the bug and it fixed it correctly.
I agree! So #4 i tried Go, and it took me hours just wrestling with the syntax. (Not Go’s problem, just a new language for me). Today’s I went back to comfy python and only took a few minutes I did it in interactive mode and didnt even use file io!
I’m having trouble understanding a problem. Does anyone understand what this problem means: #675 $2^{\omega(n)}$ - Project Euler
Specifically:
What does Summation d|n
mean? First time I see d|n
and also a summation sign without lim on top
Usually that’d be sum of the divisors of n
.
So, the sum of all d
such that n=d•x
for some natural number x
. It fits with the example that’s given, since the divisors of 6 are 1, 2, 3 and 6.
oooo tyvm! Yes, exactly! Searching for |
was hard haha
The big-numbered questions (500+) are really ridiculous! Just blatantly use numbers in the 1e20+ as starting point.
These are not problems, they’re just wealth-check!
I tried so hard solving a problem and when I get into the comment section I see people casually solving it with basic 0(n^4) loops.
The comment section is, like, “Ooh I just bought a new $90000 quantum computer but it’s not to my liking, it takes a whole 10 seconds to finish running an infinite loop.”
I’d consider those people failing to solve the question. If it doesn’t take much time because of expensive hardware, you haven’t really written efficient code.
I always thought the problems are designed such that with the right mathematical insight, they are solvable on an average laptop in less than a minute. But perhaps they gave up on that along the way…
I think the 1 minute rule still works, but I haven’t checked the latest problems.
I think there’s a caveat here, because it also depends on the programming language. I use Python because I don’t really know any other language it’s easy, but the excecution has a ton of overhead.
Quite a few times I’ve concocted a solution that takes, I don’t know, 30 minutes, go into the forums expecting a better solution, but all I find is actually the same approach on Java or C++ and it takes 30 seconds or something.
Please my friend, trying doing the same thing in Java****-ingScript The thing can’t even handle number bigger than 1e7!
I had to learn how to make C# console app because it’s the only other language I know.
But on the bright side, C# is great. Got a neat console app framework, and not to mention multi threading:
FP wasn’t that hot while writing JS, but when I switched to C# and get a taste of 10 threads in parallel it’s dangerously addictive.
That’s the gateway drug. Soon, you’ll be harvesting the power of your GPU for fast convolutions
But I still try to keep in the 1 minute rule, by ensuring total time of all threads doesn’t exceed 2 mins.
But just think about waiting only ~15 seconds for an answer that normally take you 1 minute is already a great incentive