« first day (3464 days earlier)      last day (1476 days later) » 

1:34 AM
I'm having Heroku/discord.py problems
It posted two mornings ago, but it's not posting now. I have made no updates to the codebase since then.
 
wim
all the redundant 2019 and 2020 answers here stackoverflow.com/a/57864567/674039
 
 
1 hour later…
2:47 AM
@wim I decided not to del-vote stackoverflow.com/a/58054119/4014959 since it's the only answer there that shows how to make a generator with start & step parameters. OTOH, it is reinventing the itertools.count wheel...
 
 
2 hours later…
5:03 AM
@wim When do you actually need nextafter in practice? I never knew it existed until now.
 
5:15 AM
@wim No, the answerer is just being unclear, they need to spell out the usages: x += x*sys.float_info.epsilon or x = x * (1+sys.float_info.epsilon). Otherwise people might naively try to add: x + sys.float_info.epsilon, which would fail due to underflow on floats with absval > 1, and be too large on floats < 1.
@wim How much language-specific knowledge can we expect mods to have? So they can tell if an answer's bad or dupe?
@inspectorG4dget Uhh, seriously :S? And to think people complained about starring things.
 
 
2 hours later…
6:57 AM
Short question: What is the unit of cumtime columns in output of cProfile, I couldn't find that in docs.I guess they might have presumed that the reader would assume that it would be in seconds but the problem in my case is for couple of functions total time > cumtime of some functions.
How it can be?
 
Are those functions recursive maybe?
 
No, they are not.
BTW Does that make sense in recursive case?
Perhaps, I am misunderstanding something.
239241 function calls in 0.076 seconds
` ncalls  tottime  percall  cumtime  percall filename:lineno(function)`
`1    0.000    0.000    0.078    0.078 mazeD.py:192(four_pass)
 
Presumably due to rounding errors
 
total time is smaller than cumtime there
 
@Aran-Fey Yeah, is that normal?
 
7:06 AM
Yes. Have you read the description of both of those columns?
 
If it attempts to sum up 239241 instances of a tiny value to come up with cumtime, the rounding errors are likely to add up enough to explain 0.002 seconds
 
Nothing much is given here
@roganjosh but there are two such function with 0.078
 
> tottime
> for the total time spent in the given function (and excluding time made in calls to sub-functions)
>
> cumtime
> is the cumulative time spent in this and all subfunctions (from invocation till exit). This figure is accurate even for recursive functions.
 
7:21 AM
good day everyone
 
What's the quickest way to pack and unpack a numpy array of bools into a single integer?
 
@user76284 I'm not sure I follow what you mean. arr = np.array([True, False, True]) then just arr.sum()?
 
That doesn't preserve uniqueness.
 
Ok, well if you're asking for the quickest way then could you give your current approach to clarify?
 
What you described is not invertible.
I'm looking for a fast way to encode bool arrays as integers, so they can be decoded later.
But a Python for loop doesn't seem very fast.
Currently looking at pypi.org/project/bitarray.
which has functions ba2int and int2ba.
 
8:29 AM
@user76284 arr.dot(2**np.arange(arr.size)[::-1]) from here
 
b.dot(1 << np.arange(b.size)[::-1])
Looks good with bitshift. Thanks.
 
Ah, oops, I missed the faster timings :)
 
@user76284 I'd expect it to be faster with a step of -1 in arange, rather than using slicing.
 
8:56 AM
what's a good tutorial on np slice notation?
 
@Todd Honestly, I'd say the docs themselves are pretty strong here
I'm not sure what a tutorial will add without being "fluffy"
 
thougth someone might have come across one that lays it out in simply and memorably
i don't get to use numpy in any projects I have, but i have an interest in learning a lot abou tit
 
9:19 AM
@Todd me too.
 
@MisterMiyagi not sure if you're aware, so apologies if so. If you type "[mcve]" (sans quotes) in a comment, it will auto-expand out into a hyperlink to the docs
 
@Todd numpy absolute basics tutorial on the new docs site
Work your way up from there
 
@roganjosh thanks for this info. it's new for me
are there a list with those shortcuts ?
 
@αԋɱҽԃαмєяιcαη saves keystrokes and searching for links on your part :) You can also use [edit] if you want to suggest the OP fixes up their question and that will link to the edit window of the OP. It was Andras that pointed these out to me, not sure if there are more
 
@MisterMiyagi why no repro of all things?
 
10:00 AM
:D when i was new to the site. i was asking myself are it's really people do this part of "does this answer your question" but after time i noticed it's automatically posted as a comment once you close vote as dupe. even in that time i was post it manually
 
Now i understood how quickly things such as edit or mcve posted.
 
@AndrasDeak oh awesome, thanks! Also, that exposes something basically illegible with the new dark theme :)
 
@AndrasDeak thanks , that's very helpful
 
cbg
 
How is it going?
 
@AndrasDeak a brainfart lumping "no reprex" together with "no repro"
@AndrasDeak nice to know, and thanks @roganjosh for mentioning "[mcve]" as well.
 
user10984358
Is using two stacks like stack_one=[1,2,3] and stack_two=[-1,-1,-1] the same space as stack_all=[(1,-1),(2,-1),(3,-1)] from a space complexity point?
 
user10984358
if the word stack warrants different answers then want I meant is are they both O(n) space
 
@MisterMiyagi ah!
 
10:17 AM
@TheNamesAlc I think the latter is slightly bigger in practice. As in 10 pointers versus 8 pointers.
 
@TheNamesAlc they are the same size so same complexity. There's no n for us to tell if it's O(n)
 
user10984358
10 pointers as in 3 for tuples one for list and 6 for the ints? just to be clear
 
Just ask yourself: what happens if you keep multiplying n by 10? Simple as that.
@TheNamesAlc red herring
 
user10984358
if context is needed, I am trying to do a "Get minimum element in stack" at constant time, so I was using a second stack to store the minimum values, it passes the test cases but saw some people doing using the list of tuples method, thats why I wanted to know what was better
 
Doesn't help at all.
 
10:21 AM
What MisterMiyagi said. But it's negligible
 
I have three apples. How much flour do I need for my pie?
 
user10984358
sorry :/ its a leetcode question I was just abstracting what I thought was enough
 
Ooo... there's a remake of Child's Play... wonder if that's worth a watch...
 
@TheNamesAlc you always have n pointers for the content. two lists are 2 pointers. one list + nested tuples is 1 + n//2 pointers. Oh, you can add the additional tuple headers as well, for n // 2 PyVarObject.
Remember kids: Never forget ref counts when calculating space complexity!
 
@TheNamesAlc Is there some reason not to use a heapq?
 
user10984358
10:31 AM
The only constraint was getting the minimum element in constant time, I just went with two stack approach, will try using heapq, good to learn alternate ways, thanks!
 
@TheNamesAlc constant time. So why are we talking about space complexity?
 
Yesterday I wrote some demo code that uses a library I'm working on (to figure out what I want the library's public interface to be like), and I thought "hey, this code looks pretty good!". Today I'm working on making the library work as expected, and everything's a mess. Hooray.
 
user10984358
I just wanted to know, I was browsing other answers and some didnt use two stacks but rather the list of tuples, so I wanted to know if mine was better in space, since the usual follow up question is whats the space complexity
 
@Aran-Fey at least it looks good ;)
@TheNamesAlc do you understand time and space complexity and big-O notation?
 
user10984358
to an extent yes, what am I doing wrong here?
 
10:34 AM
@TheNamesAlc not trying to figure out the complexity? Not giving an n when asking about O(n)?
I know you saw the concept last year
Oct 27 '19 at 19:52, by Andras Deak
@TheNamesAlc you should ask them if they mean time complexity, space complexity, or something else
 
user10984358
yeah still learning lol
 
You always 1. take n, 2. compute/estimate complexity, 3. look at scaling for large n (asymptotics)
Have you done that in that order?
 
user10984358
not really, I just compare my answers and see if they used more lists or variables than I did
 
user10984358
not a good means of approximation
 
@TheNamesAlc so do that! Now! And see what you get. If you get stuck you'll be able to ask a good question.
 
user10984358
10:38 AM
thanks for pointing it out
 
This is how you learn, not by asking wrong questions about vague code
We'll be more than happy to help if you do it right
 
user10984358
will do :)
 
In terms of actual RAM footprint, Python objects tend to use a fair bit of space. You can use sys.getsizeof to see how much RAM stuff uses, but you have to call it recursively to determine the size of collections.
It can be informative to compare the sizes of small tuples, lists, sets, and dicts. The differences may be surprising if you aren't aware of how dicts & sets work. ;)
 
(But as long as the fluff for an n-length container is O(n) it should not affect space complexity)
 
@AndrasDeak Indeed! And that's why I was careful to use the phrase "actual RAM footprint". ;)
I guess I should also mention that if you use sys.getsizeof on a custom class instance, it'll tell you the size of the instance, but of course it won't tell you how much RAM the class object itself consumes.
 
11:12 AM
@AndrasDeak shhhh, don't spoil the solution
@PM2Ring challenge mode: write a generic size estimator based on sys.getsizeof that correctly handles range
 
@MisterMiyagi they'd need to learn how to do it in the first place...being cryptic only works if the querent has the skills to get the correct result. Giving the precise answer to a clearly wrong question is only fair if we're talking about a troll. But perhaps I've been teaching for too long.
 
11:27 AM
@AndrasDeak done
 
thanks :)
 
11:40 AM
@AndrasDeak I admit that my teaching style of "throwing wrenches until they realise it never worked in the first place" may not be ideal for leetcode derived problems. :/
 
Closed
 
12:11 PM
Hi I am trying to scrape the first two sections values in this website https://web.bet9ja.com/Sport/SubEventDetail?SubEventID=76512106
I want to scrape 1*2 and DOUBLECHANCE values for that I have written selenium code as follows
https://pastebin.com/VPzHnHc1
but I am not getting anything
Please help me anyone
 
12:27 PM
@G.Lakshmi you've already got my response there, also please check room rules , so you will noticed the following If your question is eligible for a bounty (>= 48 hours old) and hasn't received a useful response, then you may link to it.
@G.Lakshmi that's to be noted for your future questions
 
@αԋɱҽԃαмєяιcαη where's the question?
 
OK, so it's a sock puppet account.
 
No its my friends account @AndrasDeak
she asked me I am trying using selenium
 
12:31 PM
@αԋɱҽԃαмєяιcαη @αԋɱҽԃαмєяιcαη Cant I do this using selenium once see my code
 
@G.Lakshmi you can do it with selenium but you've to wait till the element present within page, check
 
yes I mentioned the timeout also in my code
 
on the site, you were asking about requests not selenium
 
Yes once see the pastebin code if you dont mind I had mentioned
now trying with selenium
 
don't use space within class name ! to be as SEItem.ng-scope
also i noticed the class name is SEOddLnk.ng-binding
 
12:39 PM
The other day I almost learned how quaternions work
 
but? :)
 
https://pastebin.com/EAnHW52z see this once please getting error as
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".SEOdds.c3"}
(Session info: chrome=80.0.3987.163)
 
@G.Lakshmi let me check.
 
I can more or less derive the math from the first principle of "what if we had j and k instead of just i" but I can't imagine 4d space so I have basically zero intuition for its uses
 
@αԋɱҽԃαмєяιcαη Ok
 
12:41 PM
@Kevin Uses? What craziness is that? :P
 
Like when I'm puttering about with vectors I'll often come up with wacky tricks for dot/cross products but I don't think I'm going to have any quaternion-related lightbulbs in that way
In any case it's nice to have a method for rotating vectors that doesn't go wonky around the poles
This might be the first time I learned something from a Youtube video that I couldn't have learned more effectively from a written article
 
Was it numberphile or some other?
 
sorry i was late because i tried several time and at the end, i noticed that i working on different url :D
 
I think Antti posted the video a week or so ago. The first half was on youtube and the second half was interactive 3d visualizations hosted somewhere else
 
@G.Lakshmi for the names you can as well apply the same.

names = [
    item.text for item in driver.find_elements_by_css_selector("div.SECQ.ng-binding")]
 
12:56 PM
@Kevin ah, OK
 
3blue1brown, apparently: youtube.com/watch?v=d4EgbgTm0Bg
 
@αԋɱҽԃαмєяιcαη by your code I just got like this []
 
it's working fine on my end.
 
Some people use their isolation time to learn to make sourdough bread, I'm learning math concepts that will never be useful in my professional life
Next up: fourier transforms
 
@Kevin wait, I know a good one on that
heh, it's 3blue1brown... youtube.com/watch?v=spUNpyF58BY
 
1:01 PM
to make a fourier transform, take a lot of variations of y = a+b*sin(c*x+d) and add them together, and then [magic occurs] and bam, you've approximated almost any periodic function
Finding the actual values of a b c and d left as an exercise to the reader
 
@αԋɱҽԃαмєяιcαη actually getting all values
 
@Kevin the magic is an analytical expression that gives you the coefficients of the sines/cosines in terms of an integral of your function with sines/cosines.
 
Extending the concept to additional dimensions requires the learner to have a very high cubescore
 
Reminds me of the book I have on Laplace transforms. Something something something "See, wasn't whatever that was so much easier?"
 
and it's actually simpler than that: summing a_n*cos(n*x) and b_n*sin(n*x) terms.
 
1:03 PM
Ah, I thought I probably needed fewer than four variables
 
I need
1*2 (1-3.60, ---)
DoubleChance(---)
 
@G.Lakshmi what the question then?
Ok if you now know how to get the name and the values, so you can get the corresponding for each one
 
@Kevin this might not be helpful enough, but anyway: the idea is that sines and cosines are "orthogonal" in a sense that allows this decomposition to uniquely exist.
(For the "orthogonality" you need a scalar product on continuous functions, which is not terrible, but a bit advanced. Related to L2-norm.)
 
Quaternions are pretty cool, and Hamilton was very pleased to discover them. But I've never used them for computer graphics. When I learned how to do 3D stuff, the book I used (Foley & van Dam, 1st edition, IIRC), used homogeneous coordinates.
 
In 3d space you can easily compute the coordinates of a vector by using three mutually orthogonal unit vectors: [1, 0, 0], [0, 1, 0] and [0, 0, 1] (let's ignore the circular nature of defining these vectors using coordinates). When you give the coordinates of a 3d point you just project the vector to each of these coordinate axes and measure the length of the projection.
Well, with a Fourier transform series it's similar, except you have infinitely many axes (each of cos(nx) and sin(nx) for each natural n), and the projection involves an integral :)
 
1:08 PM
yes gave like this item.text for item in driver.find_elements_by_class_name("SEItem ng-scope")]
getting []
 
i didn't gave you this at all? can you show it for me ?
even i said before. don't use space within class name. use "div.SEItem.ng-scope"
 
The Fourier transform is one level above the Fourier series expansion, and should be ignored for the time being
 
yes you didnt gave this for getting values of 1*2 values
I wrote like this
 
16 mins ago, by αԋɱҽԃ αмєяιcαη
@G.Lakshmi for the names you can as well apply the same.

names = [
    item.text for item in driver.find_elements_by_css_selector("div.SECQ.ng-binding")]
 
It might be easier to start with the discrete Fourier transform (DFT), rather than diving straight into the continuous version. It's not hard (just a little tedious) to do a DFT of a small number of samples by hand, and then do the reverse transform to recover the original samples.
That way, it becomes kinda obvious how the complex exponentials make it all work. Eg, try transforming (a, b, c, d). That's about the simplest interesting case, and the algebra is easy because your complex exponentials are simply integer powers of i.
 
1:15 PM
1 3.60 X 4.20 2 1.87
I should get like this
 
@PM2Ring I think we're talking about Fourier series for now
and I think that's the easiest entry point into the subject
 
Yep
 
@G.Lakshmi i think that you mentioned early that you were unable to locate the elements itself ? now we go within another issue? what you have tried yet?
 
On the Amiga, I had a Fourier game (written by someone else). It showed you a waveform (which you could also hear). And you had a bunch of sliders that let you set the amplitudes & phases of a harmonic series, in order to try & replicate the wave. It had an easy mode with 4 harmonics, and a hard mode with 8 harmonics.
 
to get only 1*2 section values
elements = [
item.text for item in driver.find_elements_by_css_selector("div.SEItem.ng-scope")]

print(elements)

driver.quit()
I wrote like this
@αԋɱҽԃαмєяιcαη but getting []
 
1:27 PM
@G.Lakshmi See:
51 mins ago, by αԋɱҽԃ αмєяιcαη
also i noticed the class name is SEOddLnk.ng-binding
 
@G.Lakshmi because you are searching the wrong class! the one which holding the values is "div.SEOddLnk.ng-binding"
we are repeating the same cycle again. sorry i can't help you further more.
 
OK, let me stop this here @G.Lakshmi. You haven't understood what Ahmed has been telling your for an hour. Please stop and try your luck elsewhere.
Join your friend who asked the question on SO main, see if you can figure it out. Reread this chat transcript if you have to.
 
I think this is an easy question, but there's a chance I'm missing something, so I'm gonna ask anyway: In a round-based game, at the start of each round, you enter a shop where you can buy items. Buying an item costs 3 gold. The shop is filled with 5 random items; for 1 gold you can reroll the shop and get other 5 random items. For 0 gold you can "freeze" the shop, meaning the 5 items you have right now will stick around until the next round.
(If you don't freeze, the shop will roll new random items.) My question is about spending your last gold. Option 1 is to reroll, and if you find a good item, freeze. Option 2 is to do nothing and waste your last gold. Are these two options equivalent?
 
Oh, and you have 10 gold to spend each round. It's automatically refilled
 
Oh my. I lagged out so badly there, I couldn't load the menu to finish the clean-up sorry :(
 
no worries
you can put on your boots in the meantime :P
 
Ok, I'm booted up ready to go! What am I supposed to be doing, again? :P
 
we'll see :D
 
@Aran-Fey I'm suspecting some Monty-Hall type shenanigans
 
1:53 PM
Hmm. Can't say I see any parallels to be honest. There are no doors with hidden rewards that you could draw any conclusions about; rerolling gives you completely random items, no way to manipulate or foresee anything
 
What's the gold dynamics? Why do you "waste" your last gold if you do nothing?
 
Because you get 10 gold per round; no matter how much gold you spent the round before, the next round you start with 10
So any unspent gold is essentially wasted
 
If you end up with 0 gold anyway then the former is better: you don't see anything good -> reroll -> if you find something good, freeze, in which case you know you'll get something good. In the latter case you don't know if you get anything good in the next round.
you can reroll and not freeze if it's crap, and then you're in the same place as option 2 with the same amount of gold
 
@Aran-Fey I'm not trying to draw direct parallels, only stating that there could be unintuitive consequences
 
I agree that option 1 is better
 
1:56 PM
Listen to the SME
 
@AndrasDeak So you're saying the advantage is knowing what you'll get and being able to plan ahead for next round, but there is no financial advantage? If so, I suppose I have to agree
 
Yup
Or having two shots to get good items
 
A tangentially related concept: if your goal is to buy a single item of the highest quality in a round, by rerolling up to 7 times if necessary, this is isomorphic to the secretary problem
This has nothing to do with the question at hand but I find it interesting, so here it is
I wonder how the math changes because you can see more than one item simultaneously...
 
That's what's confusing me - you only get a 2nd shot if your 1st shot yielded no good results. Because if you reroll and then freeze, it's essentially equivalent to doing nothing and letting the shop auto-reroll next round. So you only get a benefit (the 2nd roll) if your first roll was useless. But then it's not really a benefit anymore, is it?
 
no, reroll and freeze is better: you know you'll have something good
whereas inaction means "you either get something good or you don't". If you don't, you'd need 1 gold to reroll for something good.
 
2:09 PM
Wait, so does spending your last gold on a reroll increase your odds of finding something good? I'm having a hard time wrapping my head around this
 
"you only get a benefit if your first roll was useless". I agree with this. But if there's a 50% chance that the first roll is useless, this doesn't mean it's not a benefit; it means it's half a benefit
Which is one half of a benefit better than if you had done nothing
 
hmmm
probability theory always kicks my butt like this
 
I'm half inclined to test this empirically by writing a simulator, but I don't have enough information about what constitutes a "good" item, so I can't write logic that decides whether to reroll or not
 
@Kevin That makes sense if you put it that way, but my brain isn't convinced yet. I'll need to ponder this for a while
 
For example the decision logic for "items all have a numerical quality between 1 and 10, with each one being equally likely to appear" is different than the logic for "90% of items have quality 1, 9% of items have quality 10, 1% of items have quality 100"
 
2:13 PM
@Kevin your items could just be "good" and "bad" like that, with 10% chance of "good"
@Aran-Fey I think of it as one more roll "for free" (i.e. money you were going to lose anyway)
 
I don't think there are any probability distributions where "reroll, then freeze if the items are good" is not the best strategy, but the criteria for "if the items are good" will vary
 
It's true that some items are better than others, but I think all that matters for our purposes is whether you intend to buy the item or not. So a random chance of a "good" item appearing should be fine
 
@Aran-Fey yeah, I agree
 
@Aran-Fey I think most of us are in that boat. You'd have to be yam-hot to spot it every time in real life. See bookmaking for example.
 
the assessment of the utility of each item is a different problem
 
2:17 PM
When I started looking into betting odds, it amazed me that really, the initial odds only have to be plausible, or at least entice bets. Then you can create a book that always returns 110% (ish) of whatever you start with
 
Hmm, if we crank up the price of buying an item to 10 gold then the answer suddenly seems pretty obvious. Rerolling (up to) 10 times and freezing at any point is clearly better than floating 10 gold
And now I'm left wondering why I only asked about the last gold and not the last 2
 
Hi guys
I need help with a regex
I want to match email address but without the "email label part"
 
@PawanSharma Sounds like a common problem
 
e.g I need only the actual email id out of "Email:abc@yamoo.com", the match should be abc@yamoo.com
the possible variants of the email label can be e-mail, E-mail, email etc etc
how can I exclude them
@andra
@AndrasDeak I was unable to find a solution :(
 
It's unclear to me why you'd include them in the regex in the first place
 
2:25 PM
[^@]+@[^@]+\.[^@]+
 
depending your problem, you could potentially just split on :
 
that's the regex I am using to match email id
 
Are you trying to find an email address in a long string or is "Email:abc@yamoo.com" literally your whole input?
 
@Aran-Fey The task is to extract email id from public resume and I guess each person has his own style of writing email. Some may write it as email, some as E-mail. also they may or may not include the colon :
 
2:28 PM
In that case I'd go with e-?mail\s*:\s*(\S+)
 
looking at 2 resume , i found that one of them had - abc@yamoo.com without and label sort of thing at the starting of a line and other had Email:abc@yamoo.com
 
Evil solution: be like 99.999% of other resume websites and require the applicant to painstakingly type in all of their information into individual fields whose formatting you control
 
@Kevin Very nice solution indeed, but I don't think I can convince my manager to do so
 
@Kevin Oh, nice. That actually took much less code than I expected
 
@Aran-Fey that regex didn't work
 
2:32 PM
I don't know if "very nice solution" applies when hundreds of applicants will curse your name for inconveniencing them
 
That's not useful feedback @PawanSharma
 
So the problem is really finding an email address in a blob of text. I think \S+@\w+\.\w+ should work well enough
 
@roganjosh Sorry , Kinda new to chat
 
This strikes me as a problem where you can cover 90% of cases with 1 hour of work, and 99% of cases with 10 hours of work, and 99.9% of cases with 100 hours of work, and so on
 
@PawanSharma It doesn't just apply to chat. "This doesn't work" is not helpful to anyone if you don't explain why it didn't work
 
2:34 PM
@roganjosh Oh, got it
 
You will never ever get to 100% because out there somewhere is an applicant who uploads a jpeg of a handwritten notebook page that says "my electronic mailing address is John Q Public at hotmail dot com", in handwriting that looks a lot like the swirly captcha font
 
@Aran-Fey, \S+@\w+\.\w+ matches the entire string including Email:
 
oh, yeah, if there's no whitespace after the colon
 
Complication: email:johnQPublic@hotmail.com is a valid email address
There's no rule that says colons are forbidden
 
> The format of email addresses is local-part@domain where the local part may be up to 64 octets long and the domain may have a maximum of 255 octets.
Why the heck is the domain 4 times as long as the local part
> The local-part of the email address maybe unquoted or may be enclosed in quotation marks.
 
2:38 PM
Oops, I misread stackoverflow.com/a/2049510/953482. Colons are allowed, but only inside quotes
 
This article is full of surprises
 
So email:johnQPublic@hotmail.com is forbidden but johnQ"email:"Public@hotmail.com is allowed
 
I guess I have to go with email label as well , as for now
Thanks anyways for helping
 
Oh, I almost forgot to link to The most standard-compliant email regex, which I like to do every time this conversation comes up
 
alright, [^\s:]+@\w+(?:\.\w+)+ final offer
 
2:46 PM
Unrelated problem. I have an infinite grid of squares, and an unlimited supply of N distinct colors of paint. I want to paint a finite number of squares so that every color neighbors every color, including itself. for each value of N, what is the smallest number of squares I need to color?
I worked out the first couple cases. 1 through 3 are trivial. I'm only 80% sure I have the optimal layout for 4.
N=1: colors = {red}

RR

N=2: colors = {red, green}

RR
GG

N=3: colors = {red, green, blue}

RRB
GGB

N=4: colors = {red, green, blue, cyan}

 CC
RRB
GGB
C

N=5: colors = {red, green, blue, cyan, magenta}

???
I haven't conclusively proven to myself that N=4 requires three cyan squares
 
@Aran-Fey can I re-roll? :P
 
[you-need-more-gold.wav]
@Kevin One less square for N=4:
 RC
CRB
GGB
 
Ah, but then you don't have a C next to a C
 
yeah, I just noticed that too, my bad
this gets complicated real fast
 
"We're not helping you solve a leetcode problem, are we?" you hypothetically ask. No, you're helping me solve an Animal Crossing problem. You can cross-pollinate flowers by placing them next to one another, and their offspring will appear nearby the next day. I want to put all combinations of parents next to one another without taking up N^2 spaces on my island.
I could probably devise a good but not optimal solution for N=7ish, which would solve the problem in a practical sense, but that's no fun
 
2:56 PM
I found an alternative solution for N=4, but it doesn't seem to be possible with less than 9 squares
 
I suspected that might be the case. And my fear is that the optimal N=5 solution will use one of the optimal N=4 solutions as a base, but not all the N=4 solutions will lead to an optimal N=5 solution. So as N increases there will be an explosion of possibilities
You can't just say "choose an optimal solution for N-1 and brute-force all possible placements of the new color around the perimeter", you have to apply brute force to every optimal solution for N-1
 
3:13 PM
If there was an easy way to skip mirrored and rotated variations of combinations that were already processed then this might be an interesting programming problem
 
3:28 PM
tagged with python
 
@αԋɱҽԃαмєяιcαη how is that a dupe?
How can a connection error be a dupe of parsing JSON?
 
well it's the same url and the issue is about the headers!
 
Oh, come on. That's too much of a stretch. I'm not saying it's a good question at all but we either close with a different reason or a different target
 
@roganjosh ok can you add this as second dupe ?
 
@αԋɱҽԃαмєяιcαη I'll VTC but I'm not convinced on either of the dupes
 
4:18 PM
hii @αԋɱҽԃαмєяιcαη Got it thankyou
 
@G.Lakshmi Finally :)
 
Yes got it actually I want to get those values which are scrapped to an html page in an table format is it possible @αԋɱҽԃαмєяιcαη
 
@G.Lakshmi you've then to read about pandas read_html
 
@αԋɱҽԃαмєяιcαη Ok I will read if I got any doubt can I ask you?
 
@G.Lakshmi you are in Python room. so you can leave your question here. and if anyone can help, so he will get back to you. check room rules as well
 
4:24 PM
@αԋɱҽԃαмєяιcαη Ok :)
 
@G.Lakshmi Not only that, but remember that the last discussion was shut down because you don't make it easy for others to help you. So you need to bear that in mind
 
Yeah okay definitely I will remember it @roganjosh
 
4:49 PM
@G.Lakshmi Ahmed loves helping lost souls. So ask him to start a new room the next time you need help.
 
5:06 PM
dark theme is not applied within chat :(
 
nope
 
i see, also i noticed the help section beside comment is a bit confusing within dark theme.
 
someone already noted that
There's a bug report thread on meta if you're interested enough, just make sure there's no answer mentioning this already.
 
 
1 hour later…
6:27 PM
"As" has just come on on Magic. My best friend and I would divvy up who is Mary J and George Michael (neither of us can hold a single note). Now this isolation feels serious
I still belted-out my part anyway :)
 
6:41 PM
> x_train is supposed to be a dictionary, but the compiler thinks it's ndarray for some reason.
Silly python doing what OP tells it to do
 
7:31 PM
 
@Kevin I'm late to the discussion, but isn't the analytical solution to this do_nothing = 1 - 0.9**5 = 0.40951 and reroll_once = 1 - 0.9**10 = 0.65132?
 
7:55 PM
Nm, looking back thru the archive, it looks like there is a lot more context, and this was just a simplified experiment.
 
FWIW, that looks correct to me
 
which close vote can be applied for that question dupe or seeking debug?
 
8:32 PM
There is no close vote reason for "this is a web-scraping script attempting to violate the website's TOS". Downvote and ignore.
3
 
 
2 hours later…
10:13 PM
@PaulMcG Right, there is no 'unethical/violates third-party TOS' close-vote reason. see Is there a canonical question for web-scraping techniques?, esp. people asking how to defeat anti-scraping measures
 
10:27 PM
...Quora had layoffs 1/2020, and Quora Partner Program is bottom-feeding for monetization.
 
11:15 PM
By calling plt.plot with a 2D array rather than a 1D array I can plot multiple lines at the same time. However, it adds a legend for each of them. How can I make sure only a single legend is added?
i.e. that they all share the same legend
 

« first day (3464 days earlier)      last day (1476 days later) »