« first day (3145 days earlier)      last day (2028 days later) » 
02:00 - 16:0016:00 - 00:00

02:20
Hi guys, I am having a problem with some web-scraping using Python, Selenium, and Beautiful soup. I am attempting to get some url's from a page source, but I am unsure how to return just the URL portion of the HTML, rather I am having to return a much larger chunk, because the URL is linked as an attribute of style. I have uploaded an imgur to highlight the url I am looking for. i.sstatic.net/U7U0L.jpg If anyone is able to talk with me about this I would greatly appreciate it.
lmao
cabbage = hello im back, I like it.
@VictorNogueira Don't forget than rbrb (Rhubarb) is bye bye :-)
02:31
@U9-Forward
Potato
Banana
I am a Green Bean. (six months)
That is somewhat similar, but not exactly what I am looking for... I am not allowed to post my question yet, as per the rules, may I dm you the link?
@U9-Forward
I now realized that there is no DM system on SF, find more details of my question please here:stackoverflow.com/questions/56318096/…
Please let me know if anything is not clear.
 
3 hours later…
05:55
recbg
06:06
cbg
06:44
5 messages deleted
cbg
cbg
?????
what did I do?
@JonClements Huh, wow, you have a lot of power man
@StephanS Exactly
@U9-Forward Are we witnessing a power move... ?
@StephanS :P i don't know :-)
06:49
Laurel
@StephanS ooops... sorry... just clicked one too many messages when deleting stuff... my bad...
@RaguvaranR that's not on-topic here - please stop asking it.
@JonClements It's all good, I thought I broke some type of new rule.
But here only active members. And somebody know the answer . suppose they know answer help me out the problem .. but your rule are not good
Ask on SO
@RaguvaranR The rules are to keep the questions on topic
07:00
On Topic is ok .But at the same time this group members are not only know on topics
@RaguvaranR They "are good" because they set up guidelines to what can be asked. No one like a cluttered chat. We are python programmers, we don't answer questions about unix here.
@RaguvaranR 1) Even with the current rules that forbid off-topic questions we still get an annoying number of off-topic questions. The rules are fine - or maybe they need to be more strict. 2) I'm pretty sure none of us can answer your question.
07:56
Hello, are there beginners?
That's a first... usually people come here looking for experts
Hello i need some help im newbie with data science... i have an assignment with a file similar to coinmarketcap.com/es/currencies/bitcoin/historical-data
But the first 100 days i have no volume data.... so i cand delete rows with volume - or put a value like mean instead or some kind interpolation
what do you think ? any suggests ?
I have to clean and format the data and make some study... i made some plots date vs hig, date vs open, volume vs market cap ... any idea of interesting plots ?
08:11
How does a builtin like max or min behave if we provide it a lambda function as a key, which returns a tuple
for example here
In [42]: a = [1,2,3,-4,-5,-6]

In [43]: print(max(a, key=lambda x: (-abs(x),x), default=0))
1
Same as always. What you really want to ask is "how does (a, b) < (c, d) work"
first element is compared, if they are the same, the second element is compared, then the max is the first element of the tuple?
yep
well, max, min or whatever, the idea is tuples as keys act like hierarchy
Are you talking to me ?
08:18
is the max the first element or the second element of the tuple then, or the element which is bigger @ParitoshSingh ?
outer to inner, or left to right.
example if I do this
In [48]: a
Out[48]: [1, 2, 3, -4, -5, -6]

In [49]: li = [(-abs(x),x) for x in a]

In [50]: li
Out[50]: [(-1, 1), (-2, 2), (-3, 3), (-4, -4), (-5, -5), (-6, -6)]

In [51]: max(li)
Out[51]: (-1, 1)
@EduardoGutierrez sorry no, that was to Devesh.
is this an equivalent of what I did earlier, or no? which was max(a, key=lambda x: (-abs(x),x), default=0)
same in terms of the key, different only because you do not get a tuple as output. But yes, that's how it's working off of the hierarchy during comparison when it comes to tuples. one value at a time, left before right.
08:22
so is a list like above created in memory, and then the comparison is made @ParitoshSingh or am I missing something here
I mean li = [(-abs(x),x) for x in a]
well if anybody has a minute ...
@DeveshKumarSingh so, what part confuses you here? Sounds like you're clear on the hierarchy comparison that tuples do, but are wondering about the internals of how it chooses a max? did i read that correctly?
yes I know that (2,2) > (1,1) and (2,2) > (2,1) compare by first element, if same compare by second and so on
but how come this translates to choosing a max, what ordering is done is something I cannot wrap my head around
or maybe I need a better example of a list to make it more clear
@EduardoGutierrez both are valid options. you'd have to choose one. One thing to consider is how big is 100 rows in comparison to your total number of rows. If you are using mean from 20 values to fill up 100 rows for example, you'll most likely get a biased dataset. At that ratio, it makes sense to drop the rows, ( or the column too in some cases)
@DeveshKumarSingh yes. yes you do.
test = [
        (2, 0, 0),
        (1, 0, 99),
        (1, 1, 0),
        (0, 0 ,0)]

sorted(test)
instead of focusing on the max, use sorting. This should help.
sorting happens on the first element, then the second element is considered for (1, 0, 99) and (1, 1, 0) and that's it right, the third element isn't considered here
08:32
mhm
only on ties do the lower values get considered. A hierarchy.
so max can be thought of a descending sort, and then picking the first element on the list?
yep. though that's not efficient internally ofcourse
so it's more often than not a "running max".
where you keep track of a max value seen up until a certain point.
if max < curr_max: max = curr_max
something like that?
@ParitoshSingh thanks this is my full file:
In concrete this :https://coinmarketcap.com/es/currencies/bitcoin/historical-data/?start=20130428&end=20170905
08:37
at a glance it seems like you have a lot of rows*
got it, and that is why these are are equivalent
id like to know also which plots can be helpful and what statistical functions like mean, standard desviation, interpolation...would also be useful to make a study... We are cleaning and formating/analysing data
In [77]: a
Out[77]: [1, 2, 3, -4, -5, -6]

In [78]: sorted(a, key=lambda x: (-abs(x),x))
Out[78]: [-6, -5, -4, 3, 2, 1]

In [79]: max(a, key=lambda x: (-abs(x),x))
Out[79]: 1
so you should be fine with whatever choice you make
@DeveshKumarSingh they aren't? sorting by default is ascending order. 1 is the last value, aka max.
yes I realized when I typed, so a layman way to understand is to sort and pick the maximum or minimum, to think about max or min where a tuple is considered as a key
08:39
@EduardoGutierrez plot all of the ones you can think of, and see. When it comes to making a study, results tell you best.
yes, in layman terms you can think of it that way. because by definition, the max will be the last value in ascending order, or first value in descending order.
that's why its max after all.
@EduardoGutierrez Also, you can read up on what other people have used for similar studies in the past. searching for "time series" or "stock market analysis" may give you some ideas on what you can use. But i would still suggest trying the different plots out, and seeing what comes out of it.
Got it, and it case of multiple keys, we only use inner keys to resolve conflicts between tuples where the previous keys are the same, and once an ordering is obtained, we don't care anymore
yes. the idea being "hierarchy". order of preference. Or whatever you want to call it.
The thing where it gets slightly tricky is for e,g
In [85]: a = [1,4,6,-8,-10]

In [86]: sorted(a, key=lambda x: (-abs(x),x))
Out[86]: [-10, -8, 6, 4, 1]

In [87]: max(a, key=lambda x: (-abs(x),x))
Out[87]: 1

In [88]: max(sorted(a, key=lambda x: (-abs(x),x)))
Out[88]: 6
the last max was not passed a key. it defaulted to taking the max value.
6 is the biggest out of [-10, -8, 6, 4, 1]
Yes, so the visual max or min you see after sorting might not be the maximum, it is the maximum when you sort according to your key
08:48
indeed.
None of those examples really needed to use a tuple as key... they're all identical to key=lambda x: -abs(x)
Aah, man this is mind bending for me, because I am used to seeing max or min from the list of numbers point of view, but that ordering is not obeyed here, instead the ordering is from the tuple
@Aran-Fey Is that because the first elements breaks all ties, so the second element will never be touched while calculating the max?
Yeah. It only really gets interesting when you have two elements that only differ by their sign
>>> sorted([1, 2, -1, 0], key=lambda x:(-abs(x), x))
[2, -1, 1, 0]
I hate this spotty internet connection
Yes the second element resolves the tie between (-1, -1) and (-1, 1)
09:08
@Aran-Fey so internally does the max function sort according to the keys and pick the last element, or it keeps a running maximum
09:27
@JonClements perhaps a Knives room move would've been sufficient?
@DeveshKumarSingh I'd be very surprised if it didn't use a running maximum
Think of non-reiterables
understood, I will also read up here docs.python.org/3/howto/sorting.html for more details on how sorting work with tuples as keys
what is a non-reiterable @AndrasDeak ?
09:32
I probably meant iterators
For instance if you want max(range(1000000)) it would hurt to sort it. And sorting is n log n, right? Running max is O(n).
yes, hence a running maximum automatically becomes the better choice
Sorting is only harmless for O(n^2) problems
10:24
Finally finished refactoring my encryption code... now I just need to remember what I was working on a week ago, before I got sidetracked.
eerily accurate
10:49
@Aran-Fey Isn't that just the life of a programmer? Working too hard on one part of your project, suddenly it's a new project, and then you've got little parts to that project, and then those become new projects, and it continues forever...
Well, let me put it this way: My backup script won't be much use if it takes another 84 years to complete
I think in 84 years Brainfuck will become the language of choice for most software developers
Hi I want to ask few basic python questions? 1) How can I access class variable outside the class...I am not able to accesss it
Can you post your class? I'll help you, but in the future you should resort to asking a question on Stack Overflow.
11:05
@connectyourcharger can you stop pushing people onto SO main?
why?
as I've said before, if they're intelligent, they'll find the answer to their question
Not all questions (actually, most questions) need questions on main. With the quality of questions people tend to ask, you're more likely than not setting up innocent people for downvotes.
@Swapnil please see sopython.com/wiki/… for formatting code in chat
(bottom line: edit message and ctrl+k)
well, here's my philosophy: If they have a brain (which most humans do), then they'll figure out they don't actually need to ask a question
yes i am trying
and if they can't find the answer to their very simple problem somewhere on the internet, then they probably shouldn't be hanging around on SO anyway
11:07
import mysql.connector
class MyDB:
    global cursor
    def __init__(self, hs, us, pw, db):
        conn = mysql.connector.connect(host = hs, user=us, passwd = pw, database = db)
        #global cursor
        cursor = conn.cursor();
        cursor.execute("show TABLES")
        print(cursor.fetchall())

db2 = MyDB("localhost","root","","mydbsnh")
which variable are you trying to get?
@connectyourcharger walk off, cool down. There is no need to be so rude/ruthless to others, no matter what.
@connectyourcharger unfortunately the real world is not a fairy tale so you'll have to give up on some of your elitist idealism
but you see, the user was intelligent enough to format their code
so I truly have faith that they can find the answer to their question on SO
11:08
sorry ..I will add place where i am getting error
AttributeError: 'MyDB' object has no attribute 'cursor'
import mysql.connector
class MyDB:
    global cursor
    def __init__(self, hs, us, pw, db):
        conn = mysql.connector.connect(host = hs, user=us, passwd = pw, database = db)
        #global cursor
        cursor = conn.cursor();
        cursor.execute("show TABLES")
        print(cursor.fetchall())

db2 = MyDB("localhost","root","","mydbsnh")
cursor.execute("show tables")
print(db2.cursor.fetchall())
not trying to be rude, but I don't think it's reasonable to assume that a user can't figure out where to find the answer to their issue
I don't usually see globals like that in a class definition.
A-ha. You should make cursor an instance attribute rather than a global
not trying to be rude, but being rude.
11:09
you did global cursor in the class scope, but not within __init__
self.cursor = conn.cursor() etc in the __init__, and always refer to it as such
yes that would be the way
doing global cursor and then doing any kind of re-assignment would not modify the variable within the class
although that would be a very round-about way of doing things
ok, you know what, I'm inspired now, I'm going to try and make a polite statement for new users who come here to help
you know, in the sake of helpfulness
@connectyourcharger if they'd have found the answer by reading SO main they wouldn't be asking here. When you ask for help you are vulnerable to what people you expect to know more than you are saying. If they tell you to go ask on SO you won't contemplate it, you will go and ask, even if it's a bad question.
I think the "ask on SO" approach may be misleading
Also your insistence that asking good questions has to do with intelligence and the presence of brains is harmfully misleading
11:12
Thanks @AndrasDeak @connectyourcharger .... I will try and let u know
@AndrasDeak maybe competence is a better word?
hmm
alright give me a minute
Most people asking on SO main can't ask good questions. That's a fact.
11:13
And frankly, sending people away when there are people here who are willing to hear them out is a disservice to both parties. If I want to send them away I can do that just fine myself.
that's a given
Ok, this is what I have;
Hello! We appreciate you coming to ask a question here, but that's what the main website is for. What you should do: First, research your question on the internet and on Stack Overflow. If you can't find a solution here, come back here to this chat room and we'll try to help you. We may direct you to the main site at some point, and at that point it would be best to ask a question on Stack Overflow. Thanks, and have a great day :)
Sending askers here to SO main will just make SO main worse and the users more frustrated. The reason we try to help is to try and teach the askers something, which is not SO main is for. Fishing and whatnot.
@connectyourcharger how about leaving new users alone and let regulars and room owners do what they want?
well, I think it's good to give them direction
I don't.
sometimes new users come here and they really don't quite know what they're doing
11:16
At which point we tell them to go away and learn. If you start posting that condescending paragraph to everyone asking a question you'll be much more of a problem than the actual people asking newbie questions.
you think that's condescending?
it reminds me of old Clippy
we don't need a dumb bot
I mean yes, it could get repetitive, but it helps ensure that the quality of questions are better on SO, because the user has to go through other helpful steps before asking a question
And chances are they will never actually have to ask the question
it doesn't ensure anything, it's just noise
If they research and/or we help them
11:19
Everyone who asks here thinks they've already tried searching and solving otherwise. They still can't do it.
well, I think it's an issue of what is acceptable to ask here or not
The rules of the room outline that it's OK to ask a question in here, and new users who don't read the whole rules won't understand that if their question meets SO's standards, it's better off there
Frankly, that rule needs to go right to the top of the "Asking a Question" section
We should make an effort to clean up that section of the rules
This question right now that you would've sent to SO main wasn't up to SO's standards and doesn't need asking on SO. It's as simple as "your design is off, use instance attributes". They couldn't have known, and we can tell them in 5 minutes if we hear them out.
But I'm still confident they could have found that answer on the web
Right from the rules: Chat is not a substitute for reading a tutorial or taking a class.
11:22
@connectyourcharger we have problems with users not reading the rules, but you're the first one to think that people's programming questions here are a problem. They are not.
Any simple tutorial on classes and instances of classes would describe instance attributes
That's like, one of the basics of classes
Indeed. How will they know what tutorial to read? Are you aware of the Dunning--Kruger effect?
It just concerns me when I see questions like that, was there no effort put in?
I am not aware
it might surprise you but people not knowing the basics won't know where to learn the basics
look up "classes"
11:24
they won't even know which part of the basics they need to learn
You should also be aware that "please read a tutorial" is the exact opposite of "please ask on SO main". At least make up your mind.
Well, you're now swaying my argument. I realize that this is a bigger problem now.
What and how you've been discussing this comes across as you just wanting to send everyone away without even listening to them on the basis of "they should know better".
17 mins ago, by Andras Deak
@connectyourcharger unfortunately the real world is not a fairy tale so you'll have to give up on some of your elitist idealism
and now that we're back I think I'm done
SO is for professionals, am I wrong?
11:26
yes
And enthusiasts
who are not professionals
Enthusiasts implies that you have a basic understanding of the language you are working in
Like, when I started, I had no idea what a class was, but I knew it existed, and if I was trying to utilize an example, I would look up "classes"
@connectyourcharger no
to find out more about classes
11:27
if you assume that all people are like you you're going to have a baaad time
oh no, definitely not
but here's the google definition:
a person who is highly interested in a particular activity or subject.
You wouldn't come into Python knowing literally nothing (and I mean like what's a variable? nothing) and be automatically interested
Have you ever seen a child who finds interest in something?
Yes, but child's play is very different from programming.
Being highly interested in something has literally nothing to do with knowledge nor talent.
Programming is very hit-or-miss with interest
11:29
Anyway, I'm growing weary of this dead-end discussion
I think we're getting nowhere. I don't really want to have an argument - I respect your views and opinions - I just think it needs to be more clearly established the types of questions that are OK to ask in here, rather than on SO.
As I said, anything is fine here a priori. You're the only one who thinks otherwise.
this won't stop regulars from sending away users who need more hand-holding than reasonable, or who are help vampires
But, I mean, should there not be clearer rules? I don't think chat should be a substitution for asking a question.
It's not. I've been trying to explain that most questions asked here are fine and would be very bad on main.
anyway
hmm, now I'm interested
I'm going to take this to meta
11:33
have fun
lol, I won't
but it's an interesting topic, you have to agree
I'd use "cumbersome"
"cumbersomely interesting"?
just plain cumbersome
cuz it's a double standard
11:35
I've wasted way more time debating this with you than the amount of time I would've spent convincing the last asker that they need instance attributes and guide them how to use them
well, I mean, they got it
I don't really want to debate, but it'sdefinitely not appropriate to set a double standard for question-asking
we'll say end of discussion there
it was a productive argument :)
there is no double standard
how does a user decide whether to ask here or on the main site?
these are two different use cases, it's not really an either/or
most new users have no idea that chat exists anyway
SO main and SO chat are completely different beasts.
11:39
but when new users see chat, it's like "oooh, chat"
doesn't matter
because talking to somebody is generally more appealing then just getting a response to a question
and more helpful
and coaching somebody into providing the necessary details in an interactive fashion is a lot more productive than on SO main, which is one of the reasons we have different rules here
(though sometimes we fail anyway, because some people are in way over their head)
sometimes
let's drop this for now
but this was a good discussion
thanks mates
12:09
Cabbage
12:37
cbg
@AndrasDeak We could use "cucumber" as the salad language term for "cumbersome". :)
some people use cucumber for repwfarmer which could be misleading to them
Sam
Sam
guys why does this simple statement return an error?
if len(sys.argv) > 1
Oh, ok. I hadn't noticed that.
Sam
Sam
12:41
SyntaxError: invalid syntax

[Finished in 0.0s with exit code 1]
[shell_cmd: python -m py_compile "/home/sam/Scripts/reminder.py"]
[dir: /home/sam/Scripts]
[path: /usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games]
@Sam we need more code, MCVE please
Sam
Sam
this is all the code:
missing colon perhaps
Sam
Sam
no i have the :
just go on with the code
Sam
Sam
12:42
did the code already upload?
Sam
Sam
now?
yes, but broken indentation
edit and ctrl+k for code format, then read sopython.com/wiki/…
Sam
Sam
    import sys
reminderfile = open(os.path.join(os.path.expanduser('~'), 'Scripts', 'reminder', 'reminders', "a")

if len(sys.argv) > 1:
	reminderfile.write(sys.argv[1])
	reminderfile.close()
else:
	print(reminderfile.read())
and post the whole traceback
missing closing parenthesis on reminderfile = open(...) (the line before the if)
Sam
Sam
12:43
Oooooo thanks
always check the previous code line for possible context with syntax errors
@Sam BTW, it's a good idea to use a with statement to open files.
12:58
@DeveshKumarSingh When you use a key function with max (or min, sort, or sorted), Python is doing an invisible Schwartzian transform on the data. So the transformed values are used in the comparisons needed to find the max (or do the sorting) but you never see those transformed values, only the original values.
To get a good feel for what's going on, I recommend using a proper def function for the key function, so you can put some print calls in it that tell you what arg the key function is called with & what it returns.
@PM2Ring Thanks @PM2Ring Yes, there was a question asked here about it: stackoverflow.com/questions/56182445/… But I didn't know what it meant before but using an explicit function for a key and having print statements inside it to see what's going on is a good idea
FWIW, Python guarantees that the key function is only called once on each original value, even though a given (transformed) value will be used in several comparisons before sorting is completed. If the key function is expensive to compute, and the list contains lots of dupes, it can be worthwhile to give the key function a cache.
good morning good guys, looking for some luck: any of you ever worked with Python wrapper of Pipx40 library from Pickering vendor? I'm able to communicate with acquisition board with .NET and C but Python refuses to play with me...
@PM2Ring yes, we decorate the arguments with the output of the key function, sort via the updated keys via comparision, and then undecorate the arguments to get the actual value? Is that what this means
@DeveshKumarSingh That's right.
13:10
Even if they didn't do the transform, the output we expect from max and min would have been the same, just that the function run would have been more time-taking and inefficient
@DeveshKumarSingh Yes, calling the key function on both values every time you do a comparison when sorting would be very inefficient. With max, it's not so bad, you just have to remember the current max & its transformed value.
To be specific, from how the wikipedia article reads, we cannot call it a Schwartzian transform in case of min-max i think(? correct me if wrong, since no sorting happens for min-max). I just am worried you keep wanting to mix min-max with sort here, and makes me regret bringing up sorting in the context.
@PM2Ring Great, thanks for the insight, It's nice of you to go back to the transcript and answer my specific question :)
@grandangelo Maybe not here, but you might have some luck on the main SO site, if you clearly give all the relevant details, eg OS, and library & Python versions, and any error messages. It might be that Pipx40 only works on Python 2, and you're using Python 3, or vice versa.
@ParitoshSingh Well, the low-level details of how the Schwartzian transform is done are invisible to us. It probably uses C data structures that we can't access directly. But at the Python level, the key function of sort and max or min works exactly the same way. And the same goes for itertools.groupby.
@AndrasDeak i just want to thank you again , i finally managed but by using a dictionary
13:25
@PM2Ring Aye, i suppose at this point its the terminology that leaves me confused. the article very heavily implies "Schwartzian transform" would necessarily involve a sort step. Would it then be wrong to call it a Schwartzian transform in context of a max calculation? (where sure, the same dict-like structure can be employed to avoid recalculating a dupe key, but no sorting happens)
@DeveshKumarSingh No worries. As a room owner, I feel obliged to keep up with the transcripts. I don't closely read stuff I don't know, like Pandas or Django, but I still skim it, to make sure people are behaving properly. ;)
thank you PM 2Ring, you're true, I'm using Python 3.5, but nowhere on vendor's site is explicitly stated that it is supported.
Enjoy your day guys
Or i suppose, rather, is it colloquially correct to use the phrase "Schwartzian transform" for max or some other calculation like that?
@ParitoshSingh Yep. Let's call it a virtual Schwartzian transform. ;)
hehe, i see i see.
I just don't wish to get picked on for using this phrase elsewhere, sometimes it's...tricky to navigate and understand coined terms like this one.
13:31
, sir, thank you very much. Looking for ctypes call differences between Python 2 and 3, I found on SO a post suggesting to take care of string encoding. Adding a
encode('ascii')
to my call fixed my issue. You saved my day, after hours of trials with no luck :-)
Wondering if we can find someone in the source code of cython about max/min using the Schwartzian transform
@HarvesterHaidar I'm glad to hear that
@ParitoshSingh If you have a list containing dupes, the key function does get called on the dupes. But it only gets called once on each original value. So if you sort a list of 16 values, the key func gets called 16 times, even if all those values are identical. You can verify that by putting a print call in your key func.
So that then just makes me think there's no memoization* (for the key calculation) happening during a max call, huh. You're right, the print displayed multiple times
Hi guys I have a doubt
Please check this problem : codeforces.com/problemset/problem/230/A
I have already solved it using one method :
Here is the code for the same:
from operator import itemgetter
s, n = map(int, input().split())
lst = list()
counter = 0
for i in range(n):
    x, y = map(int, input().split())
    lst.append([x, y])
lst = sorted(lst, key=itemgetter(0))
for i in range(len(lst)):
    if lst[i][0] < s:
        s += lst[i][1]
        counter = 'YES'
    else:
        counter = 'NO'
        break
print(counter)
13:37
Here's an answer by Martijn about sort & the Schwartzian transform: stackoverflow.com/a/41078710/4014959
Ah, never mind, got it figured out sorry :P
counter = 'YES' Now that's a 10/10 variable name
I guess it was a bad variable name right? @Aran-Fey
since we already have counter of collections although I think there was a capital C
Yeah, but fortunately it's not really a big deal in such a tiny program
Flag would have been better I guess
13:41
wow, yeah
Cool, thanks guys! Any other inefficiency in the code I have written?
By the way, does that code really pass all the test cases? You just sort and iterate?
Yeah it does
I mean it did
Wow
For the record, your solution isn't actually correct
"Kirito can fight the dragons in any order." <- that's what makes it difficult
Yeah thats why I sorted so that the lowest ones would be there first
If he cant beat a lower one , he cant beat a higher one as well was the logic I used
13:44
@RaphX You can make the sort more efficient. The sorted function creates a copy of the original list, and then sorts it in-place. So it's more efficient to just sort lst in-place
Actually, I'm dumb
I thought there was some sort of penalty for defeating a dragon
Using sort function? @PM2Ring
Wow, I really overcomplicated that challenge. My bad for assuming that it was a challenge, I guess
@RaphX Yes, the sort method. Eg, lst.sort(key=itemgetter(0))
Also, it would be better to use enumerate in the last for loop.
Ok thanks!@PM2Ring
13:57
And I would store the x & y values in a list of tuples, rather than a list of lists. That's mostly a matter of style; it won't make a noticeable speed difference, but it will save a few bytes of RAM.
@RaphX Actually, you don't need enumerate there, since you don't really need the indices. You can just do:
for x, y in lst:
And you can make your flag-setting logic more efficient. There's no need to do counter = 'YES' each time he wins.
I think you may be able to improve the key function, to maximize the strength bonus as soon as possible.
14:32
Yeah I wrote an alternate code
s, n = map(int,input().split())
a = [map(int,input().split())for i in range(n)]
a = sorted(a)
print(a)
for x,y in a:
    if s > x:
        s += y
    else:
        print("NO")
        break
else:
    print("YES")
Didn't come to mind first time
Is this what you meant? @PM2Ring
I forgot to change that sorted again
You're using python 2, aren't you?
no why?
>>> sorted([map(int, ["14"]) for _ in range(3)])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-42-f4066b4913b5> in <module>
----> 1 sorted([map(int, ["14"]) for _ in range(3)])

TypeError: '<' not supported between instances of 'map' and 'map'
Oh yeah how do I modify this code then?
Start by using python 3 :P
Then use list(map(...))
14:39
but sorted is supposed to create a list too right?
Shouldn't this have worked in python 3 as well?
Try it
You want to have nested lists. Sorted handles the outer. I'm talking about the inner.
I still don't understand the error
In python 3 you have a list of map objects
did you try recursive sorting?
if you mean sorting the inner lists, that would be wrong
Technically they need tuple(map(...)), order matters
14:51
@RaphX a = [tuple(map(int,input().split())) for i in range(n)]
@RaphX And you forgot the key function for sort, but that probably doesn't matter. I'd probably use lambda t: (t[0], -t[1]) So if 2 or more items have the same x value, he fights the one with the highest y value first.
IOW, we sort ascending on x, but descending on y.
whoops
um, cbg :P
huh
did someone ping me
nope. whistles innocently
uh huh
I saw the yellow highlight
but, lucky for you, I don't hold grudges. cbg to you good fellow
ah crap, wrong room
Does anyone know what stack I should use if I have to make a web app which has the CRUD functions, data science package support like pandas, or similar packages like dplyr, data.table, etc?

I have an app in R shiny but need to add more functions to it.
which is hard or not best to do in R shiny
02:00 - 16:0016:00 - 00:00

« first day (3145 days earlier)      last day (2028 days later) »