« first day (2986 days earlier)      last day (1962 days later) » 
00:00 - 23:0023:00 - 00:00

12:27 AM
What does (1, 2) < (1, 2, 1) evaluate to
 
wim
1:01 AM
have a guess
 
1:36 AM
What is the best way to crop 850 images in mass (each image will be cropped 70 times at the same coordinates)
I'm thinking about using Pil and I found this sample code: `
# import the Python Image processing Library

from PIL import Image



# Create an Image object from an Image

imageObject = Image.open("./iceberg.jpg")



# Crop the iceberg portion

cropped = imageObject.crop((100,30,400,300))



# Display the cropped portion

cropped.show()`PIL
Should I bother destroying the image objects from the array once I create them?
also how do I save the images once they are cropped?
can I pretend this chat is a duck?
yes, quack
No need to create an array can just do
Image.open(filename).crop((100,30,400,300))
sorry i'm retarded
ignore this
 
wim
2:13 AM
🦆
 
2:28 AM
cabbage
 
cbg
 
2:57 AM
Is this how one properly uses an index in a for loop?
for i, line in enumerate(f):
        img.crop((100,30,400,300)).save(outDir+i)
It feels very clunky
 
import os

out_dir = '/home/will'

for i in range(10):
    file_path = os.path.join(out_dir, "these_files_{0}.png".format(i))
    print(file_path)

/home/will/these_files_0.png
/home/will/these_files_1.png
/home/will/these_files_2.png
....
I usually do something like that...
 
for i in range(10):
     file_path = os.path.join(out_dir, "these_files_{0}.png".format(i))
     print(file_path)
is better than doing a for each loop with the enumerate thing?
 
In your case you are iterating over a list of images, I'm guessing, and just need to remember to format the integer so it can become part of a file path and use os.path.join() to build file paths
 
this is what I have
 
No, that was a simple example showing the iterative file path construction... nothing fancy
 
3:07 AM
for filename in os.listdir(directory):
    img = Image.open(filename)
    crop image or whatever
I need to iterate through a text file of coordinates to crop for each image
 
yeah if it works fine, but os.path.join was made for that
 
how to past code so that it stays indented and everything?
 
paste it, then ctrl k
 
with open(coords) as f:
        for i, line in enumerate(f):
            img.crop((placeholders,30,400,300)).save(outDir+i)
It just seems like using enumerate is a really clunky way of adding an index
Maybe even more clunky then just creating a var called i and increasing it once per cycle
 
Ha, I thought you were concerned with properly constructing the file paths in a dynamic way but you just care about the counter? I think you can do what you want with regard to the enumeration aspect.
 
3:19 AM
Nah I don't care about the paths, I don't need to see or deal with the paths I hope
 
I guess it might be an interesting question to evaluate performance with respect to incrementing a counter versus using enumerate(). It would have to be an extremely long loop to matter. I personally like enumerate but when the "for whatever" line is already long incrementing a counter looks better IMO
 
3:43 AM
@AnttiHaapala trying to. will work on getting some of the harder ones today.
last I checked, we are neck-to-neck at 16 hats a-piece :D
 
 
2 hours later…
5:37 AM
@coldspeed now both at 17 hats :F
 
@AnttiHaapala Nice pizza hat!
 
 
1 hour later…
7:04 AM
cbg
 
cbg
 
 
2 hours later…
8:43 AM
Does somebody know if it is a bug that this works:
photo = ImageTk.PhotoImage(image=Image.open("bloom-blooming-blossom-36753.jpg"))
                    canvas.create_image(0, 0, image=photo, anchor=tkinter.NW)
but this does not
canvas.create_image(0, 0, image=ImageTk.PhotoImage(image=Image.open("bloom-blooming-blossom-36753.jpg")), anchor=tkinter.NW)
I guess it has something to do with lazy evaluation or so not sure
but I find it very strange
 
8:55 AM
cbg
welp, we got to the 'analyze assembly' part of AoC again. Now I wish for the ascii back.
 
what is cbg?
 
it's cabbage
 
9:13 AM
:D
 
@Hakaishin More or less. The problem is that tkinter doesn't hold a reference to the PhotoImage, so it gets garbage collected if you don't save it in a variable.
 
ah I see. super unituitive at first.
 
9:38 AM
Is tkinter actually still being developed? Is it worth to make a bug report with this? Or is it dead anyways? Or is this the intended way it should be(seems wrong)=
 
 
1 hour later…
10:41 AM
cbg
@Hakaishin there's a "big" "red" warning in the tkinter docs about this
I think...
Actually, what I remembered is green and is in the "tkinter book" (also linked from the official docs): effbot.org/tkinterbook/photoimage.htm
 
@AndrasDeak I'm shocked (and a little impressed) you remember a detail like that from the tkinter docs, of all things
also, recbg
 
for what it's worth it's not in the docs ;)
 
Cabbage all, bugrit.
 
cabbage
 
11:39 AM
cabbage
 
@AndrasDeak It is nevertheless a known and accepted characteristic of tkinter. Maybe a docs fix?
 
it may also be in the docs but I couldn't find "the" docs in 2 minutes so I stopped
what I found on python.org only mentions PhotoImages as an aside
 
12:15 PM
@AndrasDeak :D Yeah this was my problem too :P I just found a online article. Reproduced it and mine didn't work. Then I copy pasted it and it worked :O But now I atleast know why :)
 
hey guys, wondering if possible to get only the € (euro) sign from multiple pages something with selenium ? 'cause the € sign is present on every page I'm scraping...without specifing the xpath, or css selector or or or... something that would work for all urls ? Sorry if too confusing
 
12:36 PM
Hello all! I'm wondering if there's a way to get my question reopened as it is not a duplicate of what it was marked a duplicate of. I already edited the question to make this more clear but it's still closed now. This question I'm talking about is: stackoverflow.com/questions/53815727/…
 
is there any way to directly access the values of class that has __slots__? similar to how one can do bar.__dict__.values()?
@Ghorich do you need all control characters?
 
@MisterMiyagi As far as I can find, no
only the usual {var: getattr(o, var) for var in o.__slots__} hacks
I think if you use dataclasses you'll get a function
>>> from dataclasses import dataclass, asdict
>>> @dataclass
... class A:
...     __slots__ = ('a', 'b')
...     a: int
...     b: int
...
>>> a = A(1, 2)
>>> asdict(a)
{'a': 1, 'b': 2}
jup, you do
i think the overlap between "classes you want to write as dataclass" and "classes you want to write with __slots__" is quite big, so if you can use 3.7 that would be an option
 
12:57 PM
btw when ppl in this chat write aoc do they mean the company or something else I don't know?
 
this is what they mean: adventofcode.com @Hakaishin
 
aaaah^^
 
@Arne thanks, it seems dataclasses also uses getattr similar to your suggestion behind the scenes
 
@Ghorich I can't tell if the dupe still applies so I pinged the user who hammered it. Hopefully they'll respond
 
Does anybody know of one unified auth service? It doesn't do anything else than auth. I hope this comes soon all these login things are so annoying
And yes I know the corresponding xkcd ;)
 
1:05 PM
What's your preferred interface to write Python in?
 
Thank you @AndrasDeak!
 
@TimStack vim
 
I've heard good things about PyCharm. Thoughts?
 
I've heard good things too
 
I am using pycharm, & very happy with it.
 
1:14 PM
Great
 
I have used WingIDE for nearly twenty years now. I like that it's built in Python rather than Java, and appears to be rather less heavy. Most PyCharm users I know (including those in my own team) appear happy with it, though.
 
2:05 PM
Am pycharm user, am happy with it. it's still very fast to start up and has all the things you need for good python coding, and isn't too bloated with stuff that is useless
@MisterMiyagi Huh, I'd have thought the python devs have access to darker magic than that :p
 
2:16 PM
Don't know whether PyCharm does, but Wing has the ability to manage development on remote sites connected by SSH, which is useful for working on multiple hosting providers, for example. But that's a pretty unusual requirement.
 
pycharm has remote interpreters, actually storing the code you are working on on a network drive isn't officially supported but works ok-ish (if you hack your own fs notifier together so the IDE still knows when a file changed on disk e.g. due to git checkout)
 
actually this is a reason to check out wing @holdenweb I need exactly this and Pycharm is super annoying about it and no it does not really work ok-ish. Without writing custom code(which is not my definition of working, since then EVERYTHING works) it does not work at all
thanks for the tip :)
Otherwise pycharm is fuego
 
2:39 PM
cbg
Looking for suggestions re: using inspect vs. traceback to look at the current stack (to log caller when exception condition occurs)
 
traceback
 
hi,
I've got data in 30 second, 1 minute, 5 minute, 10 minute intervals -
is there any simple trick to stretch this to 30 second intervals using say pandas :D
like 1 minute data can be repeated 2 times, 5 minute 10 times, 10 minute 20 times.
 
2:55 PM
@AnttiHaapala Take a look at resample, or asfreq. Either might work depending on the situation. I think both may work if you're stretching out. If you're aggregating, resample would be better.
 
per @coldspeed
df = pd.DataFrame(1, pd.date_range('2018-12-01', freq='10T', periods=2), ['A'])

# df.asfreq('30S').ffill()
df.resample('2T').ffill()

#                      A
# 2018-12-01 00:00:00  1
# 2018-12-01 00:02:00  1
# 2018-12-01 00:04:00  1
# 2018-12-01 00:06:00  1
# 2018-12-01 00:08:00  1
# 2018-12-01 00:10:00  1
 
cabbage, i think i found flask bug where i can publish ?
 
google flask bug
 
@VictorAlvarado See if is already listed here: github.com/pallets/flask/issues
 
3:07 PM
Interesting bug?
 
@Hakaishin If you can't get it to work with either, you can also try looking into connecting to a remote python process with pdb via ssh
 
but this would be mainly for debugging and not normal development right?
And as I heard this is supported by wing, so I will give it a shot next time
 
Yeah, you're right. In that case you can ignore my comment
 
i think is a bug, but maybe can be bad implementation of my
 
Has anyone here ever stumbled over a page python-course.eu? It's as far as I can see, horribly bad. I only read two articles so far, one on slots and the other on packages.
slots: it's what you use to prohibit dynamic attribute generation
packages: are directories with __init__.py files in them
Sounds as bad as LPTHW
 
3:27 PM
The bug is in here:

https://github.com/pallets/flask/issues/3036
 
@Hakaishin Pleasure. I only recently used the remote debug facilities - they are awesome!
Being ab le to interactively debug code on a remote processor through a GUI is just occasionally incredibly useful.
 
@holdenweb Now the big question - in PyCharm, I can attach to a local process running my Python script separately. With WingIDE remote debugging, can I attach to a remote process?
 
@coldspeed nice
@coldspeed though in this case since I don't have the time index calculated yet, even my manual method will sort of do...
 
3:47 PM
Ooh, going to have to look at the documentation for that one.
 
probably yes, since the former feature is more advanced, so I assume they can attach to a running remote debugger
because right now it is a pain, I have a copy on the server and on my pc. Edit on my pc copy the code via mount and sublime onto the server run and test and then code on in pycharm again.... It's close to a nightmare
 
It appears so: would wingware.com/doc/debug/remote-debugging answer your needs?
 
@Arne I’ve not seen that, is it a bad thing to dynamically create class attributes? I had that thought the other day but didn’t really know how.
 
4:12 PM
usually yes, but completely depends on the situation
my problem is that it's completely misleading. slots aren't used to prohibit that, they exist to allow faster attribute access and limit memory usage
like every single python tutorial that includes them will tell you
 
encodings suck!
 
Or this great post by AaronHall
 
what's the problem with encodings?
 
but they just completely miss the point in their tutorial and instead advertise something that I'd call a side effect
 
look here for what sucks about them: docs.python.org/2.4/lib/standard-encodings.html
 
4:19 PM
yeah, I don't see the problem
 
wim
I don't know.. I find ascii encoding quite helpful (easier to read than bytes directly)
 
Standard Encodings.... there are a million and it is sometimes really hard to tell which one are you dealing with
 
wim
except for a few special words like cafe f00d
 
this is so annoying
 
If you're guessing an encoding, you're already doing it wrong
 
wim
4:24 PM
you shouldn't have to tell. the bytes themselves can not tell you. the person who handed you encoded data has to tell you what encoding they used...
 
It doesn't really matter how many there are, because you just have to know which one is being used
 
have you ever worked in reality?
the person who gave it to you haha
this is not how companies work
you get a bunch of shit and then try to fix it
 
so, people suck
 
and technology enables them to suck
if there were one encoding there would be no possibility to suck
 
wim
@Arne the overlap between dataclasses and slots is so large that's it's hilarious how poorly they work together. try to add a default value for one of the dataclass fields and watch the entire thing fall to pieces!
 
4:29 PM
@wim it's really sad
 
this is what I like about pythons formatting syntax rules. It makes the code somewhat clean if you can run it. I have seen terribly formatted c++ code and ofc "technology" is never fault it is always people. But some tech makes it easier for people to fuck up and others doesn't
 
But from the gh discussions it seems that there are serious technical problems to get them to work together
 
does anyone understand the concept of an adjacency list and a disjoint set and coloring
 
wim
@Hakaishin that's the premise of UTF-8 ironically
 
@holdenweb Will definitely check this out, thanks!
 
4:32 PM
I know... But utf-8 was invented about 40 late
 
@Rick many people do
 
cbg
@Rick yes
 
wim
you gotta set some rules when writing software. a good one is to never accept raw bytes without some information about the encoding. even if you think you can guess the encoding, refuse to. even if the caller tells you the wrong encoding, don't correct them. Python 3 made this all a lot easier by allowing you to work entirely in decoded domain (str) and prevent implicit conversions.
 
@AndrasDeak @Code-Apprentice I am trying to find a redundant edge in a directed graph. I was thinking about using an adjacency list to color the child nodes
 
What do you mean by "redundant edge"?
 
4:42 PM
do you know any csv-transforming library, like csvkit, but csvkit doesn't exactly support these as library transformations
 
How are you representing the edges if not with an adjacency list?
 
@Code-Apprentice a->b, a->c, b->c. in this case b->c is the redundant edge
 
@Rick why is it redundant?
 
4:45 PM
well I need to return a rooted graph of N nodes
there might be multiple answer but I need to return the one that occurs last
I was thinking I would use a hash as an adjacency list to color the nodes
 
@Rick are you using a graph framework such as networkx?
 
@Hakaishin Good programming languages make it easy to write good code; bad ones try to make it hard to write bad code.
 
@MisterMiyagi no, but even if I was I would still need how to go about solving this correctly.
The problem is that I need to know what Data structures to use to solve this problem.
from a conceptual level.
 
@holdenweb with the two often overlapping substantially
 
if this was an undirected graph, this would be easy to solve.
 
4:55 PM
Oh yeah, the two sets aren't disjoint, and even Python has it warts - though fewer, now 2 is almost dead.
 
I was thinking You could use a disjoint set, and union find, but the brain fizzles out trying to go that route
 
5:08 PM
sounds like you need something like Dijkstra for all nodes
 
word I will use more this week: "ramifications"
 
even if the graph frameworks do not offer a function that does exactly what you need, you can probably copy most code
 
well breath first will suffice for visiting all the nodes @MisterMiyagi
 
an adjacency list for searches is really easy to do as Dict[node, Set[node]]
you should be fine having an additional stack (for nodes to visit) and a set (for nodes already visited)
 
@MisterMiyagi I would use the adjacency list to color the children of the root node the same at the parent
the stack isn't necessary I can abstract that away with recursion
 
5:13 PM
@Rick I still don't understand what a "redundant edge" means.
In your example, why isn't a->c redundant instead of b->c?
 
edges = {'a': {'b', 'c'}, 'b': {'c'}, 'c': {'a', 'b'}}
reached = set()

for from_node in edges:
    edges[from_node] = edges[from_node].difference(reached)
    reached.update(edges[from_node])

print(edges)
 
Mostly I'm asking because if you can explain clearly what terminology means so that others can understand, then you are a step closer to understanding the problem enough to create a solution.
 
wait a second, that only works for some kind of graphs
 
@Code-Apprentice let say you have a road that travels from point c-> b but you don't want to waste money building a direct route if one already exists. in our case there is already a route from c->b through "a"
 
33 mins ago, by Rick
@Code-Apprentice a->b, a->c, b->c. in this case b->c is the redundant edge
Let's use this example in order to communicate better. I don't see any route here from c->b
 
5:17 PM
remember this is a directed graph so direction matters
"a" goes to "b" and "b" goes to "c"
 
so in your example I just quoted, there is a route directly from a->b->c, so the route directly from a->c is redundant, right?
 
'c' does not go to 'a' but 'a' goes to 'c'
 
so b->c is redundant
 
5:21 PM
because you can get to "c" from "a"
 
If you remove b->c then you only have a->b and a->c. Now there is no way to get from b to c.
 
b to c is redundant because your starting point will always be "a"
 
okay...are you saying you want a spanning tree?
 
ya
 
if I understand correctly, you want a subgraph which gives paths from a single node to every other node, right? If so, that wikipedia article should give you an algo for it.
either BFS or DFS
either will give a solution that satisfies the criteria. No need for coloring or disjoint sets.
 
5:25 PM
it seems the graph libraries have that as well
 
I not sure if it's as simple as a spanning tree
 
anybody have any thoughts on batching django querysets to avoid SQL Server 2100 parameter limitation?
0
Q: Django Queryset Batches

Cameron TaylorI have a Django app that runs on SQL Server. SQL Server allows a maximum of 2,100 parameters in a user-defined function. I have a Django view with a queryset that should return 10,000 results when called: def result_list(request): results = MyModel.objects.filter(~(Q(importantField='') | Q(i...

 
a spanning tree will just return you a subset.
and a subset is just a graph that does not take into consideration direction
for a graph consisting of three edges will return us 3 configurations of a tree which does not put us any closer to a soltuion.
This problem might just be too hard.
 
@Rick a spanning tree is a subgraph not a subset. The article I linked seems to discuss general graphs, but the ideas can be translated into digraphs. You still do a bfs or dfs.
 
5:43 PM
if we have a vertex of n elements there are n^n-2 trees and a vertex set V of n elements so the set of isomorphic trees from a 3 vertices graph is 3. so there are 3 isomorphic trees based on cayley's formula. thus a subset of 3 trees for a 3 vertex graph.
 
n8_
I love SO's rules for posting. How don't know how many times I go to write up a post, which then helps me think through the problem more methodically and BAM! Solved it before I finished writing the post lol
 
@Rick I don't understand how that mathematical fact applies to your problem. The BFS and DFS algos will still solve what you are asking for.
both will find one of the spanning trees
 
you can only use BFS and DFS to traverse the tree. but it won't help me isolate the redundant edge.
 
The redundant edges are those that are in the original graph but not in the set of edges of the tree.
but do you really want the redundant edges? or do you want the subgraph that remains after you remove them?
 
I only want the redundant edge.
 
5:50 PM
so the algorithm is 1. Build a spanning tree with either BFS or DFS 2. Take the set of edges from the graph and remove all edges from the spanning tree.
The set of edges that remains is the set of all redundant edges
 
I am considering your approach,
maybe I can laire a spanning tree onto a directed graph breath the first search, to find the missing edge.
 
6:07 PM
That sequence of letters doesn't form any kind of meaningful sentence.
 
hmm...finding an edge to complete the spanning tree is a different problem
@Rick Do you mean "layer" instead of "laire"?
 
@Unihedron oh hey, I see me!
 
*layer
 
@Rick are you trying to remove a redundant edge in the existing set of edges or to find which edge you need to add to create the spanning tree? These are two entirely different problems.
 
Wow, you're patient
 
6:14 PM
@code it's a directed graph, an edge on its own has no relationship to the total number of edges.
 
yah, I have that sometimes.
 
I'd have given up long ago
 
@Rick yes, that is true of a graph as well
 
@Ghorich reopened by who closed it originally
 
patience is a virtue, and a rare one at that
 
6:16 PM
@Code in an undirected graph there is an explicit relationship between the edges and the vertices.
 
There are many rules that govern and undirected graph.
which makes them easier to reason about.
 
and why are you telling me this?
 
@Code-Apprentice thanks for the help, you helped put the problem into perspective. Also, I appreciate the effort. helped me clarify the problem for myself.
 
good. That's the important thing in solving any problem: understanding the problem.
 
6:22 PM
The next time I search for "blah blah blah site:stackoverflow.com" on google, I hope to be able to find this question. — coldspeed 5 mins ago
retained for posterity
stackoverflow.com/q/53857013/4909087 unclear and OP doesn't seem keen to edit
 
wim
Did anyone bother to code day 19 puzzle in a generic way?
In previous years I'd prepared a patch file, patched the assembly, and then run the optimized code on the virtual machine. But it was a lot of work to get right, and I'm not really sure it was the intended solution for AoC in the first place - maybe you're supposed to just be lazy and hacked the registers directly..
 
6:44 PM
@wim the only thing I could do with it is figure out what it does
no chance of anything even remotely generic
 
wim
@MartijnPieters I think your disassembly for day 19 is wrong
You found the view spoiler
Since your data had view spoiler but that was just luck.
 
8:01 PM
^ that was pretty neat
 
8:25 PM
@wim my prose is wrong, yes. I'm actually tinkering with the code, a massive detour over a stack of iterators calculating divisors.
 
What is the ::= operator in the python documentation? Is that some actual operator or just something in the documentation?
 
Isn't that in the grammar description?
definitely not a python operator
hmm, no, the grammar only has colons docs.python.org/3/reference/grammar.html
 
So it's like a notation for defining computer specs, is my understanding
 
OK, I wasn't completely off the mark
 
8:37 PM
> Each rule begins with a name (which is the name defined by the rule) and ::=.
@malan yes, it's basically Backus-Naur Form
> In computer science, Backus–Naur form or Backus normal form (BNF) is a notation technique for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages[.]
 
Huh, TIL
Thanks
 
@MartijnPieters what controversial did you post?
 
cabbage
 
9:04 PM
Anyone happen to know why ` assertDictContainsSubset(expected, actual, msg=None)` is deprecated? And more importantly is there an alternative? I don't want to compare strict equality.
 
What library does that belong to?
nevermind, found it
Does that do more than just all((k,v) in actual for k,v in expected.items())?
 
py2 unittest
I assume that it will report which keys fail the test. Where as self.assertTrue(all(...)) doesn't provide very helpful output when it fails.
 
Probably because the arguments are confusing.
 
what do you mean? which arguments?
 
The warning about the arguments being confusing was added in the same commit that added the deprecation notice.
 
9:18 PM
"expected" and "actual", I had the same thought when I was reading what it did
 
oh...that was in response to my original question...gotchya
 
oooh, set methods on dict views, I had no idea
 
yah, maybe a.items() <= b.items() will work okay for my use case
 
In [25]: {1:2, 3:4, 5:6}.items() - {1:2, 3:4}.items()
Out[25]: {(5, 6)}
big fat TIL
 
9:20 PM
items() is handy for iteration, too
for k, v in d.items():
 
well yeah, that's obvious
I daresay that's the primary use case for dict.items()
 
prolly
 
@AndrasDeak That's pretty cool. So you can do like intersections and unions without special functions
 
I had no idea they supported set operations. Then again it took me a long while to learn the same thing about Counters (a'la multiset)
 
I keep seeing a caveat "if values are hashable"...not sure why that's a requirement. Are the elements in a set() required to be hashable?
 
9:23 PM
yup
according to my understanding hashing is the magic juice that makes set/dict lookup O(1)
 
that might be a problem for me...some of the values in my dict are also dicts
 
that refers to keys
values can be anything
Besides, you don't need a set, you need dict.items(). Right?
 
Set operations on items() views need hashable values. I think that's the only part of the dict implementation that needs hashable values.
 
Oh, my bad in that case, sorry
also this is weird, isn't it?!
 
yah, I think calling d.items() won't be a problem, but when you start doing operations, then there might be errors due to nonhashable values.
 
9:30 PM
yeah, I just tested it, really surprising
you don't even have to do a valid operation
In [39]:  {1:[2]}.items()
Out[39]: dict_items([(1, [2])])

In [40]:  {1:[2]}.items() - 1
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-bbe14a995c4b> in <module>()
----> 1 {1:[2]}.items() - 1

TypeError: unhashable type: 'list'
 
(Actually, I think it's okay to use the set comparison operators between two items views with unhashable values, but using the other operations, or using set comparison with an actual set, needs hashable values.)
 
I guess the moment you call __sub__ or whatever it hashes the values
 
wim
in pytest that would be assert is_submap(d1, d2). I hate those unit test methods.
 
@wim yah, I'm leaning towards doing that based on different variants I found on SO
 
wim
9:41 PM
btw the stuff you are discussing about dict_items was asked by me / answered by martijn 4 years ago on here Inconsistent behaviour between dict.items and dict.values .. I thought it was weird too initially but Martijn convinced me otherwise
(on second look, maybe I'm misunderstanding which part you thought was weird)
 
@AnttiHaapala ?
 
wim
basically the items view is cheap to make because the pairs can be keyed off of the keys alone
 
I find it cool that dict.items supports set operations, but I find it weird that consequently the dict needs hashable values but only for that
I understand why this is necessary, but it's still weird
 
wim
there's some subtlety there for sure
you want the set operations to take into account both the keys and values. but you don't want to have to hash the values upfront, if you don't need to.
 
I understand
 
wim
9:50 PM
@MartijnPieters there has got to be a better divisor finder than this
 
Why? That's pretty efficient. Though n**0.5 should be faster :P
 
wim
it's a horrible approach for finding primes so I assume it's a horrible approach for finding divisors too
there's probably a similar sieve thing?
 
Eratosthenes' sieve works because you can exclude multiples once you have a prime divisor. That's not true for generic divisors.
Or...can you exclude multiples if a number doesn't divide the target?
yeah, you can!
If 3 doesn't divide a large number then any multiple of 3 won't divide it either. Meaning you're right, you could use a sieve.
 
wim
Yeah and I bet you'll need to write it for Project Euler eventually ..
they are much less forgiving of brute force than AoC is
 
Yup, though you might get away with a prime sieve plus combinations (I may have done just that in a similar challenge)
 
"I'll need a research team and five years"
 
wim
Let's see if anubhava bites, he's a regex wizard
 
Wow, 9543 posts (9542 answers) in the .htaccess tag.
 
re-cabbage
 
10:20 PM
@wim The question is ambiguous and OP doesn't know it
 
wim
10:57 PM
there's gotta be a better argsort dupe than Finding the Index of sorted elements in Python Array
even the result in the question is bogus :-\
the order is wrong, and wtf is array even here
is it numpy or not?
 
00:00 - 23:0023:00 - 00:00

« first day (2986 days earlier)      last day (1962 days later) »