#development
1 messages · Page 297 of 1
def file = new File('values.txt')
file.text.split(',')*.split('-')
.collect { it*.toInteger() as IntRange }
.collect {
[it, it.findAll { (it as String) =~ /^(.+)\1$/ }]
}
.each { range, vals -> println "For $range.from..$range.to: $vals" }
such a beast deserves way more ram
feed it properly will ya
xD
LOl
im also waiting for nvme prices to chill out again
500€ for 2x4TB before, now its like 620€
not as bad as ram but still
mmm
oh wait, ur supposed to sum the invalid ids
def vals = new File('values.txt').text
def totalWrongIds = vals.split(',')*.split('-')
.collect { it*.toBigInteger() as NumberRange }
.flatten { it.findAll { it =~ /^(.+)\1$/ } }
.sum()
println totalWrongIds
the hell did u input lmao
some quite big numbers
Caught: java.lang.NumberFormatException: For input string: "9393862801"
java.lang.NumberFormatException: For input string: "9393862801"
not supposed to share your inputs
ah yes, integer issues
11-22,95-115,998-1012,1188511880-1188511890,222220-222224, 1698522-1698528,446443-446449,38593856-38593862,565653-565659, 824824821-824824827,2121212118-2121212124
This is the example input
the example input works
it just prints the ids themselves instead of summing them up
in groovy what is *.
runs the following function on every entry
Ah yeah so js map instead of like for each
it's shorthand for map yeah
bro, how
Oh groovy is just a java subset?
superset
Or superset whatever it's called
yea, any java code works on groovy
that's cool
the println wasnt even necessary tbh
aight, did day 1 to just for completion
def input = new File('../inputs/day1.txt').readLines()
int zeros, dial = 50
(input =~ /([LR])(\d+)/).each { _, dir, num ->
def val = num as int
dial = ((dial + (dir == 'R' ? val : -val)) + 100) % 100
if (dial == 0) zeros++
}
println zeros
My exact solution lmaoo
import * as fs from "fs";
type Line = `${"L" | "R"}${number}`;
const inputFile = "input.txt";
const fileContent = fs.readFileSync(inputFile, "utf-8");
const lines = fileContent.trim().split("\n") as Line[];
let dial = 50;
let password = 0;
for (const line of lines) {
const direction = line[0];
const value = parseInt(line.slice(1));
const sign = direction === "L" ? -1 : 1;
dial = (dial + sign * value + 100) % 100;
if (dial === 0) password++;
}
console.log(password);```
Gonna do permissions stuff differently with 4 categories 🙂
@neon leaf how much do you know about CF tunnels
ask the question, i might be able to help
same
I've got it all configured but I keep getting an I/O error.
I'm pretty sure:
- DNS not cause
- ports not blocked
- internet is good and stable
But when I visit the site I get error 1003 and my logs are all just I/o errors about port 7844
If you need any more specific info lmk, no guarantees how fast I'll be to reply thi
you sure can curl it through the server right? then i assume you already configured it on "published application routes" ?
Cloudflare also has a discord if you want to get further help with things there. I'd definitely clarify a lot more though. What type of service are you running, what's the goal, etc. You can provide clarity without sharing sensitive information.
Ice heard discord has been known to "lax API restrictions for larger bots". Does anyone here happen to know what all that entails? My main thought ATM is the 50 req/sec per bot. Don't want to have to worry about that being an issue (way down the road ofc), but gotta know so I can plan better.
like, what are you trying to do here? tunneling local port to be accessible through domain?
google gave me extra access to gemini 3 pro because i have the 2tb google drive plan, time to test their new antigravity code editor
aight, day 3 done too
println input
.collect { it.split('') as List<String> }
*.with {
def head = it.dropRight(1).max()
return head + it.drop(it.indexOf(head) + 1).max() as int
}
.sum()
the one that wiped someone's disk?
lmao
how the hell
How is it so small
oh it's simple, u dont need to compare every number against eachother, simply get the largest number in the row (that's not the last index) then do it again but starting from the previous index + 1
oh my god
im a little dumb
for (const line of lines) {
let arrayOfNumbers = line.split("").map(Number);
let currentLargestJoltage = 0;
for (let i = 0; i < arrayOfNumbers.length; i++) {
const number = arrayOfNumbers.at(i)!;
const mutatedArray = arrayOfNumbers.slice(i + 1);
for (let j = 0; j < mutatedArray.length; j++) {
const compareNumber = mutatedArray.at(j)!;
if (!compareNumber) continue;
const finalNumber = number * 10 + compareNumber;
if (finalNumber > currentLargestJoltage) {
currentLargestJoltage = finalNumber;
}
}
}
joltageSum += currentLargestJoltage;
}```
nah the important part is whether u got the correct answer
How did you do day3 part 2?
When you solve the first one, and put in your answer, it opens up part 2
oh I didn't see it
for (const line of lines) {
let arrayOfNumbers = line.split("").map(Number);
const largest = Math.max(...arrayOfNumbers.slice(0, -1));
joltageSum += (largest * 10 + Math.max(...arrayOfNumbers.slice(arrayOfNumbers.indexOf(largest) + 1)));
}``` i tried that and just get a little bit higher than my correct answer
nevermind i fixed it, for some reason i have to do line.trim()
hm, for the second part I can use the same code I think
just need to add support for nth values
i would love to see what you come up with
i struggled a lot
but eventually got there
although i am confused ```ts
import * as fs from "fs";
type Line = ${number};
const inputFile = "input.txt";
const fileContent = fs.readFileSync(inputFile, "utf-8");
const lines = fileContent.trim().split("\n") as Line[];
let joltageSum = 0;
for (const line of lines) {
let arrayOfNumbers = line.trim().split("").map(Number);
const largest = Math.max(...arrayOfNumbers.slice(0, -1));
joltageSum += (largest * 10 + Math.max(...arrayOfNumbers.slice(arrayOfNumbers.indexOf(largest) + 1)));
}
console.log(joltageSum);
``` returns 16927 if i remove .trim() it returns 16946 and there is no empty space in my input.txt so im confused as to how this happens
Yes, but so that the (my) IP doesn't get publicly shown
If it returns http 404 that’s normal thing for cf tunnelling
have you configured something like this?
Nope
Let me check
Is that zero trust or normal
mine is a bit different to yours
ahhhh i found it
aaaa nevermind it already existed
yeah
int digits = 12
println input
.collect { it.split('') as List<String> }
*.with {
def prio = it.toUnique().toSorted().reversed()
def queue = it
return (0..<digits)*.with {i ->
for (p in prio) {
int v = queue.dropRight(digits - i - 1).indexOf(p)
if (v > -1) {
queue = queue.drop(v + 1)
return p
}
}
throw "Reached end of input" as Throwable
}.join() as long
}
.sum()
basically u make a list of priorities, then scan the digits excluding n - 1 indexes from the tail
for (const line of lines) {
const arrayOfNumbers = line.trim().split("").map(Number)
let currentLargestJoltage = 0;
let maxId = -1;
const poweredBatteries = 12;
for (let i = 0; i < poweredBatteries; i++) {
maxId++;
if (maxId >= arrayOfNumbers.length) break;
let max = arrayOfNumbers.at(maxId)!;
let upperBound = arrayOfNumbers.length - (poweredBatteries - i - 1);
for (let j = maxId + 1; j < upperBound; j++) {
if (arrayOfNumbers.at(j)! > max) {
max = arrayOfNumbers.at(j)!;
maxId = j;
}
}
currentLargestJoltage = currentLargestJoltage * 10 + max;
}
joltageSum += currentLargestJoltage;
}```
and every time u find the value u shorten the head so u always start from the same place
yes
That's a nice approach, are you going to keep doing it every day, your solutions are very nice
probably, cant stop at 4 stars 
good
tyyy
Groovy is so small compared to java
yea, I love that lang ngl
it's very sugary tho, like, nearly everything has a "groovy way"
make a github repo with all your solutions
I did
Ohh i thought I was following you on github but i wasn't
weird that it shows healthy on the dashboard,, do you use host-installed cloudflared or through docker?
you guys doing advent of code? i always forget that it exists lol
catching up now, did day 2 and 3, didnt do day 1 yet
anyways thought id share mine too xD
day 3 part 1:
input.split("\n").reduce((a,t) => {
const first = Math.max(...t.slice(0, -1));
const second = Math.max(...t.slice(t.indexOf(first) + 1));
return a + Number(`${first}${second}`);
}, 0);
day 3 part 2:
input.split("\n").reduce((a,t) => {
const out = [Math.max(...t.slice(0, -11))];
for(let i = 0, n = t.indexOf(out.at(-1)) + 1; i < 11; i++) {
const s = t.slice(n, -(10-i) || undefined);
const d = Math.max(...s);
n = t.indexOf(d, n) + 1;
out.push(d);
}
console.log(t, out)
return a + Number(out.join(""));
}, 0);
first option, note its not currently running tho since i didnt want to flood my pi with errors
twas degraded yesterday
when i try to run it i use:
cloudflared tunnel --protocol http2 run dashboard
if i remove --protocol http2 i get:
error="already connected to this server, trying another address"
if i go back to http2 i get:
2025-12-03T17:27:23Z ERR Unable to establish connection with Cloudflare edge error="DialContext error: dial tcp 198.censor:7844: i/o timeout" connIndex=0 event=0 ip=198.censor 2025-12-03T17:27:23Z ERR Serve tunnel error error="DialContext error: dial tcp 198.4censor:7844: i/o timeout" connIndex=0 event=0 ip=198.censor 2025-12-03T17:27:23Z INF Retrying connection in up to 2s connIndex=0 event=0 ip=198.censor
sometimes i get a mix of both errors
I am glad im not the only one who forgot to just do first * 10 + second and just made a template string wtih them and wrapped it in number
lmao, could do that but we are not really going for performance this time
just whatever gets the job done and its not overcomplicated
my shit for day 2 was absolute garbage that took some solid 10 seconds to run
day 2 part 2:
n = 0;
"4487-9581,755745207-755766099,954895848-955063124,4358832-4497315,15-47,1-12,9198808-9258771,657981-762275,6256098346-6256303872,142-282,13092529-13179528,96201296-96341879,19767340-19916378,2809036-2830862,335850-499986,172437-315144,764434-793133,910543-1082670,2142179-2279203,6649545-6713098,6464587849-6464677024,858399-904491,1328-4021,72798-159206,89777719-90005812,91891792-91938279,314-963,48-130,527903-594370,24240-60212".split(",").forEach(x => {
const [start, end] = x.split("-").map(x => Number(x));
for(let i = start; i < end + 1; i++) {
const str = i.toString();
const z = str.length;
const divisors = [...Array(z + 1).keys()].slice(1).filter(i => z % i === 0);
for(const div of divisors) {
const match = str.match(new RegExp(`.{1,${div}}`, 'g'));
if(match.length > 1 && new Set(match).size === 1) { n += i; break; }
}
}
});
console.log(n)
lmao
i just hardcoded the input
interesting
import * as fs from "fs";
type Line = `${number}-${number}`;
const inputFile = "input.txt";
const fileContent = fs.readFileSync(inputFile, "utf-8");
const lines = fileContent.trim().split(",") as Line[];
let totalWrongIds = 0;
for (const line of lines) {
const [lowerRange, upperRange] = line.split("-").map(Number) as [
number,
number
];
for (let i = 0; i <= upperRange - lowerRange; i++) {
const id = String(lowerRange + i);
const doubled = id + id;
const substring = doubled.slice(1, -1);
if (substring.includes(id)) {
totalWrongIds += parseInt(id);
continue;
}
}
}
console.log(totalWrongIds);```
this was mine
waht why does that look so complicated. doesn’t you only need to put token given when creating connector? basically just cloudflared service install the-token
or you avoid this method?
that’s what happen when cloudflare is unable to reach your server
idk why the connector status is healthy, but you might want to redo installing the connector
well i tried again removing --protocol http and get a mix of i/o timeout, already connected, and about 2 registered connection
alright, so just new connector?
that works too, make sure that you use this one for simplicity
then you will never need to touch your server, you manage everything on the cf's dashboard
yeah im just deleting the old tunnel and starting fresh lmao
damn day 1 part 2 had hands
int zeros, dial = 50
(input =~ /([LR])(\d+)/).each { _, dir, num ->
int val = num as int
if (val > 99) {
zeros += val / 100 as int
val %= 100
}
int rot = dial + val * (dir == 'R' ? 1 : -1)
if (rot < 0) {
rot += 100
if (dial != 0) zeros++
}
dial = (rot + 100) % 100
zeros += dial ? (rot.abs() / 100 as int) : 1
}
println zeros
yeah i just did another loop instead of doing it the mathmatical way
part 2
also, any idea @quartz kindle
which trim causes the change?
bro, day 2 part 2 was so silly lmao
all I had to do is add ONE character
regex is op
let arrayOfNumbers = line.trim().split("").map(Number);
from /^(.+)\1$/ to /^(.+)\1+$/
Yeah i wish I woud have done regex after seeing everyone elses solutions
if you remove that trim your result changes?
the only way that would happen is if somehow your file has spaces in it for some reason
i tested your code in mine and there was no difference with or without trims
hmm
ah yes, if your file has \n\r newlines because windows, then yeah
what's odd is that for part 1 of today it works with or without change, but if I use my part 2 solution but target 2 digits instead of 12, it needs trim
btw this solution is so much better than whatever the fuck i did yesterday lmao
You should make a most performant solution for each one
lmao
they are telling me to run
run as in run the most performant code
for 2 digits, you'd get 2 + 3
for 3 digits, you'd get 2 + 3 + 0
so should I split my input into lines my \r\n
just hardcode the string
well what's also weird is this \r\n issue only appears with certain solutions
icba setting up a code editor for function prototyping lmao

I just don't understand how 1 needs the trim and one doesn't
both ouput the correct answer
try console.loging the number arrays
also use the example so u dont get printed a huge array
in the second one you dont actually traverse the entire line
you just filter and extract high numbers from it
so the zeroes that are appended from the \r doesnt affect anything
but part 2 is the one that needs teh trim?
oh i thought you meant part 1 needs the trim
did you mean part 1
i read that as 1 needs the trim, as in part 1 needs it lmao
because printing the array in part 1, I see what you mean ts [ 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 0 ] [ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 0 ] [ 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 7, 8, 0 ] [ 8, 1, 8, 1, 8, 1, 9, 1, 1, 1, 1, 2, 1, 1, 1 ]
for both parts u can use the same code, as in, your solution for part 2 must work for any n < length
ahh i see now
is there anyway to do it without doing \r\n without having to have an anonymous async function?
so just .split(/\n/g)
Well i want to try and find a global solution that works no matter the input
because i use the same boilerplate day to day
\n should work with regex
Wait but why does the .trim have to be on the line when i already trim the file contents
cuz ur reading the whole file
nvm u said ends with an s
guys where can i generate an api key
you meant like this right, const lines = fileContent.trim().split(/\n/g) as Line[];?
u need ur bot to be approved on topgg first
how do i do that
submit said bot
ok ty
yo im sry to ask but where do i do that 😭
no option to create anything here
yes, u dont need to trim the content if u dont put an empty line in the file
Before you submit your bot to Top.gg, please make sure that your bot follows all of our guidelines found here and read over our process for approval found here.
Make sure that you are logged into...
ty
Bro i dont want a bot i want just the api to scrape list of discord servers
is that allowed?
no
well, even with access to the api you'd not be able to list the servers
since there's no endpoint for that afaik
odd
thank you I never would have thought \r being the issue
yw
Does anyone here know if "Embed Links" is needed for ephemeral responses? My guess is no since it's only a response and less "advertisement"
embed links afaik is only necessary to send embeds
embeds wouldn't be links though
embeds are just messages with style
links direct users to sites
no no, you see, even without that perm u can send links size they're text
when I say "embeds" I mean this block thing
or you mean the link preview embed yeah
without that perm u can send the link, but the embed wont show
gotcha
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
that thing
oop I best check that lmao
might be an issue
o shit u rite
I need to update that lmao
it's confusing af the naming of that perm
should just be embeds tbh
or SEND_EMBEDS
tru
I love how we're supposed to account for the new BYPASS_SLOWMODE but it's not even an option for installing apps
or are they exempt from slowmode?
Note: This primarily affects users, as bots are not affected by slowmode restrictions.
ok nvm
Part 1 was fun
Part 2 made me rewrite part 1 lmao
Lmaooo
I also got the max then the max after the first max for part 1
I've seen that for most people, they wrote one, and then wrote two so it was dynamic
Part 2 I was like 
fn get_max_joltage(battery: &Vec<usize>, n: usize) -> usize {
let mut stack = Vec::with_capacity(n);
let mut possible_removals = battery.len() - n;
for &row in battery {
while possible_removals > 0 && !stack.is_empty() && *stack.last().unwrap() < row {
stack.pop();
possible_removals -= 1;
}
stack.push(row);
}
stack.truncate(n);
stack.iter().fold(0, |value, &elem| value * 10 + elem)
}
ended up with that
Today makes me miss the global leaderboard
you would have seen the people who wrote part 1 dynamic vs those who didn't
and i first read wrong, the word column triggered me
so i read the columns as being the battery
yeah 
Part 1/2?
n=2 for part 1
n=12 for 2
fn part_one(test: bool) -> usize {
let columns = aoc_rs::input::read_file_grid_usize(aoc_rs::input::get_path(3, test));
columns.iter().map(|col| get_max_joltage(col, 2)).sum()
}
fn part_two(test: bool) -> usize {
let columns = aoc_rs::input::read_file_grid_usize(aoc_rs::input::get_path(3, test));
columns.iter().map(|col| get_max_joltage(col, 12)).sum()
}
usually I stay up until midnight to do them but last night I passed out early, and I feel like if I stayed up and saw part 2 I would have just gone to bed
well I used to them in my 1st hour during school but now I have college where only 2 in person classes in the week, both later in the afternoon
Last year I got to the leaderboard a couple of times so like I'll never top that
you would've seen AI bots at the top lol
Yeah that's part of why it was removed but still miss it
🙂 got permissions mapped out
Awesome
this is so cool, what is this, ur own chat app?
Yup
🔥
builder
Oh hi you've been released from shawshank
funny
Does Discord have any built in insights for apps to track growth/engagement? 👀
i am not sure about that
Is there a list of the error codes returned by the API for 4XX errors? For instance 670006 is missing guild feature (specifically gradient, if it's that specific).
Nice, thanks. Kinda odd to copy from the site to a repo but I guess data retention if anything. Assuming discord food isn't official lol
yeah its unoffficial
.food is for user API errors
but its. a big list of every known API error regardless of bot / user
nice
Like everywhere? Or just Discord?
just discord
ah lol gotcha
Today's advent of code was hard lmao
oooo I once coded smth similar to today's puzzle
You shouldn't show the inputs day to day on GitHub
aren't the inputs individually generated?
Yes, but I think he doesn't want people to show them because then they could get reverse engineered or something
Minesweeper is as close as I've done lol
I did
# AoC input files that are not test
/**/input/*
!/**/input/*_test.txt
so i push the test input and use that for the tests in code
repo is currently private either way but yeah
gonna see what day 4 looks like tonight
Day 4 is fun
aight, done
this one ended longer than usual
def input = getClass().getResource('/day4.txt').readLines()
boolean COUNT_ONLY = false
def mat = input.flatten { it.split('') as List<String> } as List<String>
int cols = input.first.length()
int rows = input.size()
int total = 0
boolean loop = true
while (loop) {
loop = false
for (i in mat.indices) {
if (mat[i] == '@') {
def (x, y) = [i % cols, i / cols as int]
int count = (Math.max(0, y - 1)..Math.min(y + 1, rows - 1)).collect {
int col = cols * it
return mat.subList(
col + Math.max(0, x - 1),
col + Math.min(x + 2, rows)
).count { it == '@' }
}.sum() as int
if (count <= 4) {
total++
if (!COUNT_ONLY) {
mat[i] = '.'
loop = true
}
}
}
}
}
println total
lol the second one was just a tiny change in the code
part 1:
n = 0;
cells = document.body.innerText.split("\n").map(x => x.split(""));
grid = [cells.length, Math.max(...cells.map(x => x.length))];
for(let y = 0; y < grid[0]; y++) {
for(let x = 0; x < grid[1]; x++) {
const current = cells[y][x];
const adjacent = [cells[y-1]?.[x-1],cells[y-1]?.[x],cells[y-1]?.[x+1],cells[y]?.[x-1],cells[y]?.[x+1],cells[y+1]?.[x-1],cells[y+1]?.[x],cells[y+1]?.[x+1]];
if(current === "@" && adjacent.filter(x => x === "@").length < 4) {
n++;
}
}
}
console.log(n)
part 2:
n = 0;
cells = document.body.innerText.split("\n").map(x => x.split(""));
grid = [cells.length, Math.max(...cells.map(x => x.length))];
while(true) {
const prev = n;
for(let y = 0; y < grid[0]; y++) {
for(let x = 0; x < grid[1]; x++) {
const current = cells[y][x];
const adjacent = [cells[y-1]?.[x-1],cells[y-1]?.[x],cells[y-1]?.[x+1],cells[y]?.[x-1],cells[y]?.[x+1],cells[y+1]?.[x-1],cells[y+1]?.[x],cells[y+1]?.[x+1]];
if(current === "@" && adjacent.filter(x => x === "@").length < 4) {
n++;
cells[y][x] = ".";
}
}
}
if(n === prev) { break; }
}
console.log(n)
I was stumped on the second one for sometime, and then I realized I just need to change my function to return a count, and put it all in a while loop
The grid length doesn't change
things would be totally different if we went for performance, but since we dont care about performance, we just brute force xd
you don't need to find the maximum
ye i figured but i still left it there
I don't know what the most performant solution would look like
I saw some people talking about it, but didn't see anyone post there's that was
you need to do what you can to keep it in a single loop, for example on each find only backtrack enough to check the cells that could be affected by the swap and then proceed from where you left off
there are also tricks to improve adjacent checking so you dont need to check all 8 cells
how so?
Also I screwed myself over for so long, I used .at instead of [index] and that caused it to grab the very last row on the first one because .at handles negatives and it took me way too long to realize and fix it
Pfft I didn't know that
I used .at because function syntax is nicer imo and I assumed it had some performance things under the hood
general rule in js is new things are always more convenient but slower than old things
that's not fun
then with time they improve the new things so that they are only 1% slower instead of 200% slower
i dont think there is a single new thing in js that was introduced to make something faster
The only way is not checking ones they don't exist like not checking above if there isn't and such
well for one you can check only until you are sure something can or cannot be
if out of 8 fields, the first 4 alreadt have a roll, you can skip the rest
if out of 8 fields, 5 are empty, you can skip the last 3
otherwise you can also try a minesweeper style of marking the number of adjacents on each cell so you dont need to check certain neighbours again
these are all more complex to do, but performance-wise they would be quite effective
I saw lots of people using queues today
when I read today's the first thing that came to mind was finding my neighbors function from minesweeper I made like 2 years ago
I also originally dynamically made the adjacent cells array
generally, advanced algorithms all look for doing as much as they can in a single pass and avoid multiple passes as much as possible, so it involves a lot of going back and forth with indexes and stuff, remembering positions/pointers, resuming where it left of, etc...
this goes back to the old ways of seeking HDDs, it would be much faster to work with nearby data than to go back to the beginning and scan the entire thing again
I wish I found an efficient algorithm for today
I just check every character, check the 8 adjacent, and then move on to the next character
yeah thats what i did too
its the fastest way to prototype a working function / solve the problem
I prefer to handle 1d arrays when working with grids
well I mean it's the only way I could really think to do it, only micro optimization I know how to do would be to only check possible cells so don't check above if it isn't there
Interesting
I wish I could optimize my day 2
It takes like 1.5s
I used the scan method
Scan method?
as in, do a pass -> if anything is removed -> repeat
so I do a full scan to remove any valid slots, and if anything is removed, I scan again to check if any can be removed now
the loop only ends when no slots are removed
this also lets me use the same func for both parts, since it wont loop again
btw done removing the inputs from git history
Chat what I'm supposed to do here? I just want my bot to have working cmds and a command button type thing on the profile, My bot have like 9 working slash cmds
mine takes abt 1.25s and 37 full scans
ran the entire task 10 times beforehand to let jit do its thing
you upload the entire slash cmd json (the one u sent to discord to register them)
mine did 46 passes in 85ms
wtf
Wait I coded the bot in python and I just like defined the cmds and all in the py file and it works as perfectly, does it count as registered and Im supposed to paste that in box right?
I didn't time the init part, only the looping
but well, u also hardcoded the cell accesses, that's prolly faster than extracting views
there's probably a way to extract the commands json in d.py
Oh alright
nvm strings are not mutable
just realized, I might be able to reduce the amount of scans by jumping to the first subview index, instead of index 0
I kept having this issue
That's why I have this mess
I need to create a timing system for each of these
Did this but it still don't show up on my bot profile let alone clickable buttons
it wont show in ur bot profile cuz topgg isn't discord
slash commands show in your bot profile when they're used frequently
How this bot got it then? I just want it to be like this
Ohh
Makes sense
@lyric mountain@queen needle
from ~85ms to ~15ms (can still be further improved)
function THEJOB(input) {
let n = 0;
const grid = input.split("\n").map(x => x.split(""));
const size = [grid.length, grid[0].length];
const marks = [];
for(let y = 0; y < size[0]; y++) {
for(let x = 0; x < size[1]; x++) {
CHECK(y, x);
}
}
while(marks.length) {
const m = [...marks];
marks.length = 0;
for(const mark of m) {
for(let i = 0; i < 9; i++) {
const ny = mark[0] - 1 + Math.floor(i / 3);
const nx = mark[1] - 1 + (i % 3);
CHECK(ny, nx);
}
}
}
function CHECK(y, x) {
const current = grid[y]?.[x];
if(!current) { return; }
const adjacent = [
grid[y-1]?.[x-1], grid[y-1]?.[x], grid[y-1]?.[x+1],
grid[y]?.[x-1], grid[y]?.[x+1],
grid[y+1]?.[x-1], grid[y+1]?.[x], grid[y+1]?.[x+1]
];
const l = adjacent.filter(x => x === "@").length;
if(current === "@" && l < 4) {
n++;
grid[y][x] = ".";
marks.push([y,x]);
}
}
return n;
}
one full scan, remember all the changes, then followup scans only check adjacents of changed cells
yeah this sped up a lot on my code too
now it's 1.12s
oh wait, I forgot to skip the full scan
nvm, didn't matter
why everyone still using old components for embeds?
@queen needle@lyric mountain down to 4ms
function THEJOB(input) {
let n = 0;
const grid = input.split("\n").map(x => x.split(""));
const size = [grid.length, grid[0].length];
let marks = [];
for(let y = 0; y < size[0]; y++) {
for(let x = 0; x < size[1]; x++) {
CHECK(y, x);
}
}
while(marks.length) {
const length = marks.length;
for(let m = 0; m < length; m++) {
const mark = marks[m];
const y = mark >> 8;
const x = mark & 255;
CHECK(y-1, x-1);
CHECK(y-1, x);
CHECK(y-1, x+1);
CHECK(y, x-1);
CHECK(y, x+1);
CHECK(y+1, x-1);
CHECK(y+1, x);
CHECK(y+1, x+1);
}
marks = marks.slice(length);
}
function CHECK(y, x) {
const gy = grid[y];
if(gy) {
const gx = gy[x];
if(gx === "@") {
let brazil = 0;
const gyminus = grid[y-1];
const gyplus = grid[y+1];
if(gy[x-1] === "@") {brazil++}
if(gy[x+1] === "@") {brazil++}
if(gyminus) {
if(gyminus[x-1] === "@") {brazil++}
if(gyminus[x] === "@") {brazil++}
if(gyminus[x+1] === "@") {brazil++}
}
if(gyplus) {
if(gyplus[x-1] === "@") {brazil++}
if(gyplus[x] === "@") {brazil++}
if(gyplus[x+1] === "@") {brazil++}
}
if(brazil < 4) {
n++;
gy[x] = ".";
marks.push((y << 8) + x);
}
}
}
}
return n;
}
I genuinely do not understand my code or the algorithm you two describe enough to speed my solution up
ah cmon
Bro literally wtf
caching variables as much as possible, avoiding short loops, avoiding dead/unneeded code, avoiding unnecessary array allocations
brazil++ is peak
when you remove an index, save the nearby indexes to a list
next time u iterate, run over these instead
u wanna help with that?
bonus, store y x coordinates as bitfield xD
feel free to further improve it
I thought I already do that
dont see u doing that
check dm @quartz kindle
@quartz kindle:
VM67:170 Result: 9446 @ removed
VM67:171 Time: 4.10 ms
VM67:172 Speed: 9756.1 cells/ms
VM67:175
v2:
VM67:180 Result: 9446 @ removed
VM67:181 Time: 3.00 ms
VM67:182 Speed: 13333.3 cells/ms
show code?
AI can't compare to Tim
lol
-# yet™
im asking chatgpt to improve mine and see how it does
im using deepseek
so far it produced 1 wrong code, and 1 slower code
30ms faster than u now
lmao
let me see opus
show then
I Wanna see
i think opus can do better
I don't see many improvements left in his code of any at all
rewrite it in rust ofc
xD
oh true true
XD
rust in the browser console
so far every solution chatgpt gave me was slower or equivalent to mine
but tbh this is too small of a job to get meaningful results
you would need a much larger input to get a better assessment
make your own input
input * (input.length ** input.length)
input.repeat(100)
lmao
you wanna end the universe or what
xD
time complexity from hell
chances are 12 for loops are faster than 90% of other methods out there
ultra = opus
is the code actually being tested or is AI just giving you those numbers?
because AI doesnt actually run the code
it just gives you random benchmark results
And is it giving the right answer still
cool, can you show the code? wanna test here too
he skip u
lmao
send it in a https://sourceb.in
with test everything i just copy that
nice
deepseek make that sorry
opus make slower than u
Don't generate a grid, use the grid from aoc
bro got beat by char code
idc for real i just put into deepseek to see
just go into deepseek and test it too
sometimes is good
..@@.@@@@.
@@@.@.@.@@
@@@@@.@.@@
@.@@@@..@.
@@.@@@@.@@
.@@@@@@@.@
.@.@.@.@@@
@.@@@.@@@@
.@@@@@@@@.
@.@.@@@.@.```
Test the fastest solution with this input
a lot of the changes are not actually meaningful, what actually matters is that it flattened the 2d array into a single continuous block and then used multiplication to simulate rows and colummns
let me test it
for example instead of
abc
xyz
123
it stored as
abcxyz123
and then it gets rows and columns like this
cell = block[rowindex * rowsize + colindex]
That's an interesting approach
well you gotta keep opTIMizing, can't get beat by AI
tim 0.10 deepseek 0.100
thats the same value
yeah
?????

ok 1sec
VM40:198
:mag: TESTING ORIGINAL VERSION...
VM40:203 Result: 43 @ removed
VM40:204 Time: 0.10 ms
VM40:205 Speed: 1000.0 cells/ms
VM40:208
:zap: TESTING ULTRA FAST VERSION...
VM40:213 Result: 43 @ removed
VM40:214 Time: 0.100 ms
VM40:215 Speed: 1000.0 cells/ms
VM40:218
:bar_chart: PERFORMANCE COMPARISON:
VM40:219 Results match: :white_check_mark: YES
VM40:220 Speedup: 1.0x faster
VM40:221 Time saved: 0.00 ms
VM40:224
:chart_with_upwards_trend: GRID ANALYSIS:
VM40:233 Size: 10×10 = 100 cells
VM40:234 @ symbols: 71 (71%)
VM40:235 . symbols: 29 (29%)
VM40:238
:dart: GRID AFTER FIRST REMOVAL WAVE:
VM40:273
After first removal wave (only @ with <4 neighbors):
VM40:274 .......@..
.@@.@.@.@@
@@@@@...@@
@.@@@@..@.
.@.@@@@.@.
.@@@@@@@.@
.@.@.@.@@@
..@@@.@@@@
.@@@@@@@@.
....@@@...
VM40:277
:abacus: SUMMARY:
VM40:279 Initial @ count: 71
VM40:280 Total removed @: 43
VM40:281 Remaining @: 28
VM40:282 @ after first wave: 58
VM40:283 Additional removed in propagation: 30
VM40:285
==================================================
VM40:286 :checkered_flag: TEST COMPLETE```
Speed: 1000.0 cells/ms
and yes
Not only that but AI can also hallucinate and make up any random shit you give it even things like benchmarks or "performance" improvements
any feedback?
Do you really need to add "secure oauth 2.0" xD like what does 2.0 mean?
yeah it often halucinates about what improves performance and what doesnt. for example it will say "this change massively improves performance" and it actually makes it worse.
AI is good at finding good algorithms, but not as good at microoptimizing
cuz the standard is oauth2 ig
Regular users don't need to know about what oauth2 is though
Why have a pill button in a slightly rounded container, and why does the button have a slight border but transparent background? It makes the button look odd
version from my pc...
i making few login page
and pushing it into community

Are you making it or is AI 🤔🤔🤔
front opus
pancake and tim why u are mad on ai?
tell me
u dont like it?
helps alot btw
changed @prime cliff all happy rn
I would just get rid of the text tbh
^
yea?
The standard for login seperator components is to provide Oauth methods after you already have a login/sign up screen
If it's just one login method you do not really need a seperator
Only you and other developers will know what "oauth" is and at that point they already know what oauth is unless you're building a developer oriented app
and why separate the button and the text about the button?
The seperator and text is better imo design wise
That's fair, I mean it kind of works in this scenario but also the button being so large but providing so little, being a pill with a transparent background, and the text being so far away, it all just creates empty space and some noise when it isn't needed
okay @queen needle
u wanna give me feedback about 1 more thing?
or o @prime cliff what u think about that?
I mean I can but my feedback is very biased @prime cliff is a very good developer who would be more help
I'm not that good ;-;
Better than me at least
i dont like Instant Server Setup but idk
go ahead 😄
go ahead pancake u are good ❤️
I'll have to wait until after class the video is too small on mobile
Nice but is it mobile compatible :p
ofc
Imagine
everything is compatible with mobile version...
huh???????
I don't think you're supposed to say stuff like that in here (idk the rules) but you can always dm me
aight @queen needle @quartz kindle I'm back
managed to reduce it to 5ms :v
but the code got big af cuz I went raw java
Bro went raw
so what I'm hearing is when I get home I'm going to have to add timing to mine and do a bunch of optimization s
anyway imma just send it to git
Literally what the fuck
I still don't understand how
I have some ideas to improve part 1
But that's it
it applied as much optimization as I knew on it
oh actually
the time in the prints might actually be wrong
cuz I'm reading the file inside the task
I literally know like one thing I can optimize on mine that's it
I'm going to include file reading into the time for mine
The only optimization I know I can do is handle the checks normally and don't use an array and loop through it
things u can do to shave processing time off it
- use the lowest array type you have (faster creation)
- save changed indexes to a secondary array, iterate over it from the second pass onwards
- use bitwise whenever possible
also try to stay low on array accesses
if u need to use the access index more than once make a var for it
I'll work on implementing those when I get home
today's part 2 is what i feared
part one was fun as always
fn part_one(test: bool) -> usize {
let adj = aoc_rs::parsing::get_adjacent_8_grid_char(aoc_rs::input::read_file_grid_char(
aoc_rs::input::get_path(4, test),
));
adj.get(&'@')
.unwrap_or(&Vec::new())
.iter()
.filter(|neighbors| neighbors.iter().filter(|v| **v == Some('@')).count() < 4)
.count()
}
gonna work on part 2
part one i got 5ms
okay got 2ms
2ms for part 1
maybe if I used in-memory changes or partitioned the input
part2 im stuck at 16ms
oh
can't break 16ms 🙁
link still the same right?
both parts
bruh
rust my beloved
aint that 20ms?
it is
use direct array accesses instead of loop
u can prolly go even lower
unless ur doing it just for the answer
i just do it for the answer honestly
but it's quite fast so yeah
and if i do it a second time it gets quite stable to 5ms likely because of some optimizations of the OS
best I could get was 2ms (for part 2)
i couldn't pass 11ms
I'm trying to find one from a previous year where i had a stupidly fast one
u can try profilling it, if js has smth like that
to find out what's taking too long
hyperfine is nice btw
written in rust ofc its nice
ive gotten sick of rust recently so im going to try go instead
but cold starting the bins every time doesnt sound very effective
go is nice because it teaches you principles that you must use in rust
wait, this doesnt make sense lul (time is big cuz it's also counting the 1000 warmup runs)
why tf is the first taking 10x as long
if thats js its probably because it does a lot of hidden optimizations under the hood like hidden caches and precomputations to make future access/operations faster
it's java
lmao
maybe jit is warming up idk
perhaps, dont think I can profile only the last run tho
oh wait, I can just not warmup
or it could just be the profiler thats doing something thats making it take so long
what jdk are u using? 25 has some improvements regarding warmup time
ngl day 4 was easier than the other days lol
been using python for this, relatively convenient
I figure I should get better at doing it for interviews anyways
25
I'm trying to see if it's possible to reduce to 1ms
ty github
gh actions usage?
indeed
atleast they run decently fast
unlike my windows builds that take 15min+ with cached deps
normal windows behavior
ok, not possible, 2ms is the rock bottom
i still gotta start day 4
i took a peak earlier today and it seems pretty easy
one of the previous aoc's had something similar
wsp @covert gale
hello
Yeah honestly it was easier than days 1, 2, and 3
Another stupid easy day
const ranges = new Set(`3-5
10-14
16-20
12-18`.split("\n").map(x => x.split("-")).map(x => ({lower: Number(x[0]), upper: Number(x[1]) + 1})).map(x => Array.from({length: x.upper - x.lower}, (_, i) => i + x.lower)).flat()).size;
ranges;```
doesn't work on real input due to array sizes
the solution i actually used is a lot better
I'll be interested to see the optimizations done
cloudflare is down AGAIN lmao
shopify, downdetector and LinkedIn bye bye
atp they're just playing an early April fools joke
The fact that downdetector is down is very ironic 
works for me, tho it has been 10min so idk
yeah, not down just latency spike
on some region
*at least the sites on cf not down
it did cause a temporary outage of many sites
so basically an outage
(source: all my work related sites went down and the countless news articles)
oh, today's the first day where I cant use the same code for both parts
cuz part 2 is completely backwards to part 1
A change made to how Cloudflare's Web Application Firewall parses requests caused Cloudflare's network to be unavailable for several minutes this morning. This was not an attack; the change was deployed by our team to help mitigate the industry-wide vulnerability disclosed this week in React Server Components. We will share more information as we have it today.
typical react moment
u saw this guys?
oh, so must be some only on specific datacenter(?) im in asia
yeah #development message
they keep mentioning this was not an attack on every incident but ironically that's worse 😭
atp for my nextjs project I haven't touched for a year I get at least one CVE alert from github every month so doesn't surprise me
haha yea
Oh I didn't know that, that's cool
yeah but atleast part 2 isn't too much of a change
i could reuse like 70% of the code
Ngl I'm finding this one harder than the past 4
how??!
idk, never had to face smth similar
part 1 or part 2?
I think it’s harder than the past 4 for sure
I mean you could always do this horrible good way
generate an entire array for all the ranges, remove duplicates, get the length
It’s too slow for how large the ranges are
There is an O(n) solution for merging the ranges instead of needing to iterate over every single number within the ranges
O(n) would mean for n ranges you're iterating n times
if you're expanding the ranges then it's much larger than that
would it be O(n^3) if i go over the number-number once to turn it into {upper:..., lower:...} and then go through it again to merge, and then the last time to add to the fresh ingredients?
no idea how to do big-O when the expanded inputs vary in magnitude
Yeah this wouldn’t be an easy comparison
I assume my way can be optimized I just don't know how
Expanding the ranges is incredibly slow in comparison to merging them
That’s the “correct” O(n) solution for merging the ranges
If you were doing the naive way of throwing every number in a range into a set then it would be infinitely slower
oh no no
i did that as a joke because I got bored
that solution still takes about a second though
the advantage of having read the input first for part 1 made me solve part 2 within seconds 
made the merging directly
If you make the merging directly could you still do part 1 with the merges?
yeah
items
.into_iter()
.filter(|&i| {
let x = i as isize;
merged_ranges.iter().any(|&(l, r)| x >= l && x <= r)
})
.count()
part 2
merged_ranges
.iter()
.map(|&(l, r)| (r - l + 1) as usize)
.sum()
dang
my merging is likely not the cleanest
fn read_and_merge_ranges(test: bool) -> (Vec<(isize, isize)>, Vec<usize>) {
let sections = aoc_rs::input::read_file_in_sections(aoc_rs::input::get_path(5, test), "\n\n");
let mut ranges = aoc_rs::regex::ranges(§ions[0]);
ranges.sort();
let items = sections[1]
.lines()
.map(|line| line.parse().unwrap())
.collect();
let mut merged = Vec::with_capacity(ranges.len());
for (l, r) in ranges {
if let Some((_, last_r)) = merged.last_mut() {
if l <= *last_r {
*last_r = (*last_r).max(r);
continue;
}
}
merged.push((l, r));
}
(merged, items)
}
made the capacity of the merged vec the len of the ranges, as it can't go higher
i took my first range, saw it was like 5 trillion of diff
so i was like, yeah ain't making a vec of those items 🤣
would've done the lazy technique otherwise
add all items and slap a .contains
lmaoo
always reminds me of the rocks/fish problem of previous years
which problem?
let me find them again
https://adventofcode.com/2021/day/6 - the fish one
https://adventofcode.com/2024/day/11 - the rock one
let { readFileSync } = require("node:fs"), { EOL } = require("node:os"), ageCounts = Array(9).fill(0);
const fishies = readFileSync("../input.txt", "utf-8").split(",").map(Number);
for (let fish of fishies) {
ageCounts[fish]++;
}
for (let i = 0; i < 80; i++) {
ageCounts[(i + 7) % 9] += ageCounts[i % 9]
}
console.log(ageCounts.reduce((a, b) => a + b));```
AoC in 2021 😭 unc status achieved
my beautiful solution for 2021 day 6
fishies
i did 2021 & 2022 in go
2023 skipped because military
2024 & 2025 rust because learning it
and pre-2021 in python
I did some of 2024 in rust (or maybe it was 23, can’t remember)
iirc 19&20

last year i tried to do as many languages as i could
for python i tried to also do a oneline version everyday
I’ve been putting off python practice for years
It’s lowkey been biting me in the ass for interviews though, figured I might as well practice LC-style questions with it
I use Java in my interviews but I’m realizing how much time I’m wasting
lmao
literally no clue how to do day11 of 2024 wtf
the general problem just looks like ```
stones = []
loop(25){
stones = blink(stones)
}
stones.length
yes
yeah
pub fn execute(test: bool) {
println!("{}", blink(25, test));
println!("{}", blink(75, test));
}

because i decided to do some stupid linked list shenanigans instead of doing something remotely normal
but oh well, it takes 0.4ms to run /shrug
could you help me understand the rules of "blinking"?
If the stone is engraved with a number that has an even number of digits, it is replaced by two stones. The left half of the digits are engraved on the new left stone, and the right half of the digits are engraved on the new right stone. (The new numbers don't keep extra leading zeroes: 1000 would become stones 10 and 0.)```
I don't get what it means by 1000 becoming 10 and 0, and then also in the example it shows 99 becoming two 9's? but that isn't in any of the rules
how tf
send your solution rn
If it's even, split - so
1000 becomes 10 00
99 becomes 9 9
33 becomes 3 3
yeah but, 99 isn't even?
The "is even" is for the number of digits in the number
oh
part 1:
function UGANDA(input) {
const breakpoint = input.indexOf("\n\n");
const ranges = input.slice(0, breakpoint).split("\n").map(x => x.split("-"));
const values = input.slice(breakpoint + 2).split("\n");
let n = 0;
for(const val of values) {
const num = Number(val);
if(ranges.find(x => num > Number(x[0]) && num < Number(x[1]))) {
n++;
}
}
return n;
}
part 2:
function UGANDA2(input) {
const breakpoint = input.indexOf("\n\n");
const ranges = input.slice(0, breakpoint).split("\n").map(x => x.split("-").map(Number));
const list = { start: ranges[0][0], end: ranges[0][1], prev: null, next: null };
let first = list;
for(let i = 1; i < ranges.length; i++) {
const [start, end] = ranges[i];
let current = list;
if(start < current.start) {
while(current.prev && current.prev.start > start) {
current = current.prev;
}
const node = { start, end, prev: current.prev, next: current };
if(current.prev) {
current.prev.next = node;
}
current.prev = node;
if(!node.prev) {
first = node;
}
} else {
while(current.next && current.next.start < start) {
current = current.next;
}
const node = { start, end, prev: current, next: current.next };
if(current.next) {
current.next.prev = node;
}
current.next = node;
}
}
let n = 0;
let start = first.start;
let end = first.end;
while(first.next) {
first = first.next;
if(first.start > end) {
n += end - start + 1;
start = first.start;
end = first.end;
} else if(first.end > end) {
end = first.end;
}
}
return n + (end-start+1);
}
If the stone is engraved with a number that has an even number of digits, it is replaced by two stones. [...]
okay i might be bad at reading lmao
iirc i got super confused for that day while reading it at the beginning
sometimes i just read half the words lmao
i understand so little of this
the general idea is sort using a linked list and then traverse the sorted list
bro got matrixed by linked lists
initially i wanted to run the mergining while sorting, but it got too complex and i gave up
this is basically just a glorified version of sorting an array lol
i have no idea why the fuck i decided to do it this way
im a fucking idiot
i mean hats off to you, i've seen no one else do it that way
this works just as well, if not better:
function UGANDA2(input) {
const breakpoint = input.indexOf("\n\n");
const ranges = input.slice(0, breakpoint).split("\n").map(x => x.split("-").map(Number));
const sorted = ranges.toSorted((a,b) => a[0] - b[0]);
let n = 0;
let start = sorted[0][0];
let end = sorted[0][1];
for(let i = 1; i < sorted.length; i++) {
const [s,e] = sorted[i];
if(s > end) {
n += end - start + 1;
start = s;
end = e;
} else if(e > end) {
end = e;
}
}
return n + (end-start+1);
}
fml
spent 3 hours for nothing
is the time the same?
how tf
import * as fs from "fs";
const inputFile = "input.txt";
const fileContent = fs.readFileSync(inputFile, "utf-8");
let stones = fileContent.split(" ").map(Number);
function blink(arr: number[]): number[] {
const out: number[] = [];
for (const stone of arr) {
if (stone === 0) {
out.push(1);
continue;
}
const digits = Math.floor(Math.log10(stone)) + 1;
if (digits % 2 === 0) {
const half = digits / 2;
const div = 10 ** half;
const left = Math.floor(stone / div);
const right = stone % div;
out.push(left, right);
} else {
out.push(stone * 2024);
}
}
return out;
}
for (let i = 0; i < 25; i++) {
stones = blink(stones);
}
console.log(stones.length);
2024 day 11 part 1 solution
i mean also part2
considering you just change one number
oh nevermind, it doesn't work for part 2
did you add timers to your code?
import * as fs from "fs";
const inputFile = "input.txt";
const fileContent = fs.readFileSync(inputFile, "utf-8");
let counts = new Map<number, number>();
for (const n of fileContent.split(" ").map(Number)) {
counts.set(n, (counts.get(n) || 0) + 1);
}
function step(map: Map<number, number>): Map<number, number> {
const next = new Map<number, number>();
for (const [stone, count] of map) {
if (stone === 0) {
next.set(1, (next.get(1) || 0) + count);
continue;
}
const digits = Math.floor(Math.log10(stone)) + 1;
if (digits % 2 === 0) {
const half = digits / 2;
const div = 10 ** half;
const left = Math.floor(stone / div);
const right = stone % div;
next.set(left, (next.get(left) || 0) + count);
next.set(right, (next.get(right) || 0) + count);
} else {
const v = stone * 2024;
next.set(v, (next.get(v) || 0) + count);
}
}
return next;
}
for (let i = 0; i < 75; i++) counts = step(counts);
let total = 0;
for (const v of counts.values()) total += v;
console.log(total);
part 2
just changed it to a map
your's shouldnt be much slower, just add the timers after reading the file from disk
yeah that's the thing
similar to today's problem imo
as well as the fishes
for the fishes i didn't have to change the data structure
array still worked
day 5
Part 1: 14ms
Part 2: 9ms
I swear it ran slower last night
maybe the code got scared it was being timed and ran faster
lmao
Well also i think it was running fast, it just takes a little bit to show in the terminal
aight, done it
no, still groovy
def input = getClass().getResource('/day5.txt').readLines()
def map = new TreeMap<Tuple2<Long, Long>, Integer>((a, b) -> a.v1 <=> b.v1 ?: a.v2 <=> b.v2)
def ranges = input.inject(map) {
tot, v ->
if (!v.empty) {
def (a, b) = v.split('-').collect { it as long }
if (b != null) {
tot[Tuple.tuple(a, b)] = 0
} else {
for (p in tot.keySet()) {
if (a >= p.v1 && a <= p.v2) {
tot[p] += 1
break
}
}
}
}
return tot
}
def ids = ranges.keySet().toList()
def merged = new ArrayList<Tuple2<Long, Long>>()
for (id in ids) {
def (aMin, aMax) = id
if (!merged || merged.last.v2 < aMin) {
merged << id
continue
}
def (bMin, bMax) = merged.last
merged[-1] = Tuple.tuple(bMin, Math.max(aMax, bMax))
}
println "Fresh: ${ranges.values().sum()}"
println "IDs: ${merged.sum { it.v2 - it.v1 + 1 }}"
lmao
spaceship operator in groovy
turbofish operator in rust
sounds like based languages
turbofish?
::<>
we also have elvis ?:
lmao
and churros =~

gotta speed that up
eh, aint spending more time on that one :v
that's fair lmao
I didn't hyperfine mine, gonna do it later, probably not super fast though
its including file loading probably
yep
ahh
but file access doesnt change much in java/groovy, they get cached
what's slowing it down is groovy itself, it aint exactly used for speed since all that sugar adds extra processing
the algorithm itself shouldnt take more than 10ms
adding a while(true){} counts as implementing it wrong lmao
realized that for searching the range that matches for part 1 you can likely do a binary search
can be faster by some ms 🤷♂️
you saying this made me scared thinking I did it
lmao
ok, made the optimized version
gonna benchmark now
@quartz kindle @queen needle can I get any faster?
ns / 1e6
good news: i got 0.2ms
bad news: now the answer is wrong
halo
Alright i got 0.36ms using c++
i can't do faster
and then a friend of mine immediately got 0.24ms using zig
need someone who actually knows c++
wheres brain
I think the only way I can get faster with java is by building a native image
or using native arrays
try
bro using zig lmao
If it's good enough for bun it's good enough for AoC
not saying its bad, just unusual, rarely ever see someone using it
He's using AOC to learn it
That was my thought
They haven't released any specific year merch unfortunately
I usually buy the hoodie with the design
Discord is removing active dev badge 
fr?
damn
From the ddevs faq channel
Not for too long probably 
yeah im like wahh
https://support-dev.discord.com/hc/en-us/articles/10113997751447-Active-Developer-Badge
Active Developer Badge - No Longer AvailableThe Active Developer Badge has been decommissioned and is no longer available to earn. Any Active Developer Badges that were previously displayed on user...
Any idea why this could be causing a discord ratelimit on boot
@tasks.loop(minutes=30)
async def update_topgg_stats(self):
await self.wait_until_ready()
if not self.topgg_token:
return
url = f"https://top.gg/api/bots/{self.user.id}/stats"
headers = {
"Authorization": self.topgg_token,
"Content-Type": "application/json",
}
try:
data = {"server_count": len(self.guilds)}
async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, json=data) as resp:
if resp.status == 200:
print(f"[TOP.GG] Posted server count: {data['server_count']}")
else:
error = await resp.text()
print(f"[TOP.GG ERROR] Status {resp.status}: {error}")
except Exception as e:
print(f"[TOP.GG EXCEPTION] {e}")```
This is the only place its called
async def setup_hook(self):
self.update_topgg_stats.start()
await self.tree.sync()
print("[DEBUG] setup_hook running")```
And if i remove it i have no issues
I still dont understand how that code would be doing that. self.guild should(?) not make and calls to d API. I dont know what wait_unti\l_ready() does under the hood but my guess it it just waits for the discord ready event which should also not make calls to d API.
My very very loosely formed idea is that some part of that code crashes and it tries to restart, crashed again, and enters a loop? That might cause the repeated auth api calls to issue ratelimits but it seems like you are doing proper error handling
how many times did you start the bot
lmao
1
you sync on every start/setup, only thing that can rate limit
I boot it 1 every maybe 2hrs or so. So it shouldent be a boot issue
im watching it rn @deft wolf
Why not
You have a limited number of syncs per day
Keyword shouldent
Sync only when needed
Im talking when im working on it
Make it a command or something
Like today i hadent touched it in 3 weeks till now and immediantly got that ratelimit error
Running on your pc i suppose
Where else would it be
You think i can afford a VPS for a bot that is free all around?
Lots of people can
Since you didn't mention anything, I'm trying to isolate the issue
Seeing your responses I'll pass
I want to know what there jobs are then Bc i barely make enough to live.
Sidetracked
Your right there. Wait is ssry a sleep function till discord returns "Startup sucess" or smth like that. And the lens does technically call on discord as its pulling the server count live but that is 1 time.
I'm just guessing. I dont write python code and have never used whatever library you are using. self.guilds feels to me like something that should not call an API as it's a property and not a function
Your fine and your honestly right its just odd what it is doing. I would ask dpy but there kinda a bunch of ***** over ther (In nice words. Banned me for asking for help)

