/aocg/ - Advent of Code 2018 General #15

Saved From Page 10 Edition

Previous thread: adventofcode.com/
>Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.
You need to register with an account but you can appear as anonymous.

Private leaderboard join code:

368748-e33dcae3

People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.

Alternative leaderboard for those waiting for inactives to be kicked from the first:

208834-4a1a9383

Attached: bearlain.png (639x480, 349K)

Other urls found in this thread:

adventofcode.com/
adventofcode.com/
onlinegdb.com/HkQe8hNJN
twitter.com/NSFWRedditVideo

ferst!!!1

cringe and bluepilled

you bet

Attached: point.jpg (601x625, 44K)

how hard have these been so far for someone who say only programs in python and is self taught

can i get a job if an employer sees that I did this?
no education or experience btw

python is the best language for AoC as you get shit done the quickest with the least effort required

... that being said, all easy so far, just very basic string manip and algorithms.

>string manipulation
easy
>algorithims
err shit

they don't have to be good for you to pass the test, but people do like to optimize their work and it's a good learning experience

python is good because it has a lot of handy tools, but you'll still need to figure out what you need to build.

>adventofcode.com/
>http
the website is https

adventofcode.com/

Attached: 1543973153978s.jpg (208x249, 7K)

That's me. The puzzles have been very easy but if you're a codelet of similar levels you can still find a fair amount of challenge in them.

yeah man just just email your solution to tonight's puzzle to tim cook and zuckerberg, i'm sure they'll get you set up

>not already using https everywhere
they deserve it.

ftp://actualautism.lmao

Python should be banned from AoC

>using an extension for common sense
lmfao
rude

I'd do it in C but I haven't reached the part of the book yet that explains how to implement hash maps.

I think what should be done instead is a refactoring of scoring, some people don't know much more than Python, it is *the* "I don't program" language of today and schools widely adapt it. It just so happens you can make things in it ridiculously fast.

it redirects all http to https whenever possible, it's convenient and you can't fuck it up

Top guy is doing it in ruby IIRC

"ridiculously fast" as in prototyping than yeah for sure, but I cringe every time I have to open up a python based GUI tool. Electron runs better ffs.

thanks man, I've been looking for a job for ages now

you got a college degree or some kind of portfolio?

depends on what electron program you're talking about, some can be really optimized like vsc then there's shit like atom or even discord. for gui, python is just not suitable and people who use it to make games, god, why.

i have a crappy video game I made a few years ago on my github, other than that it's barren, but I have been working on two video games in the last couple years that aren't on there
none of that gamemaker/godot/unity crap though

what you mean? raw C/C++?

You should learn marketable skills my dude

>I'd do it in C
do it faggot

i've been doing them in C++ with zero experience, though I know Java, C#, F#, Python, Lisp. i try to finish fast, but that's not my goal. learning is.

it's a good way to learn a new language because
a) you've worked through the problem
b) you can then read how the wizards did it
c) ???
d) profit

first in python, then lua with love, and now C with sdl
what should I learn? I also don't want to make video games anymore, it sucks

>what should I learn?
well what do you like to do? web? mobile apps? back/front end development? compilers?

all I've done is video games, I know I would hate webdev from looking into it awhile back, at least front end
I guess compilers? I liked doing all the file parsing I did so far with my games

nah for real I haven't even got pointers down yet, I really want to practice more shit in C outside of the K&R exercises but I find anything real just requires knowledge I don't have yet, and I don't want to half learn it by reading the minimum amount to get something to compile, I want to read through it properly when I get to it in the book.

>I haven't even got pointers down yet
why they're just variables that point to addresses and tell you what's there with the * operator don't be scared lol

Agreed.

Ruby too. And I fucking love Ruby.
Either that or leaderboards need to be split up by language category if you want a "leaderboard".
Like if you do everything in Python you get put on the "python" leaderboard, but if you mix languages you get put on the "mixed" leaderboard, and for every answer you give you have to include the source file.

Just throw CVs until you get an interview with some HR dumb retard that doesn't ask a single coding question, and answer "yes" to everything

Why would I use Ruby in 2018? Not attacking, I genuinely don't know where it's used these days. It looks kinda cute

Attached: 1499476457227.png (694x262, 51K)

i'll have you know that I can fizzbuzz

Would be hard to verify without compiling it through their website.

Else you'd have to make the source file public so people can report when someone uses a python script in the C group.

But then that's a whole other headache.

I know /what/ pointers are I just don't know how or when to use them in programs yet, and when I get to chapter 5 of the C book, I will.

It's comfy.
That's literally it. Ruby on Rails is great if you want to shit out a website in 3 seconds (seriously, there's a 'scaffoled' keyword that generates the entire skeleton for a POST ready website), but Ruby in general is pretty fucking slow and doesn't have the tremendously robust library support Python has to make up for it.
JRuby is pretty fast (JIT JVM compilation of Ruby code), and Ruby itself is a very, *very* smartly designed language that is probably the closest thing to a truly OOP language since Smalltalk
But it's slow as shit, has no decent GUI framework to interact with (not even a good TK one), and suffers mildly from an inherited philosophy of Perl's MTOWTDI with aliasing and operator overloads.

It's a fantastic scripting language but you don't really wanna do much serious with it.

If you could be about on par with githubs language detection that'd be enough. You'd have to lump C/C++ together though since it's really hard to determine if they're different based on lexical scans alone.

Mutability.

To everyone that helped me on Part 2 of Day 1, I did it! Thanks for your help!

What do you think about Crystal (compiled Ruby)?

if you know array indexing you know pointers because a[0] is *ptr and a[1] *(ptr+1) and so on. once you read up on them you will see how easy and useful they are, along with references.

can someone post their input and answers for part 2.
I'm realizing there might be an edge case with my program that my input (and the sample input) just happened to perfectly miss

A pointer points to a memory address.

This mean it's value is simply the memory address.

When you prepend it with " * " (like *ptr) you are asking C to give you the value stored at the memory address. When you prepend it with " & " (like &ptr) you are asking for the address where the pointer itself is stored.

So just think of it like * goes forwards and & goes backwards.

For instance suppose you have:

int a = 3;

Then asking for "a" is asking for the value of "a" which is 3. And asking for "&a" is asking for the memory address where "a" is stored.

*ptr = value at memory address
ptr = memory address ptr is pointing to
&ptr = memory address of ptr

a = value at memory address
&a = memory address of a
*a = doesn't mean anything because 3 doesn't point to a valid memory address

imagine also a pointer to a pointer (call it ptrptr)

ptrptr = memory address ptrptr is pointing to
*ptrptr = memory address ptr is pointing to
&ptrptr = memory address where ptrptr resides

Just remember backwards (&) and forwards (*).

would *&a compile?

So could the guy that got hired at a friend's company.
>Friend: So, you're a senior engineer?
>New guy: Uh, I once took a course of JS
>Friend: How the fuck did you get hired?
>New guy: Just said I was hot shit at the interview. Based civil service job, I can't be fired, #makingit

You will mostly use pointers to mutate data in a function.

All arguments given to a function are passed by value, meaning the function gets a copy of the thing you passed to it, not the actual thing. This means that if you want an integer to be changed by a function, you can't do:

void square(int num) {
num = num * num;
}

int x = 5;
square(x);


x would still be 5 after calling square(). Instead you need to do:

void square(int *num) {
*num = num * num;
}

int x = 5;
square(&x);


Now the function takes a pointer to an integer, and you pass the function the pointer to x. x will be 25 after calling square().

Apparently it does. It'd be fairly pointless to do but it works as expected.

Attached: whew.png (440x498, 35K)

Made a mistake in the second box, but you get the point.

onlinegdb.com/HkQe8hNJN

I always forget to do that but it's much nicer than
int x = 5;
x = square(x);

$ cat dragondildo.c
#include
#include

int main(void) {
char *a = malloc(1000);
char *b = *&a;
printf("a: %p\nb: %p\n", a, b);
free(a);
}

$ gcc dragondildo.c -oowo && ./owo
a: 0000000000706580
b: 0000000000706580

very important with passing large structs since it's by reference(the memory address which is only 4-8 bytes) compared to by value(literally copying over the entire struct)

that's more a case for references
void square(int &num) {
num = num * num;
}

int x = 5;
square(x);

Not mature enough.
Ruby's saving grace has little to do with the actual language spec, really. It was designed to be comfy, and holy FUCK is it comfy.
Which is why Elixir exists. "What if we took Erlang and wrote it like Ruby?"
The result is a wonderfully distributed functional language that's a pleasure to write, read, and use.

Crystal could be dope. The fact it doesn't allow for null-ref at compile time (much like kotlin) is great, and if it's as fast as they say it is with Ruby-style do block's it could be crazy powerful with such expressive, fast code.
But I'm not holding my breath. It doesn't have backing from a major company and that's usually what it takes to get a new language some traction. Go had Google behind it (with the authority of Rob Pike no less) and has seen quite a bit of success. Rust is backed by Mozilla and used by precisely fucking nobody but Mozilla. Clojure took off because it's JVM ready functional programming, and Java is too ancient to readily adapt that paradigm. React.js is more popular than Vue because it's backed by Facebook, despite Vue being less retarded.

If Crystal manages to accomplish what it wants and, more importantly, has a robust, built-in multi-threading or multi-process system, it'll be great. Until then it's just a toy language.

user is using C, not C++ though.

int square(int i) {
asm("mov %rdi, %rax\n\t"
"imul %rax, %rax\n\t");
}

Devops stuff. It's the spiritual successor to Perl.

Attached: 1543945202599.png (1000x1000, 712K)

should I do today's challenge in awk?

void
square (int *num)
{
(*num) = (*num) * (*num);
}

int x = 5;
square(&5);

>implying x86

kinda wished I used substring parsing desu senpai

Attached: tfw.png (903x262, 17K)

WHERE IS THE CALENDAR IMAGE

Attached: asm.png (344x399, 12K)

Based

Napping before the next challenge drops. See you guys in a few.

This is some abstract shit without context

>C++
>String parsing
God help you.

you'll be late and you know it

Best of luck, I'm playing vidya to keep myself awake for it. What I'm playing really needs focus.

This is my first AoC, so I've been doing 2017 for practice. Just did days 13 & 14. Both felt easy but still took me like 1/2 hour each just to get everything worked out. Really wish I had a faster speed

Great, Jow Forums is fucking breaking now. I can't update the thread even though I know there are new posts in it.

making a new post that he cant see

It fixed it when I posted, no fucking clue what happened

Attached: devious pepe.jpg (470x595, 201K)

whats the best way to solve day 4?

with a puter

>doesn't understand what a cache is
These are the people participating in this shit?

I know what a cache is.

dont know

Reminder to post "solved!" a few minutes after the challenge has been released, regardless of your progress or even having looked at the problem.

essentially recreating the table they use for the example is the most elegant, imo, but it's not the most efficient

Reminder to post "FUCK" literally the second the challenge is released, regardless of your progress or even having looked at the problem.

reminder that using python is literally cheating and you should feel bad about it.

reminder to use the best tool for the job, whether it's python or APL

and people will use it anyway, and win, that's why competing without using python is simply asinine. just have fun and enjoy that the execution speed of yours can't dream to match theirs UwU

reminder that it's just a fun competition, so use anything you want.

as long as it's functional :^)
and I don't mean that it works

Being reasonable? Get out.

I hope yesterday was the first wall and today will be comfy
I'm tired and have work tomorrow

>inb4 more text parsing

I feel like the last couple of days have been ez mode and today the real brainlet filter will drop.

Is this what we call a filter?

Attached: firefox_2018-12-04_22-00-11.png (685x108, 6K)

i mean we aren't even a week into december, if they dropped the hard shit already they wouldn't be able to have a nice difficulty curve

srs binis

more like meh i can't win and i need sleep

they've had 23 hours to do #4

Today’s will be easier right?

Attached: image.jpg (1022x731, 493K)