« first day (2238 days earlier)      last day (2935 days later) » 

15:00
I'd be interested to see a solution to part two that doesn't require you to step through each block one at a time. Something which, if all the numbers in the input were multiplied by a thousand, wouldn't run a thousand times slower.
my solution – Part 1 was pretty nice, but then I had to add lots of things to keep track of the real positions which made it messy >_>
@Kevin it would have to use line intersection
Yeah, my thoughts exactly
"Question with 1,000 views" 2.8m awarded
"First question with score of 1 or more" 1.5m awarded
Is the first badge older or is this a bug? Or maybe there's just a lot of questions with many views that have negative scores?
@clickhere no.
15:01
Perhaps the first one can be awarded to a single person multiple times? I know some of them work like that.
@clickhere stackoverflow.com/help/badges/26/popular-question "This badge can be awarded multiple times."
@clickhere I can post 100 questions which all give 1000 views each, giving me 100 badges. But I can only have a single first question.
single first positive question
ah, i did not know you could get a badge more than once
cbg
15:04
It was a lot nicer before I had to add the if final is None block for part 2.
@AnttiHaapala nice, I forgot we start with seen (0, 0).
I like how yours stops going block-by-block once it finds the solution to part 2.
You're the closest to satisfying my bonus requirement of doing better than O(sum of distances in input)
I actually thought about transforming every R/L turn into a direction on a first pass
not sure if that would help
but maybe one could cancel out some movements that way
@Kevin as I said above^, I've always forked the code after part 1
Wish I could use pastebin from here!
I wonder what the optimal solution would be if the direction amounts were very large, or the number of moves very large
Current approach of adding each step to a set would not be viable
mass line intersection checking?
Yep, me and Antti considered line intersection a page or two up from here.
Now that three people think it's a good idea, it must be.
You have to do it now.
The naive approach is O((number of line segments)^2), which is not great
I wonder, though, if it's only viable to do that if n is low but the magnitude of movements are large
15:26
Maybe something with quadtrees...
Quadtrees are my personal version of "maybe if we reverse the polarity?"
I was just about to say, "Err, what?"
Running into problems with the segment approach -- let's say we start by first collecting all the segments. Normally we'd just check for points of intersection, which can be done using binary search trees (logarithmic time), and then we can just trace through the moves again until we hit one of those intersection points.
However, for each move, it's a turn + movement from the previous position. In other words there are intersections all over the place; they just don't count as "second visitations"
I suppose each final visitation point would need to be added to a separate set first
Wow, that second answer on the dupe you linked is ridiculously verbose and unfocused.
The problem is made somewhat more complicated because second visitation points can occur as a result of parallel overlaying lines, not just orthogonal lines. Consider the input "R1 R1 R2 R1 R10", where the first point of second visitation is (0,0), despite there being no right-angle intersections there.
Yeah
15:41
Something like "R1 R1 R1 R1" might fail to find an intersection if you're sloppy with your endpoints
Maybe for each line segment you collect, you strip the endpoints but still store those endpoints in a set -- that way we can check for intersections in two ways: Either a segment contains a point in our endpoint set, or we have a "true intersection" within the segments on the field
Hmm, might work.
Use floats, add 0.1 in either direction. :-P
Fight me irl
DSM
DSM
Morning cabbage.
Unfortunately this year I'm going to be in an "AoC-starts-at-midnight" time zone for much longer than last. :-/ Inconvenient.
15:46
I never left that time zone ;_;
grumble this PreventUserIdleSystemSleep issue on my laptop is making me very angry
I've been pretty far up and down the coast, but I'm not big on any other direction.
DSM
DSM
You just had me searching lists of cities by longitude.
The majority of my life is spent within ninety minutes traveling distance of the vast and endless sea. Because what if I wake up at two in the morning with a burning need to write a poem about the indifferent/merciless nature of nature and I need direct inspiration?
You never hear about boats hitting massive icebergs and sinking with considerable casualties in a lake
@Kevin They're just not cold enough, I guess. Or people have no sense of grandeur to put a giant boat with not enough life boats in a lake.
16:02
Just make the boat unsinkable, duh. It's the unix solution. Remember, the simplest solution to any problem is to not have the problem in the first place.
"Our boat is unsinkable because it's taller than the lake is deep"
Pundits go on to argue about whether it would count as sunk if it capsized, but the underside would be sticking up out of the surface of the water.
@davidism Yeah, I'm not surprised.
That's just another version of the ship. An in-version.
Yeah, I'm scraping the bottom of the barrel-- or ship, I guess. rbrb
16:07
Fun fact: the Lusitania is under 300 feet of water, but it's 787 feet long. If only it sank back-to-front, more than half of it would still be dry.
@Kevin That's crazy. But length vs. height is always weird.
most things don't sink back-to-front in shallower-than-long water
recbg
Like... I can drive over 600 miles in a day. If I drove that vertically, I would have passed the ISS by 380 miles.
16:11
not the same Robin Hood. But a great scene. I think it was edited to fit the quote better
@Kevin umm...why are the dudes standing there? That's not how you act when your ship's a-sinking
these guys don't know even basic sinking
Yeah they're definitely sinking wrong
Do you even sink, bro?
user6568562
That's the right attitude when your workplace is being destroyed and your boss is an asshole
this is fine.png
16:29
Someone's asked me to recommend books for a Python learner. Anyone have any faves they want to plug?
Learn Python the [I am forcibly ejected from the room]
I dunno, I just read the official docs a bunch until I stopped having to look up something every other line
That reminds me that I wanted to add something to the skeleton of our book
Invent With Python and Automate the Boring Stuff. wiley.com/WileyCDA/WileyTitle/productCd-0470068221.html is a good un if you're into games and such
Of course I just learned with the official Python tutorial, so I can't really speak to the quality
I don't have a lot of memories from my life before I knew at least one programming language
What about IntelliPaat?
SOOOO GOOOOOOOOOD
16:37
I remember getting math homework that was just one technique applied over different numbers and thinking "if only there was a way for me to not have to do this repetitive task manually"
I'm going to unlearn everything and learn from intellipaat
Intellipaat is too good, though. It will ruin every other tutorial for you.
I used to recommend Learning Python by Mark Lutz, but I only read like 20% of it and then started studying the sample code that was distributed with that book IIRC
grrr.....*Click will abort further execution because Python 3 was configured to use ASCII*
only happening in my IntelliJ
but not in shell
I hate dealing with this shit
Perhaps it's a fool's errand to seek out a perfect tutorial. Maybe the best thing to do is pick a fairly reputable one and then ask your peers about how it's wrong before you internalize anything
May as well harness the power of the most inexhaustible force in the world: people on the Internet nitpicking mistakes.
The only hard part, then, is integrating into a peer network that knows what they're talking about.
16:43
@idjaw probably an env var
Yeah. Right now, I have to set this in my default config:

LC_ALL=en_CA.UTF-8;LANG=en_CA.UTF-8
But I'm going to check why my IntelliJ is not set to something correct in the first place
Looks like Mark Lutza has managed to turn Learning Python into a boring and tedious text. Pity
DSM
DSM
@idhaw: Heh. I spun up a Fedora client the other day and had to put a bunch of those into /etc/bashrc just so that dnf didn't complain every time I installed something. :-P
@idjaw I'd print out os.environ or whatever it is from a sample script to make sure it's all getting set proper
@WayneWerner not even set! ugh...
16:48
\o/ Surprise!
hmm...more surprises are coming out. PYTHONENCODING is not even set
there are shenanigans that are moving closer to an ID 10T error
On your end or IntelliJ? ;)
my end...definitely my end
It's working in my shell....maayyybe there is IntelliJ fuckery happening, but, the fact that this is a very isolated incident (other co-workers not experiencing this), is pointing to a pebkac
it's already almost noon??
Today is not a good day for Intelli[thing]s
today is an un-intelli[thing]s day
17:02
paats idjaw on shoulder intelli-like
DSM
DSM
Aw, Marcus, I've missed your continual self-deletions. :-)
(removed :)
DSM
DSM
sopython became snapchat so once-a-year I barely noticed..
Kind of like log-free IRC :D
I wonder if we'll make it up to a full page of (removed)
17:16
I think I only have FOMO is when I can tell the difference between an admin removing a msg vs the user removing own msg.... the former drives me kinda crazy..... what was posted that made an admin remove it?!?!?!? we may never find out...
why? so in a couple of decades when robots or a higher intelligent being decides to parse chat room 6's history chat log, they will see a page of missing text, creating FOMO chaos?
Sure, why not?
17:32
codinghorrorcbg
Our codebase is horrendous, and undocumented, and a whole other bunch of sins. But it's cool, I just found the bit that Does Snow on the internal webapp homepage.
def snow():
     max_snow = 10000
     diff = 11
     flake_count = int(float(max_snow)/23**2 * diff**2)

     return flake_count
17:56
I cannot rightly comprehend the confusion of ideas that would lead to Python import variables from sys.argv
DSM
DSM
@Kevin: not only do I recognize that, I remember the random Kevin factoid I associate it with thanks to you. :-)
Which factoid? "The plastic tips at the end of shoelaces are called 'aglets'"?
DSM
DSM
No, although I do know their true purpose is sinister. The one about the fact that was in response to.
18:06
Aglets are commonly referenced as being analogous to telomeres
So now when I think of shoelaces I think of the inevitability of death :(
Everything is related to the inevitability of death. Eventually.
DSM
DSM
@KevinMGranger: the temptation to start using "finial" in conversation to be one of those annoying people who interrupts conversations to distinguish a trilby from a fedora is going to be hard to resist.
piglets and finals, what am I reading?
good thing I'm already a grammar nazi, I don't have to resist the pressure to become a vocabulary snob
Comma splice.
18:12
I never said I'm a good grammar nazi
@MarcusS Sentence fragment.
@Kevin Sentence fragment.
bzzt maximum recursion depth exceeded
^ metro-yamming-replacement boat in Hungary (cc @Antti)
@AndrasDeak whats your stance on the comma before an 'and' for a list of 3 or more items. for example: I have eggs, milk, and ice. vs I have eggs, milk and ice.
@MooingRawr you mean the Oxford comma? (nods knowingly)
DSM
DSM
Sep 21 '15 at 16:53, by DSM
Use of the Oxford comma is what separates us from the animals.
^ a perennial.
18:16
in Hungarian we strictly omit the last comma, but I've occasionally found that using that final comma might remove ambiguities when my sentence is a bit screwed up (mostly in papers)
@DSM i thought of the flower.... xD but I agree, but I also wanna be like my spirit animal ;(
I thought the metric for separation was whether or not one took whole bites out of Kit-Kat bars
so I generally omit the one before "and", except when it removes ambiguity (yeah I suck)
and I suck #2 -----------------------------^
import turtle

SCALE=3

directions = 'L1, R3, R1, L5'

t = turtle.Turtle()
t.penup()
t.goto(0, -200)
t.pendown()
t.left(90)

for d in directions:
    if d[0] == 'L':
        t.left(90)
    elif d[0] == 'R':
        t.right(90)
    dist = int(d[1:])*SCALE
    t.forward(dist)

turtle.done()
Hungarian is also pretty generous when it comes to commae, so I usually find myself randomly removing commas from my English sentences where I'd otherwise put one
18:19
If you wanna see what that advent of code path looks like
Most of the time I just stick commas wherever I would leave a pause if I were talking out loud.
(though you'll need to add the full input yourself)
Reminds me of Logo
does it:P
DSM
DSM
@WayneWerner: invalid literal for int. ;-)
18:20
@Kevin Most people do. I overuse commas like crazy - it takes me a bit of effort to stop doing that
Kevin Kevinson's Holistic Copyediting Agency
@Kevin so do you need a pause inbetween two short independent clauses with a conjunction inbetween?
@Kevin plot twist: copyediting as in "how to cope with all that bad editing"
@DSM wat? I don't get that -_-
Anyone else overuse dashes? I use them all the time -- makes it easy to separate stuff.
18:21
@MarcusS that's an en-dash and I approve of it
"The rain stopped, and the sun came out again." vs "The rain stopped and the sun came out again." ? they are short and you can say it with out a pause...
DSM
DSM
@WayneWerner: directions is a string.
I do a fair amount - though typically just one.
even if an em-dash with no space would be appropriate
oh, right
18:22
@MooingRawr It varies depending on how I want to convey my voice.
I had .split(', ') at the end of that
@Kevin go for Vin Diesel
Sometimes I'll put out these huge run-on sentences and not put any commas in between any of the clauses and it's completely intentional because I'm trying to give the impression of a six year old trying to tell a complicated story all in one breath
@Kevin Or Gilbert Gottfried
ADVEEEEEEENT OOOOOOOF COOOOOODE!
18:23
the Fizzy has been unleashed
Two men enter, two men leave, because programming is not inherently a contact sport
can't explain that
DSM
DSM
I'm interviewing a potential Python dev tomorrow. I'm seriously considering asking him an AoC question.
I'm gonna do it in Node.
@DSM I haven't quite done it yet, but I definitely want to turn one of the middle problems into an interview question.
18:25
what would programming be like if it was a contact sport....
How do I join the team?
DSM
DSM
You're already there..
nvm found it
Must still be connected from last year
@DSM How do you guys manage solving questions live?
I freeze up no matter the question -- huge hurdle for me
18:26
Oh hey Marcus, good to see you.
DSM
DSM
Wait, didn't you come in first once last year?!
Frustrating as hell
By "team" I thought Fizzy meant DSM's interview squad, and DSM was replying that he already had, like, a scarecrow dressed up as Fizzy in the chair next to him
@DSM I think he means during interviews.
@Ffisegydd You as well
DSM
DSM
18:27
@Kevin: that. is. awesome. If the candidate runs away screaming, he wasn't going to fit in anyhow.
"This is our cardboard programmer. He outranks you."
"Oh yeah, I've actually invented a few algorithms!" "Cool, solve this easy problem in O(n) time that any first-year could do." "Aackck, urgmgm, ajncdjskfnsdkjfdsf !!1111"
What if he is attracted to the scarecrow and gets distracted by the beauty, thus rending him incapable of coding.
@Kevin DING senpai found
DSM
DSM
Didn't we talk once about getting a Martijn plushie to use for rubber-duck debugging?
18:28
"Realistic shuriken action!"
@MarcusS you find those questions hard to answer? What about the "where do you see yourself in a few years?" or "what's your greatest weakness" type of questions ?
@MarcusS I worry about that too.
DSM
DSM
@MarcusS: well, for what it's worth, I let the candidate ask whatever questions they want about any coding task I set them. It's a conversation, not a quiz.
"Why do you want to work here?" Because money can be exchanged for goods and services.
@DSM each question is -1k quatloos of salary, right?
18:30
@MooingRawr Depends on whether someone wants an honest, introspective answer or a rubber-stamp answer
"When was a time you demonstrated leadership?" Dude, I can barely make my computer do what I say, let alone humans
DSM
DSM
And so far, I've only had to change my mind once on a candidate after ten minutes of speaking with him.
@AndrasDeak: say rather it's -1k quatloos for every question he doesn't ask, but should have..
@MarcusS I can never tell T.T like I would be honestly but not like brutal honest.... it's like a fine wire to walk on..
btw for advent of code, is there a differences on signing up with reddit vs github ?
18:33
I've only signed up with github so I don't know
I suck at grammar. I need help with grammar. Is this considered imperative:

Supports brand spanking new thing
DSM
DSM
No.
How would I make that imperative?
Support brand spanking new thing
?
@MooingRawr I think the signup method doesn't matter -- it just determines what your name links to when clicked
DSM
DSM
Yeah, like in a to-do list. "Go to store; buy Cinnamon Toast Crunch; eat cereal; stare into the singularity that binds cause to effect." Each verb as a command.
18:35
Got it! @DSM thanks.
Man your trips to the grocery store must be interesting
DSM
DSM
For bonus points you should have said "Get it! Be thanked."
haha
I'm trying to find official git message "rules". Does the subject have to be imperative?
"official"
DSM
DSM
@MarcusS: starlord plagiarism‌​.
haha
18:37
I have no memory of writing that, so I hereby release that sentence into the public domain.
303
A: Should I use past or present tense in git commit messages?

mipadiThe preference for present-tense, imperative-style commit messages comes from Git itself. From Documentation/SubmittingPatches in the Git repo: the body should provide a meaningful commit message, which: - uses the imperative, present tense: "change", not "changed" or "changes". So you'...

IMO past-tense makes more sense
"Added this feature, changed this line, etc"
But that may not be "official"
future tense "applying this commit will add this feature"
DSM
DSM
To be perfectly honest, this is one case where I have a tough time getting worked up about the inconsistency.
"Maybe I added this feature. Maybe I didn't."
18:40
If your message is more descriptive than "bug fixes", you're already doing well.
"Updated some stuff, idk"
DSM
DSM
Fifty-fifty I type git merge maybe at some point today now, thanks to you lot.
Quantum gits are still experimental; merge at your own risk
DSM
DSM
Until someone does a git clone, master is unresolved.
There is a slight chance you end up with someone else's repo
18:42
There are tools that enforce consistent styling throughout a codebase, right? They should be able to do the same thing for commit messages.
There was a debate between these two:
Supports adding a thing in the other thing
vs
Support adding a thing in the other thing
A little NLP, a little tense change, bada bing bada boom
to avoid more arguing over a freakin' letter in a commit message, I removed it.
$ git config alias.save
commit -a --allow-empty --allow-empty-message
haha
18:43
Why even bother with a "bug fixes" message?
Devil's advocate: so you can distinguish bug fix checkins from new feature checkins
Even better, you can find version-control-aware package managers that don't know how to handle empty commit messages when parsing
DSM
DSM
I guess it distinguishes between whether or not new functionality was added.. although I tend to encode that in the branch prefix, like bugfix/whatever or feature/whatever.
@Kevin you mean bug fixes from bug creations?
Exactly. Circle of life.
I usually stick the ticket id at the front of my commit messages, which easily disambiguates between bug fixes and new features, because their ids have different letter prefixes.
D for defects, and... I forget the letter for features. This is possibly a sign that I've been putting out too many fires lately.
Let's see... It's B for features. Yes. Logical.
18:49
bros before defects
Possibly it's D for Defects, B for Backlog items, and some third thing for Features, and it just so happens that this sprint has nothing but defects and backlog items.
It's too much work to navigate to past sprints, so I'll have to wait until next week to solve this mystery.
DSM
DSM
We use sprints here, but they don't fit our actual work patterns very well. Next year we're going to experiment with longer ones in the hopes of easing the frustrations. I've become "that guy who objects to process-for-the-sake-of-process", which can sometimes be an annoying role, but if someone doesn't play it they'll fill up all available hours here at NumberFirm with meetings about stuff instead of doing stuff about stuff.
I gots a star!
DSM
DSM
No, Fizzy still has zero stars. ;-)
For the last three meetings my boss has asked "are the changes for story B-123456 ready to push to QA?" and for the last three meetings I've said "yes" and I'm worried I'm caught in a time loop
18:54
Hopefully not a "Dormammu, I've come to bargain" type of thing.
I haven't completely ruled out the Vashta Nerada.
19:04
Now Fizzy has a gold star!
I have a star, too (if we're talking about the advent of code), but for some reason my formula doesn't work on the second one
The problem I had for the second half was: the crossover point doesn't necessarily happen at a spot where you change directions
Damn.
Yeah, cheers Kevin.
Did not consider that.
cabbage
that second half made me inefficientize my solution
cbg
19:09
I was drafting a letter to The Times stating that AoC#1 was clearly incorrect
Yeah that's seriously going to inefficientise my solution too
DSM
DSM
I was lucky -- from my memory of how the questions went last year, I knew I'd be wanting "path" information, broadly speaking, so I stored it. :-)
I think it was +2 minutes to store that for me, so meh
the worst part was realizing that I have to dumb it down
@Kevin ooooooh.
that would do it
My code for "change coordinates based on current heading" is not to my satisfaction
From last year's AoC, I knew I would misread the instructions at least twice, so I was able to keep my composure after the requisite failures
19:16
I used an Enum for kicks and giggles
Got my 2nd star
class Direction(Enum):
    north = (0, 1)
    east = (1, 0)
    south = (0, -1)
    west = (-1, 0)

    def turn(self, turn):
        assert turn in ('L', 'R')

        if turn == 'L':
            new_directions = {
                Direction.north: Direction.west,
                Direction.west: Direction.south,
                Direction.south: Direction.east,
                Direction.east: Direction.north,
            }
        elif turn == 'R':
            new_directions = {
                Direction.north: Direction.east,
It's probably less than optimal, but it was fun
def rotate(pos, turn):
    headings = ["N", "E", "S", "W"]
    d = {"L": -1, "R": 1}
    idx = (headings.index(pos[2]) + d[turn]) % 4
    return (pos[0], pos[1], headings[idx])
I took the smarty pants route and stored my position and heading as complex numbers.
rbrb, time to vacuum out my wallet go pick up the car from the mechanic vacuum out my wallet
19:17
Short and sweet - like a chocolate goblin.
Then you can rotate right and left by multiplying by -i and i respectively
@Kevin Nice
I'm pretty sure someone did that trick last year.
Yeah nice.
DSM
DSM
I just used pairs.
19:20
turnDirs = {"L":-1,"R":1}
deltas = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def day1(data, aocPart):
    dirFacing = 0
    x = 0
    y = 0
    visited = set((x,y))
    for turnDir, amtToMove in data:
        dirFacing = (dirFacing + turnDirs[turnDir]) % 4
        deltaX, deltaY = deltas[dirFacing]
        for i in xrange(1, amtToMove+1):
            x += deltaX
            y += deltaY
            if aocPart == 2 and (x,y) in visited:
                return abs(x) + abs(y) #part 2 answer
            visited.add((x,y))
Urgh complex numbers would solve my travel thing too. Screw you Kevin.
/OFF
it is probably old, but I just found it today :P
/ON
DSM
DSM
dpaste or gist, everybody.. plus spoilers! ;-)
Just another incentive to submit a correct solution early... Protection from spoilers.
Not much opportunity for the puzzle to get ruined if you solve it at 12:01 AM
wim
wim
19:49
how do you spoiler text in chat?
I can't figure out the sopython.com/spoiler interface
You type in the text and hit the encode button and copy the text that looks like [view spoiler](http://sopython.com/spoiler/YmxhaA%3D%3D) and paste it in here
wim
wim
It doesn't work
or use [spoiler](http://example.com "spoiler text") syntax
wim
wim
502 bad gateway
Lol --^
DSM
DSM
@wim: so you can't get to the site to create your own, or you can't follow links, or both?
wim
wim
I can create it, but can't view them
DSM
DSM
Huh, weird.
wim
wim
and the link for pasting into the chat is too long
It's 1608 characters long the link, chat won't allow it
19:55
Modern science has come only so far.
@wim your post is too big, it can't fit in a url, even encoded, apparently.
wim
wim
#!/usr/bin/env python3
import numpy as np

directions = 'R3, L2, L2, R4, L1, R2, R3, R4, L2, R4, L2, L5, L1, R5, R2, R2, L1, R4, R1, L5, L3, R4, R3, R1, L1, L5, L4, L2, R5, L3, L4, R3, R1, L3, R1, L3, R3, L4, R2, R5, L190, R2, L3, R47, R4, L3, R78, L1, R3, R190, R4, L3, R4, R2, R5, R3, R4, R3, L1, L4, R3, L4, R1, L4, L5, R3, L3, L4, R1, R2, L4, L3, R3, R3, L2, L5, R1, L4, L1, R5, L5, R1, R5, L4, R2, L2, R1, L5, L4, R4, R4, R3, R2, R3, L1, R4, R5, L2, L5, L4, L1, R4, L4, R4, L4, R1, R5, L1, R1, L5, R5, R1, R1, L3, L1, R4, L1, L4, L4, L3, R1, R4, R1, R1, R2, L5, L2, R4, L1, R3, L5, L2, R5, L4
you know chat markdown doesn't do that:P
wim
wim
So the source code literally fits, but the encoded url is too big? how does that work -
POST data doesn't have the same length limit as URLs.
The encoded URL is 1588 characters, so I guess our server is configured to restrict it to something lower than that.

« first day (2238 days earlier)      last day (2935 days later) »