#advent-of-code
1 messages · Page 12 of 1
how do you accept and read multiple lines in a input?
first 4 minutes it was full
In which language
python
for i in open("file.txt"):
i = i.strip() #now you can work fine here
do i have to use a file?
yeah that's the best way in my opinion
i took user input
oh okay
though i had to put an end keyword because there is no limit
and it compiled
good
it is better to use a file
I mean you can make a get request to the puzzle input url
thats work i have too little braincells for
there is something better, there is a library call aoc
but i dont know how to use it
so something like
inp = input(":", end="")
I eventually wound up with a solution where I ||reversed the strings, and also reversed all the digit words in my regex. s/eno/1 and s/owt/2||
I'm a moron.
absolutely horrific
I could've || just added it to a .txt instead of scraping it. I went it the hard way. ||
yes
jajaja
no i did more like this
while(True):
a = input()
if (a = "print result") : break
...
something sad is tomorrow gets much harder than today
this take multi lines input as many as you want
I think this input was particularly evil, honestly
I've rarely seen input this deliberately difficult to interpret
Max efficiency
allowing the digit words ||to overlap|| is just cruel
For a first day this was a cruel assignment..
line 2 in the example input specifically designed to prevent cheesing it
it was about on par. a bit rough if you haven't seen dictionaries or regex or some other easy way to do the substitution.
help i cant do part 1 lmAO
what are you struggled in?
can you already read the inputs?
did you get the sample input to work first?
heres code
||```py
out = 0
for line in data.splitlines():
first = 0
last = 0
for char in line:
if first == 0 and char.isdigit():
first = int(char)
elif char.isdigit():
last = int(char)
out += (first + last)
print(out)```|| but wrong outptu
break
you forgot to use a break
ah
no
first and last must to be strnigs
strings
huh sample inpouts arent working
so
"9" + "7" = 97
&aoc leaderboard
You are not allowed to use that command here. Please use the #aoc-bot-commands, #sir-lancebot-playground, #bot-commands channel(s) instead.
oHHHHHHHHH IM DUMB
sort of, but it didn't show the real interesting edge case. The real interesting edge case would have been ||eighthree -> 83||
so would it accept somethings like
hi
hello
and print
hi
hello
that would have been fun!
same. Not pretty at all though.
||[right[re.match(f".*?({'|'.join(right.keys())})", l[::-1]).group(1)]||
many people have different approaches. test around and figure out what you like
regex give me anxiety
my input had that - I'd be surprised if everyone's didn't, since that'd be a mean thing to drop on only some people
andd its still wrong :(
finally, now i can get somewhere, thx
maybe im just dumb
wow people used ||regex, i spliced every 5 positions and checked if it had the word and just break'ed the loop (i know pretty inefficient but oh well)||
but it wouldnt work for
"asjdfasjdfkajfkdajthreeasdfa8dshfshfsf"
I did it 2 ways, one using find and rfind that worked, and the second using regex because I wanted to make that work. 🙂
||```py
out = 0
for line in data.splitlines():
first = ""
last = ""
for char in line:
if first == "" and char.isdigit():
first = char
elif char.isdigit():
last = char
out += int(first + last)
print(out)```|| why isnt my thing working part 2
it does
you're right that line 2 does draw your attention to something, but it doesn't illustrate that you should be interpreting the digits on that line as ||823|| and not as ||8wo3|| - it doesn't illustrate that it should be interpreted as ||3 digits and not 2||
anybody doing it in Haskell ?
ohh
i just want to have fun for this day so i ain't gonna bother with regex. let's see what happens further, if i have to
it... doesn't seem to handle the words at all? is that a part 2 solution or part 1?
part 1
oh
lmao
you said "part 2" and that threw me
some lines ||contain only 1 digit||
:P
im dumb part 2
in other words ||the first digit is the last digit on some||
part 2 is tripping me up D:
i was thinking p1 if theres only 1 then skip 😦
shouldve read better
massive time loss
yeahhh pretty hard comparated with first one
evil.
eivl
it's the first entry that has items with characters that overlap
I didn't notice earlier, but line 4 and 6 do as well.
In any case, that's the one I focused on when I couldn't figure out why my simple replaces were not producing the correct checksum
I'm big mad about this input, heh
was that an unusually difficult day 1, or is it just me 😄
Yes
you could reaplce the first and last word and then use your part 1 solution. 🙂
a little harder than previous day1s I think
those 3 show ||overlaps||, but they don't show how you're supposed to interpret them.
they don't illustrate the rule that ||twone counts as 21 instead of as 2 and some non-digit junk||
SIXTEEN IS A DIGIT?
nope 🙂
wait
but it contains one
1 or 6 depending on if it's the first or last one - but your input won't contain those I think
no but SIX is
not yet 😉
Doesn't work if it's the first one 🙃
oh im dum
huh...
?
My answer is too low despite being astronomically high.
sixteen1 -> 11
no that's 61
Also, question
If there's no second number, last number is the first or is None?
That seems like a very important detail
covered in the example
It's academic because it will never occur in the input, but it should be 11 (sixteen -> 16, 161 -> 11)
There will be lots of those to come. 🙂
yeah, figuring out the correct overlap semantics is definitely what threw me for a bit
agreed that it should have been more clearly stated in the spec
it worked out for me, because I was using chained replaces, so "eighttwothree" became "eigh23", which didn't produce the example result of "83"
it's not academic, it's just wrong. The problem statement defined the 9 number words
oh no
ahhh this hapend
no, it DOES occur (or did in my input at least.) and sixteen is six
ok I'm just blind
my answers were both in the 50000-60000 range
well I'm glad it didn't appear in mine LOL
I actually implemented special handling for that and everything lol
and some testing, actually.
I should do that.
there are different inputs. but I'd expect with 1000 lines and 2 numbers per, you should be around the same.
yeah. At first I thought that was my bug, but I replaced it with 1 regex that substitutes all 9 things, and I was still wrong, because I'd wind up with ||eightwothree -> 8wo3 -> 83|| (passing the example), but I'd also wind up with ||twone -> 2ne -> 22|| instead of ||twone -> 21||
small hint: if you're doing ||replacements in your string||, you're probably not going to get the correct answer
no shit
(I have already solved the puzzle btw, that was for demonstration)
((also you can do smarter replacements and still do fine))
it was in the sample input for part 2 as well. last line is 7pqrstsixteen
bingo
glad I discovered this discord - nobody at work wants to chat about it
Yes but the last digit of 16 is 6 so we didn't disagree on that one lol
lol
aha, I see what you did. lol. yes that would have been a problem
yeah. either this input is particularly evil for day one, or these examples are particularly terrible. 🙂
Yeah, it's fine
I'm gonna be mad about this input for days
damm hardest day 1 yet
wait a second
I was originally just replacing them in order, but eightwo become eigh2.
made me rewrite my code. could have shaved 10 minutes off the time.
i did the same 🥹
:O
tip ||re.findall has an overlapped parameter||
I'm still quite sure that sixteen is supposed to be interpreted as just 6. The first paragraph of the part 2 description is pretty explicit about what counts as a digit.
figured it out! And learned how ||lookahead assertions|| work! Pretty cool
but not how spoilers work 😛
now that's handy, but I'm not sure you need it.
i just did
||
line.replace(n, n + str(i + 1) + n)
||

yeah, definitely
why not just use ||lookahead assertion||? genuinely curious
I'm actually clueless at this point.
agreed
part 2 ?
i wanna do aoc so badb ut i gtg class cya
What problem you having?
Many.
I mean, not really
But I'm not entirely sure of what is causing the wrong output
How's it look with the example input?
Even the part 2 example?
maybe investigate what you get for ||eightwo|| and what you really want for that
I don't see this in the docs. The docs state: ||re.findall(): Return all non-overlapping matches of pattern in string, as a list of strings or tuples|| and there's no ||re flag that does this||. I think you have to use ||lookahead in the regular expression itself, right?||
Wait... are you using python? lol
Not reading spoilers btw
That wasn't really a spoiler imo
ok, maybe think really carefully about overlaps then.
you don't have to, but that's one option, yes
right, I meant in terms of using that particular function the way they described
another option is ||scanning the string twice, once forwards and once backwards (and reversing the patterns in the backwards case)||
that would be neat and probably quite efficient since you can skip most of the string 🤔
||not stdlib re, regex package does though||
Oh.
I found my error.
oh, that's interesting. which package is that?
big mood

regex
well i choked hard
we all did
fisk!!!
dennis! ma boyy
every single year we meet once more during AoC
now time to look on yt for fast solves and contemplate is anything even worth it
sixteen = 6
maybe the hardest day 1 ever?
yeah, probably
i was thinking the same yea, at least part 2
I solved use regex I wanna kms
breh
twone
eightwo
no counts as 2,1 but in string form yes 21
i didnt see that
mhm
i solved it and i don't even know the answer to this
is there no aoc spoilers channel? or do we just use this one with spoiler tags?
there is one
you will likely see people spoiler tagging things in here anyway though
aha, I was searching for advent.
where did 77 come from?
|| 7 is both the first and last number in that line||
I'm new to Advent of coding. Where do I find today's challenge?
you can search adventofcode 2023
@minor cave did you pass first try
I haven't even read the puzzle, I was watching a movie
oh lol it is annoying
I'll probably attempt it Saturday
Much appreciated 👍
Fish
the golfed code in #1047673173447020564 does
what do you have to say against that?
small hint: if you're doing ||replacements in your string||, you're probably not going to get the correct answer 🙂
hmm, TIL spoilers don't copy and paste
There are of course ways to do it, the straight forward one is not it. :/
definitely the hardest day one
i missed ||the last example|| on part 1 which took me quite a while to get the edge case ||couldnt figure out whether to leave single digits or add them as it is||
@mossy basin I'm trying to use your lube but I can't get it working
that sounds wrong
oh I see
never mind I got it to work
why would you make something that's realistically only useful as a CLI a function and not a CLI tool
because i use it in a python console
Ah are you a xonsh user too then
Is anyone trying this out in Groovy? I can't get this to even set the puzzle input to a variable ```groovy
import groovy.transform.Field
@Field String puzzleInput;
public class Day1 {
public static void main(args) {
String fileContents = new File('input_1.txt').text;
puzzleInput = fileContents;
}
}
This simply gives me `Apparent variable 'puzzleInput' was found in a static scope but doesn't refer to a local variable, static field or class.`
My guess is that @Field is non-static?
Try @Field static String ... @molten fulcrum
Hmmm
Doesn't seem to make much of a difference
I completed it in Groovy
I didn't make any classes
Also from looking at the groovy docs I don't think you need classes/main functions
Oh, maybe I tunnelvisioned on it being like Java
I'll try without classes, thanks!
how can i fix that?;(
Check your token, it might have refreshed since you last set it
is this the year I finally solve all days 
lol, its my first time, i will try to complete as much as i can do in Lua/Python
The first problems seems very simple
Im so excited i just wanna come home and solve it
I will also make a repo about the 2023 aoc
part 2 not so much XD
I still wonder how people will golf it
yeah still working on it. its kind of tricky
Unless there’s some nice stdlib library for it, it seems like some monster ||unreadable regex|| will be needed
guys i am new to aoc, i not able to understand how to solve the puzzle, what do i need to do?
||no regex for current golf||
the ||regex approach I used wasn't that bad either||
||just used lookahead to replace the empty space before a digit name with the digit||
you can share your repo at https://github.com/Bogdanp/awesome-advent-of-code
Is it just me or is this way harder than usual day 1?
agree
I guess trying to prevent Ai ?
where can I ask for feedback on my code for day one?
I feel like the question just wasn't very clear from the outset
||the testcase should've included something like oneight but the eight is relevant||
how does the scoring on private leaderboards work again
osmenoe help with aoc p2
||```py
a = {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
"six": 6, "seven": 7, "eight": 8, "nine": 9, "zero": 0}
out = 0
for line in data.splitlines():
first = ""
last = ""
nearestdist = 9999
lastdist = 0
for i in a.items():
x = line.replace(i[0], str(i[1]))
for char in x:
if char.isdigit() and x.index(char) < nearestdist:
first = char
nearestdist = x.index(char)
if char.isdigit() and x.index(char) > lastdist:
last = char
lastdist = x.index(char)
out += int(first + last)
print(out)```||
does it take into account the number of attempts 
why dis no workie
sort of like global leaderboards
havent read your code but have you considered ||oneight -> 18||?
1st place gets n points (n = number of people), second gets n-1, etc. for each star
how do multiple people get the same score then
they got it at the same second
there are 2 stars
anyway help ls
||maybe you need rindex instead of index with lastdist?||
huh?
!d str.rindex
str.rindex(sub[, start[, end]])```
Like [`rfind()`](https://docs.python.org/3/library/stdtypes.html#str.rfind) but raises [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) when the substring *sub* is not found.
||replacing might screw up the indexes based on the length of the word and the number of times it appears||
wait why do i need that
wdym
make a thread in #aoc-solution-hints
ok
I read the task twice wrong, +15min of time
idk how to make thred
solved but I think the first day should be trivial, this isn't as trivial as in the past years
did they up the difficulty a bit due to people cheating and stuff
This will put people off for sure
I rallied a few people at work to take part this year and I doubt many of them will attempt day 2 as a result
how is it so difficult, it's just text processing
I have words to say about today's problem
Last year day one was literally "add these two lists of numbers together"
ya I did last year 1-4 easily
ive been on #1 right now for a solid ~30 mins
but I doubt they increased based on chatgpt
not sure why my code isn't working can I paste it here by chance or in help?
it is not difficult, for us, what I meant it should be trivial, and it is definitely not trivial
take a look at day 1 from previous years
ye same, I even recommended it to a relative novice. He can probably solve it but with much effort, so he's probably gonna drop out right at start
I'm not able to solve it using insert / append and casting int
im using two pointers first and last and while loop while first <= last
not sure but a brute force is usually my preference to start off with
Am I in the wrong place? I cannot view problem one
to see your input you also need to login
Didnt know about this repo thanks
part2 is little bit hard :\
what is the recommended time to upload solutions to Github?
e.g. to prevent cheating etc
a couple hours should be enough no?
If you want to be safe just upload the day after?
you can't prevent anything
recommended*
ya if someone really wanted to can just gpt4 it no?\

I still havent submitted its been over 7 hours chill dawg
I tried two pointer method didnt work cuz its skipping lines with one number
also if you cheat you cheat yourself 🤷
is the AoC leaderboard of this server purely virtual?
I can't find the code for aoc in https://github.com/python-discord/sir-lancebot/tree/main/bot/exts
in the puzzle if there is one number only in the line, what should we do !
Have a look closely at the test input
ok heres a huge hint that actually helpeed me a lot
this case is in there
create a new input case where you only have this
test against this
tmmnhlxzpj1eightldxhjnone97
9fivekfpl855mjmfdqzvbn
two29eighteight1
4md```
the first 4 lines, its hard to debug when the input is huge****
I just figured it out but even if I give you psueduo code or more hints it will ruin it
^ note that the puzzle itself gives you a cut down input
and the answers to go with it
huh. that's so mild. I was expecting something truly despicable for day 1
oh ok I should start using that tbh Im dumb
good morning pub
for part2 i got it correct for the given input example
and this one i got it
but for my puzzle input its too low !
Yeah, most of hte people I got involved are not software engineers, just hobby coders so I suspect this will kill them all off day one which is a real shame.
huh
Would you like to ask in #aoc-solution-hints for more help?
I mean I've developed a bunch of projects and I'm struggling with it
whenever you want, as long as it's after the global leaderboards for both parts fill up
I did last years q 1-4 last week with ease
It took me a while, but it was simpler than I thought in the end.
now, this means one less sensible lang for later days
oh. I hadn't considered that
surprised my solution isn't working for the full output rn and but it works for 4 lines rip
This is what I had, dumb mistake on my part
can I link you my code in dm?
00:02:24 2023 day 1 vs 00:00:53 2022 day 1
Sure thing, but theres lots of appraoches, so you might be "way off" my approach but "pretty close" with your approach
you can send it in #aoc-solution-hints (open a new thread if you want)
ok I put it in that thing with a / spoiler
ah ye that makes sense
good lord I tried solving the example input using apl
Imma just nope out of that one
well, first step out of the way, i managed to fix my java environment when installing groovy
This day does translate quite poorly to APL, yeah.
I've seen some videos on APL, first time trying it out. Got as far as creating an array with every line
ive made a code that i belive should work for part 2, and when I test it with the example given: ```
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
i get the correct answer of 281, but when i test with my own input file, they say its wrong
what do you think ||oneight should evaluate to?||
just "one"
well it should be ||18||
$ groovy Main.groovy
Yo
``` 😎
Me and my friend have two different accounts, but we still got the same exact input file
Input files aren’t completely unique
they draw from a pool
There’s a bunch of different ones but not one per person
How to participate
See #aoc-faq - you can sign up at https://adventofcode.com
Is it like a coding competition?
kinda not really
just a handful of coding puzzles ;)
you can compete for solving them quickly if you want to
part 2 is way harder damn
Ok
Do I find the puzzle into events ?
ya click events and select 2023
the submission box at bottom, make sure to signin to your github
use the example for input at first it makes life easier and read the output of the example it wasted a solid 2 hours of my time not reading
ok well my suggestion is that you can push it to Github once there are 100 users on the global leaderboard
u guys used regex for p2 or what?
That's the general rule, yeah - as that's also when submission megathreads start
nah this is confusing
i hate this bum shit story they make it always confuses me
I dont know what the valuable information is except for the 50 stars
||I did yup ||
2 parts * 25 days
yes each day has a question with two parts, each part gives you one star
||you need the first 49 to get the last one||
It is a challenge of reading comprehension as much as it is a challenge of programming
especially later on
if I get all 50 does it go on my github?
wdym
the only thing I can think of about the question is that you take the first occurence of a number in a string and the last occurence of a number, combione them and when you have multiple of these you find the sum of them??
combine*
The story mixes you up which is BS imo
It's part of the fun, I think it makes it a bit more interesting than the dry problem statements of leetcode et al.
one day my visualization post will beat a "funny" post
Ok so is my thought process correct?
if you want hints, go to #aoc-solution-hints please
No way it wants us to have a preset file??
It gives you your input file
No it doesn't you have to manually make one
dude
its in green get your puzzle input
did you login?
which channel
at the bottom near where you submit
if not, you have to login to get your puzzle input
Ohhhh I thought you meant the discord
yea I see it
Ohhhh
This is so easy then >:)
No one told me about this
ya you just open filename and readline thats it
ez lets fuckin go
So in my IDE do I make a file with the input it gave me??
i use pycharm
def trebuchet(filename):
with open(filename, "r") as f:
treb = f.readlines()
trebuchet("/Users/PATH//puzzle.txt")
I know how to open the files from the time I made a web scraper let me send you mine
Have it like this
control save it and move to your pycharm then find path with right clicjk
What is "with"?
Never seen this before
!with
The with keyword triggers a context manager. Context managers automatically set up and take down data connections, or any other kind of object that implements the magic methods __enter__ and __exit__.
with open("test.txt", "r") as file:
do_things(file)
The above code automatically closes file when the with block exits, so you never have to manually do a file.close(). Most connection types, including file readers and database connections, support this.
For more information, read the official docs, watch Corey Schafer's context manager video, or see PEP 343.
that seems useless
I just did ```py
def trebuchet(file):
total = 0
open(file.txt, 'r').read()
trebuchet()
thats mine
well, it can't hurt to ensure that your file is always closed
I dont even know what with does, those python explanations are confusing.
it's better when someone explains it themselves
The above code automatically closes file when the with block exits, so you never have to manually do a file.close(). Most connection types, including file readers and database connections, support this.
def trebuchet(file):
total = 0
with open(file.txt, 'r').read():
for number in file.txt```
this good?
you would normally use it like this: ```py
with open(...) as file:
data = file.read()
what is as file?
open(...) as file is like doing file = open(...)
so is mine correct
no
Even If It Was Correct, Where Is Data Stored?
in a txt file
Yeah, But You Cant Have . In Variable Name
well file could be an object with a txt attribute
file.txt?
Dude they're confusing me
But If You Could First Argument Of open Needs To Be String.
Anyway The Syntax Is with open("filename") as file_variable_name:
"I cant have a . in vairbale name"
file = open('...')
for line in file:
...
file.close()
when using with :
with open('...') as file:
for line in file:
...
stdin?
yeah
Smort 😮
Didnt Know That D:
mostly because that's what we do in the golf solutions
its this that is it
def trebuchet(filename):
with open(filename, "r") as f:
treb = f.readlines()
trebuchet("/Users/PATH//puzzle.txt")
then you loop through lines
What is f???
I dont know how to open a file in python, I don't
Try Looking Over This https://www.programiz.com/python-programming/file-operation
just copy and don't be so contrarian lol
You Can Also Do:
with open(filename) as f:
for line in f:
print(line)
as a junior dev you are way too combative no offnese
"you can't have a . in variable names" was about the open(file.txt, 'r')
Correction: Was About file.txt
Idk He/She Mentioned It Would Be Stored In That Variable, Did I Understand Incorrectly?
yeah, iirc it's roughly equivalent to: ```py
f = open(filename).enter()
try:
...
finally:
f.exit()
guys should I relearn regex for part 2 or just do it using index -1 /+1 etc
but no one does this
I'm trying to understand why, not just copy it and be done.
yeah, because with can do it for you
so you change the name of it with the "as"??
you need the as f to reference the file @minor ivy
You Dont Need Much Regex For It 🤔
yes the verbose version is what Code put opposed to with open
So you reference it because the name has a "." in it and you change it to somethign else with the "as" key word???
I Used re.search, But It Only Finds 1 Match. So Ended Up With re.finditer
you're right but I'm clueless except like [a-zA-Z] / and jumbles of shit
re.findall?
No Indexes 😦
How Do You Know If Its First Last or Whatever
You go through the whole line of letters/ numbers, the first occurence will be easy using the .isdigit() function, the last digit requires you to iterate through the thing to find the last digit.
For 2nd Part You Can Get Away That Easily Tho
I'd like to ask a quick conformation question. In case that theres only one number given in a line, you are supposed to double it? ```1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
In this example, the calibration values of these four lines are 12, 38, 15, and 77. Adding these together produces 142.
Idk the 2nd part
That's correct
The first digit is the same as the last digit
Ima just read automate the boring stuff to learn this file read shit.
Did You Try The Link I Pasted?
What link??
Yes, treb7uchet becomes 77 in the example
r is for reading
you're reading the file for input, so yes
open file, read it, traverse line by lline thats it
you just use for loop to traverse to it right??
ya your outer loop will iterate over lines, then you need inner to go through characters
For part two, would twone be counted as 2 or 21? I thought the former, but now I’m thinking it has to be the latter
It's the latter
Thx
22 no?
(no)
if two exists, how can you use the o in two for a second word?
One also exists
(so 'how can you use the o in one for a second word')
(the answer is they share)
I need to wait till I get home from school to do the puzzle 😔
holy shit i forgot about aoc
Rip
what was the rolled language today?
Groovy
gotcha, thanks
rolled language? people just randomly choose lang to solve it with?
One of the things people like to do is solve each day in a random language
About 10 minutes before puzzle unlock, someone on one of the staff teams picked a random language (idk the specifics) and it was Groovy
huh
omg part 2 today
interesting
where do they post this?
In this channel
alr
hmm at first it sounded as a good idea but I think it would only bring me pain
you have to donate every year to get aoc++???
AoC++ is only for the year you donate, correct
but what about aoc#
IIRC it stays on that year's leaderboard permanently
side-note, I hate part 2 today
🤝
I didn't think I'd need to pull out nom on day 1
oh ok ty
then ill have to donate 2$ again
Hey, is it fine to use libarys like re to solve the AoC Puzzels?
We're not going to punish you
the only "rule" is don't use AI tools
Okay thx
Hey, quick question. If I miss a day for some reason, can I do the puzzles next day?
you can do them whenever you want, only thing thats affected is your position on the leaderboard
yes you can
Why is there the introduction text with the „Trebuchet“ puzzle and within that text is the „Not Quite Lisp“ puzzle linked and both say day 1?
Day 1 2015?
Thanks mate!
It's a reference to past events, Eric puts those in sometimes 🙃
So the not quite a lisp was from 2015 and trebuchet is today?
Yes
Yep
Once a puzzle is released, you can solve it at any time you choose
It's only if you want leaderboard spots that you have to be around for unlock
Alright Ty
I can't believe this caused me issues. 'eightnineseventwo1seven' 81
Mine Was 5seven5
Hi
only replace once ?
It was finding the first seven and not the last one
What is the code to join this discords leaderboard for AoC?
0
Use the command /aoc join
part 2 is gonna be the death of me, just completed part 1
no its easy, dont overthink
Any tips to get me started?
||regex||
||oneight is annoying||
Hello all - I’ve done a visualisation of the day 1 solution. Is that safe to post here? No code or anything really.
yes for sure
Made with the wonderful Textual
that is very very cool
this has to be my favorite visualization ever
excellent job
We are very lucky that @upbeat night and team have made things so easy for us with Textual.
Omg, that took way too long for day 1
guys i need some help
So I did a for loop and then another one inside that one to first get every line then the elements inside of every line.
def treb(file):
total = 0
with open("file.txt", 'r') as aoc:
readcontent = aoc.readlines()
for line in readcontent:
first_number = 0
current_line = []
for index in range(len(line)):
if line[index].isdigit():
current_line.append(line[index])
first_number = index
break
for i in range(len(line)-1, first_number, -1):
if line[index].isdigit():
current_line.append(line[i])
elif line[index] == first_number:
current_line.append(line[i])
How will I make it where it'll combine the 2 elements in the list
Like I have [1,3,4,5,8,7,9,0] for example
and I want to make it combine 1 and 3 which will be 13, 4 and 5 which will be 45 and so on because the rest of the code should work and bring in all the numbers from every line (the first and last occurence of one)
You probably want to do a more simple approach than a nested for loop
the nested for loop is like the easiest way to approach it I dont see any easier way
(let's discuss more in #aoc-solution-hints )
the first one is for the lines and the 2nd is for the actual elements in every line.
Ok
That’s absolutely awesome
Meanwhile I’m making a cluttered blasphemous mess of Palpatinian proportions
lmao
I am pretty sure my solution is way more complicated than it needs to be
anyone else had this when logging in through github?
I pressed F5 a bunch of times and it worked, but that sounds like a bad solution
there seem to be a few posts on the subreddit about it, so you're definitely not the only one
Happened with me earlier today
Had a similar issue, solved by using browser incognito mode
Shouldn't this be reported?
eric wastl and his mods monitor the subreddit, so i would more or less consider it "reported" to the proper people
Got it, sounds good
bros
damn
i felt so good finishing the first task
who is the absolute CHAD that made this?!?!?
these are like leetcode questions
but like a little bit more invovled / requires opening and reading file and stuf
Eric Wastl, absolute legend: https://adventofcode.com/2023/about
the year 2019 is his masterpiece in my opinion
i don't think he's in this discord, some of his mods are though i think
you could donate, or write him an email
2019 was intcode wasn't it
If yes then I totally agree
indeed it was
thats really cool
i made a small cli for myself :d
AoC++ 😎
Do you have to include „zero“ in the second part of today?
Is that true? I see 83k with both stars and 40k with only one star
That seems more like a third
oh I read them in reverse derp
so 1/3 of people haven't gotten it
still. very difficult day 1. I can't remember an AOC that I spent this much time on
Yup. That’s a lot for day 1 but we are intraday
Be interesting to see if that holds through the weekend
I thought it wasn't counted past day 1
Hardest day 1 by far
or is that just leaderboards
Stats are, leaderboard is not
I keep thinking I have eureka moments and realize my solution won't work 😦 I'm trying to figure out how to apply my nom parsers and not having any luck with the arbitrary bytes
Are you writing in a particular language?
yeah, Rust. learning how to use the nom parsers this year
Ah gotcha
Oh yeah the username gives it away lol
I did consider Rust but I don’t have the time for it this year
Don’t have time to fight with the borrow checker lol
I'm on vacation most of this month, so I've got some extra time to dedicate. not enough to compete at midnight when they drop because who can think at that hour lol
For me they drop at 5am so I definitely don’t compete lol
Personal Leaderboard is 0 across the board lmao
I did a few in the past few years where I got some points
it's wild to me that some people cleared part two in under 5 minutes, like a whole 30 of them
suuuuus
both jane street sponsors lol
People who go for the top times have a lot of prep for this. They have prepared functions for all the things they think might come up, plus they practice a lot at this kind of stuff too
oh I get it. It's just interesting to see two coworkers complete at the same second
what solutions did others use for part 2 today?
I was considering ||.translate() until I realized there was text overlap for the word numbers||
There’s a solutions channel #1180009538544488478
what's the point of this channel then?
General non-spoiler discussion
blech. found a solution that works on the sample code but not on my actual set
P1 or P2?
p2
Ah
yo
fairly sure this isnt the place to put code
can you pls adhere to guidance
it literally says no spoilers
just finished both
feel so accomplished
:))
The 3 stages of grief part 2
I feel you
i really thought that 9 .replace calls could solve it
part 2 was really something to me
I spent 2 hours
😭
||it can||
what
part 2 was fucked uppppp 😅
i literally did a happy dance when i got it
not feeling good about the next 23 days lol
in cases like eightwothree i don't think it can work because of the chaining
||you might just need to be a bit more clever about what replacements you do||
I can't say much more without being overly spoilery
That one screwed me
but there are for sure ways of doing this, there are many solutions like it

(e.g. mine)
Some used ||itertools.reduce||
||💉|| 👀
positively groovy
Oh god, that too much ||spoil??||
no

I can send you one line and you'll smack your head and see how it can be done 😛
do it
does anyone else look at their code an hour after doing these and think... how in the absolute fuck did i come up with that solution?
and I was very correct about the reaction 😄
i severely underestimated the difficulty of aoc
Ok, now I'll visit. Part 2 took me longer than expected. Challenge level: SQL.
you're doing aoc in sql?
Yah... "extended" SQL (duckdb)
ouchy
anyone still on part 2
this year is particularly difficult
I normally start feeling fatigue around days 12-15 to complete part 2 of the puzzles
Finally a channel for talking about Alexandria Ocasio-Cortez
i thought it was about the AOC monitors?
hey, I have that one
harder first puzzle maybe
let's wait a few days 😛
it is a weekend to be fair
I'm so confused why mine doesn't work for p2 lol
it looks like it passes the edge cases
but it somehow gets a too high num
Maybe ask in #aoc-solution-hints
I did...
inb4 day 2 is a dp problem and this year is going to be inordinately difficult
Ohh noo, not dynamic programming!!!
inb4 day 25 is just the halting problem
part 2 day 25 is the halting problem
the answer to the halting problem is technically yes assuming a program written on a celestial body that will eventually be destroyed by cosmic events and therefore also destroy the program itself
or did i read the wikipedia page wrong
that's not how the halting problem is specified though
the halting problem is about turing machines, that's it. no celestial bodies, cosmic events, etc
🙄
that implies God is alan turing?
halting problem honestly seems fine
because we'd just get a predetermined input
we don't need to solve it for every general case for aoc
it's just like an exec
our input would be a program that constantly gives us an unlimited amount of random undeterministic inputs
what if the input activates another input, terminates, and that input eventually re-activates the first input

and actually, for aoc2019, i believe we had to find an input that would cause our interpreter to halt. or something like that
oh huh
is it considered halting
wdym "activates an input"
I feel like this was a hard day 1. Is that just me or is this a general consensus?
the latter
at least in Python part 1 is pretty easy -- maybe a day 2/3 challenge though
part 2 is insane for day 1
I don't think part 2 was honestly that bad to solve, it just had an edge case most didn't anticipate
solving that edge case was the hard part
depends on how hacky you were willing to be :)
&aoc c
Day 2 starts <t:1701493200:R>.
I tried to do it in Excel but gave up. I thought I was better at Excel than I am. I think the main problem was the need for recursion
Why do you need recursion?
Might not have needed it but it was the easiest way I could think of. Can't give spoilers in this chat tho
I've been meaning to get around to trying it
It was the ambiguity that got me, had four arguably valid solutions (three? Or was it really two plus a buggy version?I dunno, I put it away)
I hope today was just a fluke and it'll be much easier tomorrow, otherwise I don't stand a chance to make it past 2 weeks lol
I hope today is as fast as yesterday or faster, I have a monster headache tonight 😔
I'm sure someone else can do it for you if you need it
@ keith wekup
heck, i'll be around and i think i have the permissions if necessary
what's the ambiguity?
Eh, that’d be a hint right? (Don’t want to discuss solution here
I'm more asking if there is ambiguity that isn't disambiguated by the sample
There is
i think i'll have to reach my ballmer peak tonight
what needs happening later?
Making the thread for day 2?
&aoc countdown
Day 2 starts <t:1701493200:R>.
I feel like that could be automated ngl
same 😔
watch the amount of people still in aoc decrease every day
that's what happens every year
i probably should get an automation tool
aoc-lube!
I tried aoc lube but couldnt setup dir
Making a thread and picking a language for language roulette
aoc_helper 🙃
setup dir?
(aoc_helper[full] for CLI)
Said it had no module named setup_dir
Aoc-kit works alright but I have to set it up each day
(I don't know if you like fluent style, but aoc_helper has that for lists and iterators)
Does aoc-kit even have auto-submission? @hallow birch Doesn't look like it does from its readme
Fair enough
I think aoc_helper might be the only library that attempts parsing the sample cases lol
probably because it's quite hard LOL
done
;-; python3 -m aoc_lube.setup_dir
/home/me/.local/share/virtualenvs/Advent-Of-Code-eZ_HZCZt/bin/python3: No module named aoc_lube.setup_dir
less than 14 minutes
GL everyone!
best wishes
it's because it's a function not a module
import aoc_lube
aoc_lube.setup_dir(2023)
I still think that's a poor design choice
well, i didn't write aoc_lube for you
(also does that not allow for partial directory init?)
i don't know what that means
aoc template 2-25
If someone already has some days completed (without the library) they may want to init only the days they haven't already got
it already skips over files if they exist
Ah fair enough
Soon :3
Was chosen at 4:55 yesterday
So I'm guessing 2 minutes into the future

shut up
I mean we'll see tomorrow if I was right
then again I kinda violated causality so who knows
Language Roulette: Day 2
The language is ... Ocaml
What does this mean if im dumb
oh god
Language Roulette Leaderboard
A leaderboard for those participating in the Language Roulette Challenge. See #announcements message for information on the challenge. To join, enter this code on the Private Leaderboard page: 3276417-ec19f3e3
a challenge some people are doing where you use a new language each day
Bro I can barely get python to do what I want lol
same tbh
I starated trying to learn about a month ago now and this day 1 part 2 challenge nearly killed me
To be fair day 1 was harder than day 1 has ever been before lol
All you need tbf
Hopefully thats the challenge
I need stdin 🥴
call_python();;
If they continue to increase difficulty taking day 1 as base idts imma complete this year also lol
one minute!
GLHF everyone!!
Do people usualkly save their code or how does this work?
Day 25 is gonna be rocket science
Lots of people upload to GH
"Get a job at Nasa"
trebuchet into space
But you got it? Nice
In a git repo, ye
Alr gl all
<@&518565788744024082> Good morning! Day 2 is ready to be attempted. View it online now at https://adventofcode.com/2023/day/2. Good luck!
I got a hint from reddit that atleast told me where I was going wrong. Assumiung I can't share in here
There’s a #aoc-solution-hints
string parsing huh
god tier
what's p2?
its 12 at night 😢
im still on #1 part 2
nedbat's iteration speach helped with my thought process
112/170 :)
198/223 😔
unfort
not bad considering i'm not at home tbh
ah
i got my first points on the global leaderboard ever!
how are you coding? laptop?
yeah
I'm doing this as I'm running a stall at a charity fair
shit


