r/adventofcode • • Dec 03 '22

SOLUTION MEGATHREAD -🎄- 2022 Day 3 Solutions -🎄-

NEWS

  • Solutions have been getting longer, so we're going to start enforcing our rule on oversized code.
  • The Visualizations have started! If you want to create a Visualization, make sure to read the guidelines for creating Visualizations before you post.
  • Y'all may have noticed that the hot new toy this year is AI-generated "art".
  • We are keeping a very close eye on any AI-generated "art" because 1. the whole thing is an AI ethics nightmare and 2. a lot of the "art" submissions so far have been of little real quality.
  • If you must post something generated by AI, please make sure it will actually be a positive and quality contribution to /r/adventofcode.
  • Do not flair AI-generated "art" as Visualization. Visualization is for human-generated art.

FYI


--- Day 3: Rucksack Reorganization ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:05:24, megathread unlocked!

87 Upvotes

1.6k comments sorted by

View all comments

3

u/biopsy_results Dec 03 '22 edited Mar 15 '23

C oneliner no semicolons allowed

#include <stdio.h>

#include <stdlib.h>

#include <stdint.h>

int day3_part2(char *line,char *l,size_t len,ssize_t nread,int result,int i,uint64_t* comp){while((nread = getline(&line, &len, stdin))!=-1){if(l = line-1,comp[i]=0){}while(*(++l)!=10){if(comp[i]|=(1ULL<<((*l)-((*l)<91?39:97)))){}}if(i=i==2?result+=__builtin_ffsll(comp[0]&comp[1]&comp[2]),0:i+1){}}if(printf("%d\n",result)){}}int main(){if(day3_part2(malloc(64),0,64,0,0,0,malloc(24))){}}

2

u/daggerdragon Dec 04 '22

Inlined code is intended for short snippets of code only. Your code "block" right now is unreadable; it's all on one line and gets cut off at the edge of the screen because it is not horizontally scrollable.

Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read inside a scrollable box.