I criticized another coder for assuming that any command that isn't POP will be PUSH, so I had to revise my own solution to avoid that assumption. Also avoiding my prior use of
queue.append(command[5:])
I hope my new attempt is a little clearer for being more explicit and allows for the code
More
I'm not really a fan of this:
case _:
q.append(i[5:])
It works, assuming no one is ever going to develop this further, but if we decide later to use something like a "clear" command to empty the queue, might this lead to trouble? I mean, in something as simple as this, no, it w
More
Huh... I at first thought that del s[:1] was a strange choice, as opposed to del s[0]. But then I realized your purpose was to avoid having to test if s. Since slicing won't produce an out-of-range error, it's an interesting little trick, though I'm not sure that it's any faster or clearer than test
More
This is good. Using a deque is also a good choice if we expect to process a huge number of commands, but if it's not time-critical, a list does the job.
More
Interesting use of the walrus. I think this could turn out to be really useful if I can remember it and apply it as needed.
More
That does the job. Another possibility is to make a group ([A-Za-z]+) and then use \1 for each repetition of that pattern. Not that I'm an expert. I like the power of re, but I also feel like I'm relearning from scratch it every time I use it!
More
I recognize that I did some unnecessary work creating a sort function that replicates the default sort! Oops. Well, my "New and Improved" solution cuts that stuff out, but I'll leave this here for posterity. Hehe.
More
I've got to give you credit since I've never used the default argument to max before, and thus I've learned.
More
I like your approach, and it's far simpler than how I went about it. It's enlightening. I don't really like the "coverage_heights = [0] * 11" even though it does work within the preconditions. I just would have liked to use the max of x-values (max([build[2] for build in buildings])) to make it exte
More
Interesting, though I was a bit confused at first about how you were popping out a list then inserting back the elements into array to be processed again in subsequent iterations. Ultimately, it does make sense.
More
Ah! It didn't even occur to me to use zip as a way to ensure the lists are of equal length.
More
Cool to see another go at doing this without re. I'm not sure I buy into the named lambda function as a better alternative to putting in two append calls where they fit in (just for readability), but it's cool that there is such variety in the ways we can approach this. And it works!
More
Voodoo! But good. I was looking to see how it would be done without re. It's a bit sneaky the way you got the part() function to do double duty, essentially behaving as two functions in one and packing the two different results into a list.
It has to be admitted that this is somewhat cryptic, in th
More
This was a little hard for me to analyze, but having done the same mission, it made sense to me in the end. The main good thing is I learned from it, particularly the use of the star operator in the assignment right at the beginning. I've never unpacked a list in an assignment this way.
The handlin
More
I can't remember the last time I've seen this use of the tilde operator, but I MUST remember it, as it's quite a convenient little shorthand to use in exactly this kind of problem.
More
You're forcing me to learn a little more about lambda functions and the alias "check" that you used here. It surprised me to see that you could declare pr = primefactors(n) AFTER pr is used in the lambda function, named "check." But it works!
I experimented with this in very primitive form:
More