#AdVENt of Code
1 messages · Page 7 of 1
WTH
parse mapping, process mapping, then go to the next
oh yea int32 isnt enough
i think crystal should do garbage collection?
@sullen fiber ok so part of it might be
cause im initializing the array
of like 481096765 elements
struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64
getter dst_range : Array(Int64)
getter src_range : Array(Int64)
def initialize(@dst_start, @src_start, @length)
@dst_range = (dst_start...(dst_start + length)).to_a
@src_range = (src_start...(src_start + length)).to_a
end
end
dst_range is an array
of every singkle number
idk
it used like 40 gb
WHAT IW SOWHT ANG
AWTHJ GFHN
WATOFGNWAOHTN
AWOTNHFOHWTAFNTHOWNAFGHO
TNWAOHNAWTOH
until systemd killed it

NOWHNATAOHEWNTG
OHNAWEG
TOHOEWATHG
OH
OAEWHTGOHE
OEWHTNGA
WEOHT
AOWENHAO
WEHTOAHGN
WEOHTAOGEWHOAEWHTGOEWATHG

end
i wonder if the Range class is better
@sullen fiber find method on Range that lets me get value at index in the range
only other idea i got is doing some math
soon
in 25 seconds
chaos shall be upon us
ur insane zt
nop
1
happy new year
LOVE THIS PROBLEM
this input tiny af
Todays problem seems fine after yesterdays incident
the input is so tiny
Zt will calculate output himself
okay
I AM WAITING FOR BUS
fr
In a good way
how would you get the numbers from the string as seperate numbers
since theyre spaced by varying spaces
cant do a split(" ")
does your stdlib split not account for that
idk
in uiua its just ⊜□≠@\n.
refreshingly easy
wow today is the first problem that doesn't make me wanna kill myself
What about part 2
part 2 is totally fine, no bullshit
why would i write code to do this
i don't even know what math shit y'all are talking about i threw a for loop at it and it worked 👍
rigging horse race bets prob idk
no like to solve the problem
i wrote it in python but wish I just used a calculator instead lmao
my flatmate was talking to me about rust when the problem started and he wouldn't stop and i couldn't read the puzzle text 
would have gotten it done so much faster
I just did mine with a for loop too
no you probably just did a for loop instead of a _.range

lmao oh god
"SHUT THE FUCK UP IT STARTED"
he won't even do advent of code because he thinks it's too competitive
like ;w; sure it's nice to get on the leaderboard but it's also just fun to see how fast I can go? i don't care about the leaderboard ;w;
i feel like most people don't do it for the leaderboard
how is the example solved correctly but not the actual input
Yeah
whar
looks inside vencord
vap using uiua
uiua uiua uiua uiua uiua
uiaiai so bad
honestly part 2 is easier than part 1
the only thing that gave me trouble was parsing lol
for what
par 1
my answer was 74k for p1
where did you get 88k
remember you're not calculating distance for these
or do you mean 88k solutions
galunguh
my answer for p1 is 449,820 lol
how do i tie in quadratics to this
did any of yall also use ||dfs || for part 1 and then cry in p2
what is that
||depth first search (bruteforce)||
||oh yeah I just checked every button pressing time value possible and incremented a number lol||
||that worked for both p1 and p2||
it's not brute forcing it's just applied mathematics 
|| part 2 benchmark Average timing: 84.909324ms ± 38.073447ms ||
time to make a large input 
||part 1: Average timing: 1.112µs ± 2.031491ms||
not that type of bruteforce
i made an actual ||dfs function that adds 1 to time and speed and calls itself twice per iteration||
||in p2 i had to rewrite it to just filter 0..maxtime||
I like your funny words magic man
|| ``` override fun solvePart1(input: File): Any {
val (time, dist) = input.rl().map { it.split().drop(1).map { it.toInt() } }
return time.map { (0..it).filter { t -> (it - t) * t > dist[time.indexOf(it)] }.size }.product()
}
override fun solvePart2(input: File): Any {
val (time, dist) = input.rl().map { it.extractNumbers().toLong() }
return (0L..time).filter { (time - it) * it > dist }.size
}```||
i love kotler
why is it so unformatted
this is the first day ive done where ||if you wrote part 1 properly, part 2 requires you to delete code and run again||
i should probably stop looking at early day problems and coming up with the most mentally insane and complicated solution
||yeah part 2 is so easy, if he was going for yesterday's "no more brute forcing" then he completely failed because computers are actually pretty fast||
||well any sane person shouldn't be using lists in the first place, basic loops are so much better||
||hi||
||just increment a number, no need to calculate size||
||hi||
||```
fun dfs(time: Int, speed: Int, totalTime: Int): List<Int> {
if (time >= totalTime) return listOf(time, speed, totaltime)
return dfs(time+1, speed+1, totalTime) + listOf(time, speed, totaltime)
}
||tyminky||
i didnt even increment anything in my p2 solution
yeah because your "increment" is a list that you count
||
(0L..time).filter { (time - it) * it > distance }.size
||
for part 1 its the same but product and ||all the times||
kids, remember, whenever you decide to do a ||dfs that increments by 1 and only checks if the number has exceeded the bounds and do nothing else, it shouldnt be a dfs, it should be a range.filter||
also today is solveable with 12 clicks on a calculator
nuh uh
guy on reddit says ||Not really lol, the algebra is literally
!time, divided by 2, squared, minus distance, floor, times two, plus one!<
That's it. Six total steps to the answer - three of which are doing a calculation against a single digit, the fourth is one button, and the other two are using the inputs. If you have the input and output as pre-registered values, T and D, you can press 12 total strokes on a standard scientific calculator to get the answer.
!T/2=^(2)-D_x2+1!<||
i got part 2 now
that doesnt give me the right answer
why do people say day one was hard
then you did it wrong
square root?
physics have failen me
wh
twoneighthreeightwone
mantika cant spell
cuz its a toy boat where u spin a key to twist a spring that launches it or something
oh
||```js
const fs = require("node:fs");
try {
const file = fs.readFileSync("./input/day-06.txt").toString().split("\n");
console.log(Part 1: ${part1(file)} ways to win);
console.log(Part 2: ${part2(file)} ways to win);
} catch (err) {
console.error(err);
}
function part1(lines) {
const [times, distances] = lines.map((line) =>
line.split(/\s+/).slice(1).map(Number)
);
return possibilities(times, distances);
}
function part2(lines) {
const [times, distances] = lines.map((line) => [
Number(line.substring(10).split(" ").join("")),
]);
return possibilities(times, distances);
}
function possibilities(times, distances) {
return times.reduce((acc, time, i) => {
const recordDistance = distances[i];
let waysToWin = 0;
for (let heldTime = 0; heldTime <= time; heldTime++) {
const distanceTravelled = heldTime * (time - heldTime);
if (distanceTravelled > recordDistance) waysToWin++;
}
return waysToWin * acc;
}, 1);
}```
||
it would be more harder if it accelearted while moving tho
tldr pls
would it be tho
phycics
theres prob a formula
i was hoping it accelerated
mantushka
instead of ||(maxtime - time) * speed you do (maxtime - time) * (it/2 * (it+1)) i think||
yes
i think u can do this on a calculator
.
square root
isnt that what i said
the bottom is notice that its wrong tho
idk thats not my formula
T=30 D=200 is one of the examples
i did ||
(0L..time).filter { (time - it) * it > distance }.size
||
ya ik i was just letting u know its not that one
u can probably also just do a manual binary search
find the first number where it works and the last where it works
I thought my part 2 would take few mins
it took milliseconds
looove
non release is 1.56 seconds husk
the hardest part of this large input is the damn formatting guh
vap help me
im still on day 5
||```crystal
struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64
getter dst_range : Array(Int64)
getter src_range : Array(Int64)
def initialize(@dst_start, @src_start, @length)
@dst_range = (dst_start...(dst_start + length)).to_a
@src_range = (src_start...(src_start + length)).to_a
end
end
def process_map(mapping, value) : Int64
mapping.each do |range|
if index = range.src_range.index(value) # check that value is in the src_range, and fetch the index it occurs at
return range.dst_range[index] # get the value at the same index in dst_range
end
end
return value
end
i just dont know how to rearrange it
im blanking
struct Guh
yop
I always end up naming at least 3 variables some variation of fuck while writing my solutions
and then have to clean up after
part 1 or part2
both
part 3
ill get the answers i have to write the solver
float2048
floats will not be enough
@sullen fiber check ping
wait zt im codin
die
yop
get struck by lightning
I decided to make my part 2 answer better
now it solves in 13.776µs with the power of MATH
quadratics are fun
ty do
is that going to fit in an f64 wtf
why did it give such a small answer
nop
@real hinge
sorry im not finding a decent arbitrary-precision number lib rn
does that bottom number even fit in a 64 bit int
not even close
wait actually do I even need floats
yea no thanks ;w;
though a i128 is still too small I assume
but yeah im not doing bigints, you can cope
I need to sleep
to make today's non brute forceable you only need to add like three races of the normal size anyways
just adding two makes my brute force take over 30 minutes (estimated based on runtimes from other tests)
oh
wtf
i solved day 5 part 1 in less than a second
how did others get like minute long times
depends how you implemented it
i made mine go lazily
oh just part one
yes
yeah part one isn't hard
yea thats the right answer
BigInt
WHY AM I GETING 0
part 2 will be fun
vap unsane
so sane
part 2 is waiting for computer
what is the outcome count for 7509 9731106
part 2 i need to make sure im doing the math without rounding errors
nvm
4178
WSL is taking 4 gb of ram
Time: 30 31 69 141 238 9913375
Distance: 194 205 657 1776 2492 694201739
my computer is so laggy that shareX refuses to open screenshitter
true
0 is a valid number
someone try it
wdym
run it
part1 or two
both
i dont have 2 yet
it should work for both
part 1 is 1489058314105824
are there any 0s
if there were it would have zerod the whole accumulator i think
u just need one in there thats
time^2 / 4
or more
o yea
whats regular input
aoc input
you said my part one was correct, but that isn't what I got?
@real hinge run my input
your input doesnt have terrible double spaces
wait
oh thank fuck
does yours end with a fuck ton of zeros as well?
p2?
1489058314105824 this is on i128
I would try part 2
but I hardcoded values
because was too lazy to parse
imma do parsing
your part 2 requires more than float64 for me
"please do not spam"
manti are u doing math on int
yes
mods crush this person's skull
you're probably getting rounding errors
||```crystal
file_content = File.read("./input/day-05.txt").lines
seeds = file_content[0].lchop("seeds: ").split(" ").map { |seed| seed.to_i64 }
seed_to_soil_index = file_content.index("seed-to-soil map:").not_nil!
soil_to_fertilizer_index = file_content.index("soil-to-fertilizer map:").not_nil!
fertilizer_to_water_index = file_content.index("fertilizer-to-water map:").not_nil!
water_to_light_index = file_content.index("water-to-light map:").not_nil!
light_to_temperature_index = file_content.index("light-to-temperature map:").not_nil!
temperature_to_humidity_index = file_content.index("temperature-to-humidity map:").not_nil!
humidity_to_location_index = file_content.index("humidity-to-location map:").not_nil!
struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64
def initialize(@dst_start, @src_start, @length)
end
end
def process_map(mapping, value) : Int64
mapping.each do |range|
index = value - range.src_start
if index >= 0 && index < range.length
return range.dst_start + (value - range.src_start)
end
end
return value
end
def process_seeds(text, start_index, end_index = nil, values : Array(Int64) = [] of Int64)
values.map do |value|
mapping = if end_index
text[start_index + 1..end_index - 2]
else
text[start_index + 1...]
end
mapping = mapping.map { |line|
dst_start, src_start, len = line.split(" ")
Guh.new(dst_start.to_i64, src_start.to_i64, len.to_i64)
}
process_map(mapping, value)
end
end
m = process_seeds(file_content, seed_to_soil_index, soil_to_fertilizer_index, seeds)
m = process_seeds(file_content, soil_to_fertilizer_index, fertilizer_to_water_index, m)
m = process_seeds(file_content, fertilizer_to_water_index, water_to_light_index, m)
m = process_seeds(file_content, water_to_light_index, light_to_temperature_index, m)
m = process_seeds(file_content, light_to_temperature_index, temperature_to_humidity_index, m)
m = process_seeds(file_content, temperature_to_humidity_index, humidity_to_location_index, m)
m = process_seeds(file_content, humidity_to_location_index, nil, m)
puts "Part 1: #{m.min}"
part 1 works
bruteforce time
but thats way too much memory
the answer to part1 is 11645 bits
HOW CAN I PARSE THIS
p2_seeds = seeds.in_slices_of(2).flat_map { |(start, len)| (start...(len - 1)).to_a }
guhhh i explode soon
the part2 distance is 22909 bits
its at 15 gb of memory usage
okay I think this is unrealistic with static typed langauge
I was gonna try u64x64 but weird stuff

its just holding at 15 gb
wait dont tell me
you are trying part2
with arrays
its impossible dont even try
IT WONT BE ENOUGH
wrong
YOU NEED PETABYTES OF RAM
wait i know a programming language that can do this easy
one sec ill get the part 2 answer in 2 seconds
part 1 worked causes seeds array was small
maybe i could make this parallel?
process 1 range on one thread, another on another thread?
what datatype did you use?
bigint
im anticipating that there will be an issue when trying to square root a bigint
and then doing more math on that
will accumulate a rounding error
wait
smh i have idea
i will simply not bother with mega large inputs 
it was 2 yeah
ur on the repo if u wanted to just add it
i will adapt it to match what you have in there
it is funny my input generator takes longer to run than my solution for that day
i hope its not too confusing
nop i took a quick look a bit ago and it didn't seem too bad
real fire
WHERE DID I VAR
I'm trying to think of what I need to change to do part 2
o i c
this
cus let/const in intensive loops will make gc cry
Im gonna have to drop that m array aren't i
understandable
guh i need to publish ec25519 npm package
soon tm
this is the key
so I think what I should do is instead of doing all the seeds together I should do them separately, update the min value
and I can use parallelism to make that much faster
by doing seeds on different threads
or one range for a thread
rwae;
Because of a bug in the day 6 puzzle that made it unsolvable for some users until about two hours after unlock, day 6 is worth no points.
fire
wait im looking at the wrong year
LOL
unfortunately: no tsconfig
fix
sure i can, would probably just use https://github.com/tsconfig/bases#node-lts-tsconfigjson unless you have an issue with that
also do you care about pull requests or can I just commit and push
smol works too
two different kinds of slightly lazy
me: make someone else do work that I could have done
you: do the bare minimum but in the end better
z
im big lazy
WHAT
Z
ZT
I TOLD YOU
ITS IMPOSSIBLE
wrong
THERES AT LEAST 100 MILLION ENTRIES THERE
are u running it in release mode
I have enough ram
never
HOW ARE YOU GONNA STORE 1 BILLION INT64S
i was gonna do aoc this year but man
I have enough
wait
what if I use swap space
that'll be funny
okay so you need 8 billion bytes
day 3 killed my motivation and i heard day 4, 5, and 6 were just as ugh
I have enough storage too
6 is not ugh i dont think
7.4506 GB
mantika I have a network swap device on your computer
you need that much memory
I have that
you are so bad
I made mine do it in levels
good
could you do it
yes
save rusher
I will
guh teacher was explaining how to make prime number findng algorithm since last 20 minutes
soooooooooooooo boring
memorize
you will need
WHY WOULD I
I am doing weird aoc problems then theres prime number finding algorithm

Legit sleep
soon
Stackoverflow lmao
you dont even need
wdym
at worst you can just loop from 0..number and check if its divisible by any number
sleep
@delicate crane hi
/ze{0,2}t\d{2}?/i
so worst
one day you will need to generate a 4096bit prime number truist
yop
idk how more efficent you could do it
you need to check if its divisible by any prime numebrs
but finding those is the problem
using a sieve
sieve?
like ex nihilo
holy sht minecraft referaence
okay so
isnt sieve basically the same
you remove prime numbers
TF
2,3,5
sieve is like
mass automating sieves in modded Skyblock was an experience

project ozone
u remove all multiples of an integer
auto sifter and mechanical user beloved
and do this for all possible factors
@real hinge guh we need to play modded Minecraft
yes
and those integers are prime numbersss
ya
@real hinge give me biggest prime number
and then return all the ones that werent filtered out the primes
I think if you are trying to see if single number is prime checking all is the easiest
but for multiple in range sieve is lovely yop
991923885493
there are better probabilistic tests for chekcing if a single number is prime
deterministically checking is super hard yea
@real hinge modded Minecraft when
2022
but there are algorithms for checking if a massive number is prime with like easy 99.99999% certainty
is this computable by iterating through ranges
for either part
interesting
eagely prime test
TRUE
TRUE
either prime or not
WRONG
wrong
Guhh too far away
thing is the more numbers are getting bigger the less prime numbers there are
I think
thats like
not sure
bleh
its probably like hta

that symbol next to p means the number being prime
pr means probability
the operator on the left of P is NOT
MRk is the number passing the miller rabin test after k iterations
and conditional probabilities make me wanna kill myself
this is the fastest prime checker in existence
we must stop notating
4095 zeros + 1
:3
NOT A PRIME NUMBER
wdym
oh rly
ya primes start at 2
guh
owned
I will writ ebetter one
how many ms
53982894593057
check this
not REAL
mk-mantika leaked documents
rini will be crucified
is that my input
no thats my input
send
can some be 0
are u asking me to put zeros in there
222334565193649
or are u asking if its possible for there to be a zero
if this simple loop is only using 0.272 seconds itsfine imo
is it possible
nah
how did u gen it
my "Distance is too close to max distance" check
now try checking 171284189464818489127489165984812648912647126481489127498271041289462857895687657236598365923659823
GIVE SOMETHING THAT FITS U128
nah thats cheating
RUST DOESNT HAVE MORE THAN 128 BIT
it has bytes
heres my benchmarking tool
does 5 fit in int64
wdym
what is 5?
ohh
is that correct
no they're all uint32s
and why tf does part 2 take less time than p1
wait i might be smoking let me check
I found bigint library
im not even merging the ranges in p2
BUT HOW DO I PUT THE THING
ur part1 is right
cant even parse
its just faster
i think ur part2 is wrong
uh i can reverse the mappings and tell you the seed that corresponds to the answer
if that helps
ok ill put it through p1
why doesnt it return when finding a match
because it would finish in 2 microseconds
ok so
its at 19 million
why is there no infinite precision bigint
1468910892

this is rust
static typing
but I wish it had 256 and 512 bit numbers
NO
F
i mean it solves aoc input so im not debugging it
oh true true
try
2^82,589,933 − 1
Yeah but dynamic numbers would work maybe a bit weird
you just gotta reinvent math
represent it as a string or smth
you could do it as a string tho it would just be horror
And same for loooimg probably
i think the old bignumber.js library did this
it was horror indeed
java.math.biginteger stores it as an array
java based
so its actually quite limited
how so
cuz you can store way more numbers as a string
and storing millions of digits in an array is gonna oom
do they store each digit?
im sure they store like chunks of bytes
instead of doing it in base10
stores it in base 65536
yea surely thats much better than trying to do math on base 10 digits that take up way too m uch space for each digit
least sig bit first
so 5000000000 is represented as 1 on index 1 and
705032704 on index 0
vap
storing the large input for day02 in a string may not be an amazing idea unless I shrink the large input a considerable amount
its like 82mb right
thats not so bad
hm well
I will see how long it takes to run
it's going on a minute or two already
oop
where u get large input for day 2
ok
but DAYUM
here go
77mb???
FIRE
no
474402212 214379527
er
looked at wrong number
i have small brain sometimes
is that large input
it is
it says user 86,4
still blazingly fast 🚀 🚀 🚀 🚀
someone more familiar with x86 could probably find some magic opcodes to make it even faster but I'm probably pushing it close to the limit
(at least I hope I am)
they will use the xmm simd parallel instructions
@proper totem solve AOC using an attiny85 and 7 segment displays
can u push ur code i wanna add the ability for generators to be streamed to files
okis

why does it say 20s
goodnight friends
it does work for the example and normal inputs so i do know it works
large just explods
NINI ZT
sleep goods
it takes 3s
make 1 trillion lines
oh cus gradle overhead
does it have to start a daemon itself
its measuring the time of the whole command
like 30 times
but u prob just one the time of ur part 2logic
so hyperfine prob lame for this
i guess i have to install kotlin in cli
HTTPS
http git so bad ssh better
i leaked my ssid
my initial generator was a lot larger since I guh I forgot to stage changes from index too
@sullen fiber you'll need to add the imports for 02 to index but otherwise stuff should work ish
I promise I'm not this bad usually my brain must just be very tired
what nah this is good
we should make a large input for 2022 day 24
how did u redo the round before
like 1mil x 1mil grid
just round--; continue which would just get new random numbers
oh true
since I was using Math.random
are lines also lonh
or is almost every line false because theres so many chances for it to be false
original input generator
auto imports are bad
I need to get jetbrains to stop auto importing process
is ur input gen only ts
ya
okay slight issue
change the default large input game count to 100k instead of a mil
I must have gotten numbers mixed up because 1 mil generates a 774mb file
time to see how long this one takes to run
for me 100k total games only generates 78mb file
that makes more sense
that's close to how big the file I uploaded here was
most sane executable
yeah
oh okok true true
oh god this happens a lot
i must generate an 8gb input file
FEAR
i made it pretty likely that there will be matching numbers, and didnt check for duplicate numbers
pretty likely so that there is a u64 overflow
i made it append to the output every 1 million games
and run for 100 million iterations
1 billion actually
but it takes like 5 minutes for 1mil iterations
cuz it has to compute 60 random numbers for each game
Game 70000: [67, 21, 31, 22, 38] | [1, 17, 22, 43, 38, 32, 39, 70, 61, 64, 18, 3, 31, 30, 94, 30, 11, 21, 85, 42, 23, 4, 60, 28, 31]
10 minutes*
wait why are there braces
fuck
Game 10000: 80 59 22 68 9 | 71 10 51 29 59 2 27 86 2 52 59 17 46 50 69 3 79 59 25 92 62 99 17 92 84
there can also be duplicate winning numbers
but that shouldnt matter anyways
@proper totem can u
run ur code on the 02/input_large.txt from the repo
i wanna know if my uiua code is still right
it was right before but just in case
it will be 99gb after its done running
yop just a minute
FEAR
but itll take a week to finish running
167 hours
more actually
like 10 days
ill stop at a few million
mmmmm
my asm solution segfaults which probably means we have a formatting issue of some kind
i hope
still segfaults with trailing newline
TEWRGADFHJ
ty
what are u goidng'
I love debug prints in assembly
WTF
thank u for ur efforts katlyn
INSANE
okay it works
there were two newlines at the end of the file apparently
which mega exploded the assembly
general formatting does work though so no issues
here is the answers I get for large input @sullen fiber
1/3RD DONE
@hazy sinew @proper totem how many cards does yalls input got on day4
192
i see okok
197 i think
pro tip: trying to link an 8 GB executable may cause your computer to struggle with memory usage
another pro tip: gcc will just die if you try to link an 8GB executable
I will try half the inputs
LOL


