Beep Boop Bip
[Return] [Entire Thread] [Last 50 posts]
Posting mode: Reply
Subject   (reply to 3044)
BB Code
File URL
Embed   Help
Password  (for post and file deletion)
  • Supported file types are: BMP, C, CPP, CSS, EPUB, FLAC, FLV, GIF, JPG, OGG, PDF, PNG, PSD, RAR, TORRENT, TXT, WEBM, ZIP
  • Maximum file size allowed is 10000 KB.
  • Images greater than 260x260 pixels will be thumbnailed.
  • Currently 1012 unique user posts.
  • board catalog

File 16698735903.png - (1.55MB , 1920x1080 , SUPPA HAKKA.png )
3044 No. 3044 [Edit]
Hello gentlemen, and welcome to the Advent of Code: TOHNO-CHAN Edition.

Post your solutions!
Ask questions!
Have fun!

Leaderboard: 1795791-8781b07c
Expand all images
>> No. 3045 [Edit]
And my sincerest apologies for belatedly making this thread!
>> No. 3047 [Edit]
File 166987638571.png - (77.84KB , 864x682 , event1-1.png )
Allocations for days!
>> No. 3048 [Edit]
File 166987654219.png - (81.38KB , 830x756 , event1-2.png )
Performs slightly worse, probably due to allocating an array for sorting.
>> No. 3049 [Edit]
Disregard that, after increasing the N, this solution performs about as well as the initial one that I didn't post.
>> No. 3050 [Edit]
File 166992394650.png - (257.62KB , 1636x1198 , carbon.png )
I completely forgot about advent of code...
Last year was my first time participating, I ended up lasting until day 18.

This year the goal's to finish it... but in common lisp!!

I got interested in it some time ago but never ended up using it for any projects, so this is a nice excuse.

It's really hard to get used to the lisp way of thinking again though, it's been a while since I wrote any lisp code and it was never much to begin with.
>> No. 3051 [Edit]
Thank you for your participation and enthusiasm! Your solution is aesthetically pleasing, and it's composed well too.
>> No. 3052 [Edit]
File dayoneptone.c - (898B )

I tried this but got absolutely crushed on the very first challenge. I'm pretty sure not only does my program not work, it is also a monstrosity judging but how succinct most programs of the kind seem to be.
>> No. 3053 [Edit]
You're doing it in C, it's terrible for doing any sort of string processing. Your error handling is also not idiomatic, would recommend looking at established codebases, but that shouldn't impact correctness. Could you also please indent or format your code? There's no need to separate declaration and assignment unless you're using some ancient C spec (and if you're using C, why make things harder on yourself)?

You're also reinventing the wheel a bit, you don't need to read 1 char at a time, you can read the entire word and do atoi. Or use scanf. Just generally, I'd recommend looking at the "boilerplate" code for icpc type problems which will show you how to read from stdin/stdout in C.

So the short answer is that you're doing this at a much lower level than you need to be, even if you stick with C.

As for why the solution is incorrect, I think fgetc already increments the file offset, so you don't need to do it manually?

Post edited on 2nd Dec 2022, 11:51am
>> No. 3054 [Edit]
File 167001027871.png - (837.60KB , 1868x3386 , carbon.png )
I'm ashamed of how ugly my solution is...
It took me quite a bit of time too, but I'll keep going. Just hope I improve in the next few days, otherwise I'll be getting filtered even sooner than last year.
>> No. 3055 [Edit]
I feel like a pleb since I just used an associative array to map the hands to a result. There's probably an elegant solution via math, but I didn't have much time for research.

I feel you, friend.
>> No. 3056 [Edit]
File 167004732234.png - (141.34KB , 1532x2474 , carbon.png )
The unga bunga continues.
>> No. 3057 [Edit]
File 167007493491.png - (517.76KB , 1852x2158 , carbon.png )
Oh yeah, it's going much smoother than before

I've been meaning to ask, what language is this? It looks really nice.
>> No. 3058 [Edit]
Yeah, you're right. The reason I tried it in C is because it is the only language I know something about. As for the reason the program did not work, I don't really know. The fseek served as an way to check if there would be 2 '\n', I used it forwards and backwards so it wouldn't mess with fgetc. For some reason this program refuses to do anything. I tried printing some values, or just anything and random points in the code, and nothing comes out. It seems after the program tries to open the file it refuses to do anything and ends. The compiler accused something on the feof condition. But yeah, I should probably redo it from scratch again.
>> No. 3059 [Edit]
Possibly how you specify the path is wrong, I don't know anything about windows or how libc functions work with whatever wacky stuff windows does. Also printf is buffered, so if you don't immediately flush you won't see any output until program ends.
>> No. 3060 [Edit]
File 16701555787.png - (333.33KB , 1716x1488 , carbon.png )
My code is getting shorter!!
Or maybe today's problem was just easier... It did feel like that
>> No. 3061 [Edit]
File 167018984199.png - (182.56KB , 2148x1352 , carbon.png )
Pretty easy, but my brain decided to shut off near the end for some reason.

>I've been meaning to ask, what language is this? It looks really nice.
D, part of the Island of (Programming Language) Misfits.
>> No. 3063 [Edit]
File 16702707812.png - (628.21KB , 1552x2872 , carbon.png )
Today's one was a huge pain to parse for me...
>> No. 3064 [Edit]
It was a fun time for sure. Among the three of us on the leaderboard, there's a guy who easily knocked it out. So congrats to him! [Unless that's you, in which case, congrats to you!]
>> No. 3065 [Edit]
File 167032597892.png - (297.44KB , 1130x1570 , carbon.png )
Pretty easy today, I guess you were supposed to get fucked over in part 2 if you settled for a bruteforce solution first.

>Unless that's you
Heh, that's definitely not me... I only ever get to do the problems at least 5 hours after they're released, and even then it takes me a while.
>> No. 3066 [Edit]
File 167032916090.png - (195.37KB , 2414x1538 , carbon.png )
I was hoping for something more interesting than this, but I'll take it over the last one, but to be fair, I was running into some linker issues.
Also, where the hell are the other two people? I'm heartbroken.
>> No. 3067 [Edit]
I'm busier than expected. I'll try and play this weekend.
>> No. 3069 [Edit]
Man, I didn't think of using a hash table at all. This is why I like seeing other solutions.
>> No. 3070 [Edit]
I'm not well-versed in either D or lisp, is the

buf.canFind!(ch => buf.count(ch) > 1) ? 0 : i

just checking if buf is comprised of all unique characters (i.e. no char appears twice?)
>> No. 3071 [Edit]
It is indeed. Another way to do it would be this:
signal[i..min(i+k, $)] .staticArray!k[] .sort() .uniq() .walkLength == k ? i : 0

>> No. 3072 [Edit]
File 167038124237.jpg - (90.47KB , 559x421 , aocd1p1.jpg )
late starter here. Day 1 first challenge.
>> No. 3073 [Edit]
File 167038330682.jpg - (101.16KB , 588x407 , aoc_d1p2.jpg )
day 1, 2nd puzzle
>> No. 3074 [Edit]
My kludgy day 6 solution in Python with minimal cleanup:
with open('input6.txt') as f: data = print([j for j, s in enumerate([set(data[i:i+4]) for i, c in enumerate(data)][:-3]) if len(s) == 4][0]+4) print([j for j, s in enumerate([set(data[i:i+14]) for i, c in enumerate(data)][:-13]) if len(s) == 14][0]+14)

>easily knocked it out.
I wouldn't say so. It took me a while too. And unlike you guys, I took the easy way out and used regexes for day 5. I even lost a lot of time failing to notice that I messed up one of them...
>So congrats to him!
>> No. 3075 [Edit]
File 167039114918.jpg - (68.78KB , 516x502 , aoc_d2.jpg )
day 2, 2nd puzzle.
First puzzle is the exact same, except that the map is different.
>> No. 3076 [Edit]
After two attempts that didn't go anywhere, a solution is begotten. Biggest thing that bothers me is the vestigial 'name' method, but I'm too lazy to remove it.

Welcome aboard, anon! Seems we have two lispers now. >>3075 is concise as hell.

I need to get back into python (and ruby). That looks slick.
>> No. 3077 [Edit]
File 167041287537.png - (433.88KB , 1692x4740 , carbon.png )
Guess I wasn't that lazy after all! [Could a mod delete my previous image? Might as well not have it take any space.]
>> No. 3078 [Edit]
File 167043820480.jpg - (210.35KB , 1080x805 , aoc3-1.jpg )
>> No. 3079 [Edit]
File 167044965350.png - (13.85KB , 859x95 , screenshot.png )
Finally getting it right felt so good...
>> No. 3080 [Edit]
File 167044972498.png - (933.44KB , 1770x4212 , carbon.png )
Forgot the code
>> No. 3081 [Edit]
File 167045273836.jpg - (147.82KB , 964x618 , aoc_d3p2.jpg )
>concise as hell
yeah, I've been doing these on my phone so far, so I have a strong incentive to keep keystrokes per puzzle to a minimum.
If time permits, I'll re-implement a few of these in assembly, just to see how I solve them when I don't have all these fancy standard library functions and data structures at my fingertips.
>> No. 3082 [Edit]
I didn't like how I hard-coded the entire alphabet, but using bitwise manipulations made it even worse:
(defn priority [c] (+ (bit-and 2r11111 (int c)) (* 26 (bit-and-not 1 (bit-shift-right (int c ) 5)))))

>> No. 3083 [Edit]
File 167048020883.jpg - (160.05KB , 846x632 , aoc4_2.jpg )
day 4
>> No. 3084 [Edit]
File 167050104617.png - (290.73KB , 1540x3250 , carbon.png )
I make hamsters seem intelligent.

>yeah, I've been doing these on my phone so far, so I have a strong incentive to keep keystrokes per puzzle to a minimum
>I'll re-implement a few of these in assembly
Wow! T-C truly has all kinds.

>I didn't like how I hard-coded the entire alphabet
Why is that?
>> No. 3085 [Edit]
File 167053148822.png - (695.48KB , 1620x3804 , carbon.png )
I just sort of wrote what first came to mind for part 1 and thought I'd have to rewrite it into something more efficient, but turns out it's fine even for the large input.

I guess it wasn't that hard, but it still took me a while...
>> No. 3086 [Edit]
File 167054078417.png - (82.09KB , 610x878 , aoc5-1.png )
>T-C truly has all kinds.
oh don't worry, I'll get filtered by some math-heavy puzzle soon enough.

>Why is that?
Iterating through a long hard-coded sequence of characters is much less efficient than doing a small number of arithmetic operations.
On the flip-side, it would always work even if Eric decided to change the priority values of the symbols around, and not just in the special case where the priority symbols are in alphabetic order.
>> No. 3087 [Edit]
File 16705532136.png - (23.93KB , 517x228 , aoc6-2.png )
>Pretty easy today
yeah day 6 was definitely easier than the crane thingy
>> No. 3088 [Edit]
File 167063220313.png - (245.13KB , 1080x1920 , aoc2-1_asm.png )
>> No. 3089 [Edit]
File 167065814672.png - (81.15KB , 576x534 , aoc10-1.png )
feeling right at home with day 10
>> No. 3090 [Edit]
File 167098431680.jpg - (285.59KB , 939x976 , aoc13-2clojure.jpg )
not quite filtered yet, just usually too busy to do these
>> No. 3091 [Edit]
File 167115550617.png - (97.21KB , 688x652 , aoc15-1.png )
I have an idea how to tackle part two, but I'm off to bed for now.

Did you all lose interest or why did you stop posting anything in here?

btw, I started doing AoC this year to familiarize myself with Clojure a bit more, and I really like this language. Dead simple syntax that nevertheless manages to be very concise, good standard library, can be used in the browser, on the JVM or as an interpreted scripting language, is open source, can use most of the libraries of JavaScript and Java, and is reasonably fast. I'll be using it for any serious dev work from now on.
>> No. 3092 [Edit]
I'm glad to see somebody still plugging away, bringing glory to T-C!

>Did you all lose interest or why did you stop posting anything in here?
Can't speak for the other of course, but I usually get to a certain point where I can't justify the amount of time I spend on an event instead of working on my actual projects. If I weren't a dumb-dumb, this wouldn't happen, but such is life. [I could read fewer manga, but that isn't happening.]

>can use most of the libraries of JavaScript
Are you referring to ClojureScript? Seems like a lot of functional/functional-esque languages can target JS in some way or another.
>> No. 3093 [Edit]
>I can't justify the amount of time I spend on an event instead of working on my actual projects.
Yeah I get that, I myself didn't start until day 6 or so and have done only about half the puzzles. Today's problem in particular seems like something that would take me more time to solve than I'm willing to sacrifice, so I'm not even gonna try.

>Seems like a lot of functional/functional-esque languages can target JS in some way or another.
Yeah but most of them lack some key attribute that I'm after.
Haskell: syntax too complex, dev community doesn't care enough about backwards-compatibility
Elm: only usable for front-end web development, which is a very small part of the software I write
Scala: not functional enough, syntax too complex
Kotlin: not functional enough, I had difficulties trying to use it as an interpreted scripting language, designed by JetBrains to shill IntelliJ and you're screwed if you try to use anything else

There are also things I dislike about Clojure, of course, but on the whole I'm just angry that I didn't discover it sooner.
>> No. 3106 [Edit]
File 167366375333.jpg - (93.57KB , 599x377 , twosum_reduce.jpg )
I've decided to try and make it a habit of mine to solve a programming puzzle from AoC or a similar site every Saturday.

I figure it's a good way to stop myself from forgetting programming languages that I haven't used in a while.
>> No. 3108 [Edit]
File 16737468612.png - (109.99KB , 789x885 , aoc7-2.png )
>> No. 3266 [Edit]
File 169509943487.png - (92.89KB , 600x742 , aoc2022-8gold.png )
here's my solution for day 8
>> No. 3267 [Edit]
File 169524539133.png - (103.58KB , 548x942 , aoc2022_9-2.png )
day 9. The second puzzle was tricky because my initial solution worked fine for the extended example, but not for the actual input.
>> No. 3269 [Edit]
File 16957089193.png - (75.65KB , 534x875 , aoc2022-14-2.png )
>> No. 3290 [Edit]
The Advent of Code approaches once more. Is anybody up for another round?
>> No. 3291 [Edit]
File 170062139441.png - (82.63KB , 596x957 , aoc12gold.png )
yeah I'll try to make time for the first week at least
>> No. 3294 [Edit]
File 170141869435.png - (90.04KB , 1748x512 , aoc2023day1.png )
Part 1 was easy, but part 2 was probably the hardest day1 puzzle of any year.
I wonder if Eric was trying to trip up ChatGPT with this.

You can still use the leaderboard in the OP for this year's calendar, by the way.
>> No. 3295 [Edit]
File 170152261647.png - (56.67KB , 1048x306 , AOC.png )
Day 2
>> No. 3296 [Edit]
File 170189886355.webm - (944.09KB , aoc2023day12.webm )
>> No. 3305 [Edit]
File 170257879120.png - (76.03KB , 800x786 , aocday14part2clojure.png )
today's puzzle was pretty fun
>> No. 3357 [Edit]
File daythree2023.txt - (19.28KB )

C dude here. Last year(2023) I tried Advent of Code again and surprisingly succeeded at first. I did the first day part 1 in around 2 days, then part 2 also around 2 days. I progressed this way doing all problems until day 3 pt1. When I finished it, it was already day 12 or something. I eventually got sidetracked and returned to this a few days ago to finish day 3 pt2. Well, I did the thing and my program apparently works flawlessly, I have it printing every individual value and manually checked for many numbers, but the fucking site gives me "wrong answer". How do I debug this? How to find the one fucking * that is causing me all this trouble? My program is still written in the same style as my 2022 attempt, pure C, parsing every single char at a time. It is too long and contrived and so I wouldn't want to force anybody to wade through the spaghetti swamp. I kindly ask any anon that have done this if they can check my input with their code at at some random lines(binary search recommended) so I can find the fucking line with the faulty exception.
>> No. 3358 [Edit]
Just run my input and say something like:
Up until line 40: Total gear sum value is: XYZ
Up until line 100: Blah, blah, blah.
Just a few lines so I can compare with my results.
>> No. 3360 [Edit]
>How to find the one fucking * that is causing me all this trouble? My program is still written in the same style as my 2022 attempt, pure C, parsing every single char at a time. It is too long and contrived and so I wouldn't want to force anybody to wade through the spaghetti swamp
Have you considered using a different language?
>> No. 3362 [Edit]
Ah, I bet you're the guy on SO who responds to every JS question with "use lodash" (or if this were the 2010s, "use jquery").

I looked at the file but it just seems to be the output, and I don't really want to read the AoC text to figure out what this is supposed to be and how to parse that. Probably you're failing on some edge-case, can you just get a solution off the internet, run it on that, and diff the results compared to yours?

View catalog

Delete post []
Report post

[Home] [Manage]

[ Rules ] [ an / foe / ma / mp3 / vg / vn ] [ cr / fig / navi ] [ mai / ot / so / tat ] [ arc / ddl / irc / lol / ns / pic ] [ home ]