« first day (2604 days earlier)      last day (2569 days later) » 

00:04
I've unraveled what I am trying to do.
00:54
evening cabbage
@Simon when I am tackling a problem, I find it helpful to describe in words what I want to do. For the most part, I don't worry about programming details such as "lists" and "strings". Instead I use everyday language. This helps me to focus on what I want to do rather than how to do it. I find making this distinction moves me towards a solution. Once I figure out the "what" I can then translate it into the "how" of specific python code.
Tomorrow on sopython: further people ask Simon what they're actually trying to do
@Code-Apprentice Good advice. In order to write any code you need to understand what you are trying to do.
01:09
@AndrasDeak What are you trying to do?
in the mean time...more Advent of Code!
I'm waiting patiently. How long did it take you to solve the problem?
Can I put my private leaderboard code on my profile?
Which problem?
today's problem took me about an hour
The Advent Of Code problem.
It took me most of the afternoon.
Although I spent only a few hours actually coding it was understanding the challenge that took the time
01:32
cbg cabbagesees and cabbagettes
How about a Advent Of Code room?
02:11
Rhubarb all.
02:22
Is there a story behind this cabbage (or Rhubarb) thinghy?
03:02
sopython.com/salad Scroll down to History.
03:21
hehe, there had to be! :-) Thanks
@Craig
@ReblochonMasque You're welcome. I'm new around here and was wondering the same thing.
04:43
aoc cabbage!
 
2 hours later…
06:40
What are you cbgs using for storage & retrieval of code snippets?
06:53
@ReblochonMasque I often use gist
Thank you; yes, I also use gist... I find gist a bit ungainly. I was using gistbox that recently became cacher, but I don't like the interface, I find the information is "dispersed" over a too large area, and requires too much scrolling...
What do you mean by "ungainly"?
sorry, maybe wrong term - I mean not quite convenient or easy to use.
I probably misspoke. I don't use gist all that often, but when I need to share small snippets, it is my go-to.
 
2 hours later…
08:45
hi was not there for a long
09:02
hey @XavierCombelle
I meant cbg!!
09:50
Question
I have this
In [12]: class bigPizza1(object):
    def __init__(self,size):
        self.size = size * 2
    def get_size(self):
        return self.size
And this
In [13]: class bigPizza():
    def __init__(self,size):
        self.size = size * 2
    def get_size(self):
        return self.size
in bigPizza1, I put the object not in bigPizza
yet when I do this
In [14]: bigPizza(20).get_size()
Out[14]: 40

In [15]: bigPizza1(20).get_size()
both of them are returning the correct result
what's the point of inserting object?
(in the class, I mean)
10:12
well what do you think the point is? :)
that's how inheritance works, and in python 3 there's no difference
in python 2 putting object there is the difference between "old style" and "new style" classes, the former being crap and the latter being what python 3 knows as classes by default
>>> class Foo: pass
...
>>> class Bar(object): pass
...
>>> dir(Foo())
['__doc__', '__module__']
>>> dir(Bar())
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
that's python 2 ^
in python 3 the two is exactly the same, so using object is either a mistake or for backwards compatibility with python 2
so in python3 you should only put such classes in the class definition which you want to subclass
Thanks for that
Python 3, day by day looks so much better than Python 2
perhaps it's not just Big Python's conspiracy behind everyone trying to push people to 3 :)
11:11
bonjour @AndyK
@AshishNitinPatil I agreee, althought it was not worth breaking the compatibility as brutally
if compatibility weren't broken I'd wager python3 would be worse off and more people would be using python 2 because "python3 is not better enough to merit migrating"
It has been a few rocky years, but it seems python 3 is on solid tracks now.
python 3.6 rocks
@XavierCombelle sometimes, you just don't have a choice :|
It's not like you can go back in time and hit yourself in the head for a dumb bad move.
11:37
Maybe there were no good options @AshishNitinPatil, and they had to choose between bad and less bad?
True, the lesser evil :)
 
1 hour later…
Jan
Jan
12:58
Hi! Just wonder is there any simple way to obtain equation from a thousand pairs of (x,y,z)?
I don't understand the question.
perhaps you mean curve fitting, in which case google "scipy curve_fit"
Jan
Jan
Like I have a thousand sets of variables (x,y,z) and I want to get the equation that can fit this dataset
yup, curve fitting or optimization in general
Jan
Jan
Thanks!
if it's a line: linear regression even
Jan
Jan
13:03
The problem is I don't know what kind of function it should be
that's probably where your job/assignment/task begins :P
Jan
Jan
haha yeah...
Generally, how do people come up with func part in "scipy curve_fit"
like the example
>>> def func(x, a, b, c):
... return a * np.exp(-b * x) + c
what I said before
you need to have a priori knowledge of your data, or if you don't, figure it out by looking at it real good
"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." - John von Neumann
Jan
Jan
haha ok!
thanks
if your model is complicated enough you can fit anything, but if you want to do science you should actually use the right model
of course if you only want to interpolate and your data are smooth enough, an elephant can do
there's no one answer to your problem, depends on a lot of details
13:22
Taylor series!
yeah, you can tailor any model to your data
14:23
I'm wondering, why is flask not defaulting to https/ssl security?
Well: to redirect everything to https or refuse http connections.
14:41
Because that isn't flask's job, more of the server, apache / nginx
 
1 hour later…
15:45
cabbage for lurky DSM
16:26
AoC has been pretty easy so far compared to what I remember of the start of last year.
DSM
DSM
@AndrasDeak: sorry, went off to do AoC! Morning cabbage for you as well.
I was expecting part 2 today to be "do the checksum, but for columns this time" or something like that.
It has been pretty easy. Had a nice solution for 2.1 which I then had to butcher slightly for 2.2
Doing checksums for columns would have been just as easy if you've accepted numpy into your life.
DSM
DSM
Yeah, today I wish I'd gunned it at midnight. I would have placed very well. :-/
(arr.max(axis=AXIS) - arr.min(axis=AXIS)).sum()
16:29
@Ffisegydd add your repo to the wiki!
That means I have to check things into git D:
Nah, you can use Mercurial like me. :-P
This year I put in the effort and used PyTest to run the examples and real input, it's nice.
Ah nice.
For the real ones I just do assert None == func(data) and then look at what the error is. Then I fill it in so it passes and it looks like I already knew the answer.
@davidism github.com/Ffisegydd/aoc will add it now
I'm 1 point ahead of @MartijnPieters on AoC right now, but only because I started day 1 earlier.
@AndrasDeak just plain awesome, just plain awesome
Timezones are an unfair advantage!
@davidism lol.
DSM
DSM
17:03
It's true. In two weeks I'll be moving to Mountain time-- I code much better at 10 PM than 12.
@Ffisegydd you've been away for a while
@AndyK I'm always around, watching silently o.o
@Ffisegydd in the shadows. lol
Unfortunately I need to go cook some dinner
waves SO constitution
@AndrasDeak what is this class Bar(object): pass, pls?
An empty class called Bar.
Anyway I really do need to cook some dinner.
DSM
DSM
Enjoy!
17:16
Meanwhile, I need to get breakfast.
Nachos, refried beans, pico de gallo, some roast chicken, salsa, sour cream.
DSM
DSM
Lunch for me, I guess..
@davidism I was more thinking what means the pass. I got the answer -> stackoverflow.com/a/13886195/2572645
@davidism I'm on two Python leaderboards you are on too.
Last years leaderboards are still active.
I'm guessing you are looking at this one: adventofcode.com/2017/leaderboard/private/view/188337
@AndyK the docs are your friend :)
17:23
On this one the ranking is different because there are more people on that board: adventofcode.com/2017/leaderboard/private/view/41753
I'm going to have to bask in beating Martijn while it lasts :p
@excaza thanks m8
@excaza Anyone in the EST timezone or thereabouts will have an easy time of it.
I am not going to stay up for an advent puzzle ;-)
I just got two colors of magnets, so I'm trying this out.
No puzzle is worth having to be awake at 5am.
17:35
haha, I'll take it
@AshishNitinPatil actually as far as I know, python core developers had choice, but it was the first time such move was made in the whole language landscape history, so when it was known it is such a pain in ass, it was too late
if I remember correctly, I had got a page where It was written that I was on the top x% users of python tags or something similar. If you know the address of this page you are welcome
18:15
I realized the largest problem is that people probably don't treat the EOL date as what it is: a heads-up so that everyone can port their code in time. Instead they think "hey, we've got 2 more years!", sit on their butts, and when the date comes, then start complaining that they still need support while they port their code base. This is all speculation on my part, but otherwise there'd be little python 2 left in the wild by now.
19:07
Well I can't solve today's challenge. I can't see why my code refuses to work but it does.
DSM
DSM
Did it pass all of the example test cases?
Nope. Still trying to get the answer on those.
Can I go for Day 2 tomorrow? I need more time to think.
DSM
DSM
Then you're still good. The frustrating part is when you pass all of the example cases and then have to read the description very carefully to find what you've missed.
And yes, you can catch up whenever you want.
And still get awarded the stars?
DSM
DSM
19:10
@Simon: yes.
Lucky. I'm still on the first part.
You can do the problems in any order you wish. A problem will always be there after it is released.
And you can take as much time as you need.
You can still go back and do the 2015 and 2016 sets if you want.
@Code-Apprentice Phew. Cbg
Might do later.
@Simon break down the problem. You need to sum over lines: check that each line works. If they don't: figure out why and how.
you need to view spoiler
Finally :P
Anyone here experienced with flask?
DSM
DSM
We should modify the room rules page to make it easier to link to specific rules. That way, when someone who's been around long enough to know better breaks one, we can be very pointed in our response. ;-)
Well I would directly ask for help on stackoverflow.com/questions/47511303/… but the question did change to "is this even possible".
And just looking around/working on the different aspects after a week I'm kind of "stuck".
19:56
wooow "What is the difference between the map function and decorators in python?"
Self-deleted... Oh well.
@paul23 perhaps you should take DSM's hint and actually refresh the room rules
DSM
DSM
Time to (belatedly) get on to the day's errands. Rhubarb for all!
rhubarb
rbrb DSM
Ah well, I'm basically wondering how, for flask, I can set the "static" folder to not be a subfolder of the location where the python application is run from, rather a sibbling/parent of this folder. - This should be really easy, or just not possible at all.
20:19
@paul23 I should give it as an answer, but did you try to set the root path as an absolute path ?
@paul23 I really wonder why one would want to have not standard flask layout
@XavierCombelle I wish to be able to have a single environment when working on the (js) client side and flask server side. So that means my project has a \js` folder where the "javascript" is located in (subfolders like \js\src`, \js\jspm_packages`, and a \server` folder where the server is located in. Now of course I could export the javascript to a subfolder of the server software: but that would require me to rewrite part of the config files.
Or at the very least require an "export" step always when running the server. (Just in case the javascript source has updated).
20:41
You don't want Flask then, there's no point in using Flask to serve a separate project.
Also, I can't reproduce your issue, Flask doesn't "expect" the static folder to be anywhere.
@paul23 you look that your environment is a mess.
@davidism Well ultimately the requests would require a decent amount of calculation, so I'm not using flask a way "to serve webpages" but rather "to allow a server to run python so it can be efficient in calculations".
OK, but that has nothing to do with serving some JavaScript files that are generated elsewhere.
Presumably you're using a JavaScript framework, use that framework's dev server for the frontend.
In production, you'd be using Nginx to serve the static files anywhere, so Flask's configuration of the static folder wouldn't matter anyway.
Btw the "overarching problem" is that u = flask.url_for("static", filename="index.html") when I started the app (using flask.run() for development) app = Flask(__name__, static_folder="static", root_path="../") returns "/static/index.html", instead of "../static/index.html".
21:06
cabbage
I think I'm using the requests_oauthlib module incorrectly. Has anyone experience with it?
My goal is to obtain the input file from adventofcode, which requires to be logged in using GitHub
I found requests-oauthlib.readthedocs.io/en/latest/… but I can't see where I provide my GitHub credentials here?
What I have so far is this:
@ByteCommander you should not try to automatize the download of advent of code input file. If you are doing such a thing, you probably doing advent of code wrong
from bs4 import BeautifulSoup
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import MobileApplicationClient as Client

CLIENT_ID = "7bb0a7ec13388aa67963"
AUTH_URL = "https://adventofcode.com/auth/github"

oauth = OAuth2Session(client=Client(client_id=CLIENT_ID))
authorization_url, state = oauth.authorization_url(AUTH_URL)

auth_response = oauth.get(authorization_url)
print(auth_response, state)
token = oauth.token_from_fragment(auth_response)
print("Token:", token)
@XavierCombelle Why? What should be wrong with that?
FYI wim has a library that caches downloaded inputs so it doesn't strain the server
I only download it once when I start with the puzzle and then save it as local file anyway.
Not polling constantly.
I found Wim's repo, it requires one to paste the AoC session cookie.
@ByteCommander, because it doesn't worth your time xkcd.com/1205
21:13
That would of course also be possible, but now that I started it this way, I'd like to get it working for science
sure :)
I will not help you in your craziness
Having knowledge in Oauth is a good thing anyway, so this is a nice opportunity to learn and practice.
Phh
no having knowledge in oauth is not a good thing in any way
oauth is a crazy protocol and has a lot of security flaws dhavalkapil.com/blogs/Attacking-the-OAuth-Protocol
That doesn't help if there is no other supported way.
21:53
Good morning cabbagees and cabbagettes :)
@MarcusAndrews you still want to win this year? :P
22:10
@AndrasDeak Brilliant. Not quite at the max() min() values yet though.
I'm trying to convert the table into a list and it's not working.
22:33
@Simon How are you trying to convert it?
I've been super slow on AoC this year. I've completed both days, but I'm behind both Kevin and Poke despite them only completing the first day so far.
Gotta make up for it when tomorrow's puzzle drops.
DSM
DSM
So far I'm doing them whenever it's convenient. If we're taking points seriously, I'm going to have to start schooling some kids. :-P
*grabs popcorn*
Nah, I just like the motivation of falling behind to actually do them.
Otherwise I'd probably forget.
Kinda hard to tell who's who on that leaderboard (though I'm not one to talk)
22:41
I mean, I should be easy enough.
Sure, most people are easy enough to guess, but some are pretty difficult
@AndrasDeak Yep.
my competitiveness so far has only been to the extent that I check the problems first thing in the morning...which happened to be at 11 AM today
DSM
DSM
I wouldn't mind beating this and this, at least once..
second was real close
wait, you're not even on the private leaderboard, are you?
DSM
DSM
I was earlier today.
22:47
I can only see you on last year's
DSM
DSM
I can't check from this machine right now, but I'll have a look later. I definitely remember seeing the new list.
Yeah, I don't see you either, DSM.
DSM
DSM
Hmmm.
oh yeah: I've been ill all week and I'm currently getting into a cold, so don't trust my judgement :D
@Craig I can show the script I have so far.
DSM
DSM
22:54
Ah. Looks like I had joined Marcus' old leaderboard.
as I said, I saw you there ;)
Woooo, now I'm losing even more. ;)
DSM
DSM
I misinterpreted the "last year's" comment, I guess.
:40285982
Go ahead. At least the part that you're stuck on.
Here goes:
The problem: It does not make a new line for the values on the line underneath.
DSM
DSM
23:03
for i in a: b.append(i) definitely isn't something you want to do.
Have I asked you whether you've read any tutorials yet?
Nope.
Have you read any tutorials yet?
Loads.
okay
(I should've asked "python tutorials" :P)
23:04
I can send you a few links if you want. : )
nah, I'm fine, thanks
Why do I have a suspicion Pandas may solve my problem?
You have the data as a sting. You could save it as a file and read the file one line at a time, or you could split the string into individual lines.
You don't need anything that complicated.
it's just that you seem to have an unusual approach to programming in python, and I thought this was due to you not reading any tutorials that teach idiomatic basics. Like the official one
@Simon I think you should stick to native python for the time being
That is probably because I started C
DSM
DSM
23:07
Seconded. Libraries aren't very useful until you understand the basics.
It's basic isn't it?
part of it is, I'm afraid
Damn I'm really going to kick myself when I solve this.
so which tutorials have you read?
I'm starting to get a bad feeling :P
(of course regardless of tutorials you yourself have to decide to not write C code in python)
the more you go with the design of the language, the easier your job becomes
Tutorials: For starters the link you gave : P
23:10
have you finished that?
Nearly. I was thinking I should cover it a second time as soon as possible.
OK. Then it probably is all about your preconceptions :)
C will get you nowhere in python
Your telling me!
if you find that something simple takes a lot of work: odds are you're using a wrong approach
Cabbage
23:12
cabbage
Damn. Write a tomato file. readlines() should solve it.
Hmm, I'm trying to find something in the official tutorial about string splitting, but I can't
@Simon What's with all the blank lines? A few blank lines can enhance readability, by separating groups of related lines, but when you space out the code like that it makes it harder to read.
I'm not sure what you're trying to do, but if you want a 2D list of integers from that a string you can do:
[[int(u) for u in row.split()] for row in a.splitlines()]
he's learning the basics
@Simon I can't find anything in the official tutorial right now, unfortunately. But you should take a look at str.split and the rest of the string methods. Now, keep in mind that the library documentation is not the best place to start learning the basics, but it does help to look around and see what methods are available and useful for built-in types
@AndrasDeak I can understand that thank you.
Great. All the decorations are now falling down.
Back in a second.
23:18
that's what you get for setting up your Christmas tree so early
unless you really meant your tree because I was only trying to joke
Nah some tinsel.
I hope you don't have any cats. Cats and tinsel are a bad combination.
None luckily. Right back to the problem.
Q: What's better than JavaScript and PHP? A: Cassis! "My friend's project, Cassis, is a subset of JS and PHP that works the same across both languages (plus a supporting library to get a bunch of functions working in both). You can write code in Cassis and deploy it both in browsers and servers." :D
DSM
DSM
I'd recommend six weeks of hard labour but some crimes are their own punishments.
23:27
but_why.gif
Right I do need one tutorial. Reading those single line codes.
And before anyone says it's just 2 for statements
and split() and a.splitlines()
DSM
DSM
The line I mentioned earlier,for i in a: b.append(i), is wrong in a few ways. It's important to know why.
cbg
@DSM Why?
I wish we could design our own AoC metric. I can't stand the points relative to 12:00 EST. I was lucky that when I got off a plane last night, I had the time to relax and answer the questions. However, I do like the idea of timing the second question. You only get access to the question when you've answered the first. That means, everyone has access at a time they are sitting down and have already gotten the gist.
23:39
@PM2Ring oh, and we're discussing day 2 of Advent of Code
DSM
DSM
@Simon: try it. Add some prints in there to see what you're actually doing.
Not just yet I'm working on a solution. Will try it in a few minutes.
@DSM if we were taking points seriously, I'd see that 15 people are tied for first (-:
only if you order by stars :P
Yes.... which I'm implying is the most relevant metric available
23:41
metrics won't solve anything; we just need the problems to go public at midnight UTC >:)
i.e. 20 minutes from now :D
DSM
DSM
I was stuck on one of last year's for a day or so, and was quite annoyed when I found out that a lot of people got the right answer with a wrong solution which only worked by fluke.
oh yeah, good times
also the one that Martijn solved on paper
that might or might not have been the same one
assuming you mean the one that we were debating for days afterwards
DSM
DSM
I remember the emotion, not the details. :-)
@AndrasDeak Rightio. I hope the code I posted wasn't too much of a spoiler.
23:44
meagar 68th globally
@PM2Ring oh, not even close :) I was just adding context
I'd also rank higher the ridiculous amount of discipline exhibited by the "real" coders who have posted their answers on github with full test suites. As opposed to my hacked one-liners
Don't you want to join us? The problems go live at a convenient afternoon time Down Under
@piRSquared what makes you think they didn't get the stars with hacked one-liners first? :P
DSM
DSM
One reason I don't post my solutions is that I don't want to (1) spend the time to do it right, or (2) live with the shame of my hackery.
@AndrasDeak Probably not. I'll just watch from the sidelines, like I did last year.
23:46
I decided to leave my day1 one-liners
@DSM Laurel... I share that sentiment
after all, I don't have a programming license that can be revoked
@PM2Ring I noticed that (re: last year), so I was expecting that :)
well I'm looking at the polished code because I'm learning a lot from it. Thanks to those putting it together.
@piRSquared I second that. I also appreciate seeing the different approaches to the solution.
You guys are having a group for aoc?
23:52
try to find out ;)
unless you're on mobile, in which case check the starboard

« first day (2604 days earlier)      last day (2569 days later) »