I think specific, objectively answerable programming-specific questions about hardware specifications are reasonable. Certainly more useful to programmers researching specific issues than a lot of questions we get...
I can't immediately find an MSO discussion on the topic
I also pinged one of their mods in TL for a opinion on if it'd fit better there
Valid point that general hardware spec questions are probably off-topic and it might be a hard line to draw (memory alignment questions are probably fine; TDP probably isn't; is clock speed fine? who knows...)
Can someone review this answer and see if it adds anything to the existing answers or actually answer the question asked. by OP The question is c++ tagged btw.
Am I right in thinking that it's probably fruitless trying to roll back edits by a user who appears to be methodically vandalizing their previous answers. I've mod-flagged one.
@DavidBuck you could both rollback and flag, if that user vandalized multiple answers, the former will save moderators some time, as they won't have to do the rollback when handling the flag
@Adriaan none of those words are watched specifically in Smokey, we have a long list of phrases like "legal services in Noida" but it didn't trigger any of them
I watched "visa consultant" now but feel free to suggest other phrases to add
Duplicate? I don't know any duplicate target for that one, but it's clearly a typo (2 should be changed to 3, don't even know why there's a 2 in the first place if there's a 3 after)
@TylerH My take is, when used appropriately, goto can be incredibly useful. And just rote avoiding it because 'goto bad' and using 'alternate solutions' that turn out less readable than goto would anyway, is not a helpful mindset.
Yes, I'm surprised so many people who are such doomsayers re: goto have clearly never dealt with code with nested loops
chances are if you've ever dealt with nested loops you've also dealt with needing a way to jump out of all of them from some point more than one loop deep
Like yeah, 1 goto, 1 label, vs moving all the code to a new function, making a new bool variable and adding an if statement or && statement to the condition of every loop, like no thanks, I will take the goto
It could be implemented in C++ probably without breaking legacy code, by making break label; mean 'if the statement following the label is a loop, break the loop' etc.
I think Java should totally just add it, since they already reserved a word for it. It is a useful tool to have in my opinion, even though, when abused, can be used to create truly disgusting things.
Ehhhhh, it's certainly not straightforward to do so, and the most compelling case (jumping out of nested loops) is already well-handled by labeled break/continue
Oh, I remember doing that. Allocating multiple items, and then using goto to free() the correct number of items if one malloc() in the middle failed. But now if I am allocating multiple items at once and they would all be deallocated at once, I just use one malloc() call. But I suppose you would not do any of that in Java, which has little/no manual memory management.
Something annoying is having to error check every little file operation and act accordingly. Sometimes I wish file APIs accepted batch-style instructions where I encode a list of operations, submit them to be executed, and they either all succeed or all fail. Probably some technical limitations to that, but would simplify file I/O handling code greatly.
yeah atomic stuff is tricky. if I wanted to do a series of I/O operations that need to either all succeed or all fail, I'd strongly consider just using a SQLite database if at all possible.
@CPlus I'd be sorely tempted (eliminates the possibility of, say, a failure partway through resulting in you having no settings). Does have the downside of making it somewhat less editable by hand, though.
And I find it rather annoying behavior, actually (though I rarely need to do batch operations these days). I'd much rather it work up until it doesn't, skip the operation on that line, and then do the rest. I can fix one row of data easily enough
1. Open file 2. Write to file 3. Close file. What if 1. Succeeds and 2. Fails? Delete the file? What if the delete fails? And what if 2. Succeeds and 3. Fails?
I forget whether 3 is typically doable atomically, but if it's not, you can delete, then rename, and then check before reading whether the new filename exists and do the renaming then
@CPlus we're probably talking about different scenarios. You're talking about sequential, dependent operations. I'm talking about a dataset that you repetitively apply the same operation to
Ah, so there is a problem with the data? Or is like by some anomaly the I/O function responsible for importing a single line of data failed at that seemingly random point?
SQL (at least, SQL Server. I assume MySQL and other flavors are exactly the same in this regard) handles operations like this in batch format. It will try to apply any transformations or data type conversion operations you request, before actually doing it. If the "check" fails for any step or for any row of data in any of the steps, the whole procedure fails
@CPlus Should we delete a working solution that is simply subpar?
> You will have to work it out by using a boolean that you set to false prior to the loop, set to true in the loop if you want to break, plus a conditional break after the nested loop, checking if the boolean was set to true and break if yes.
fair enough, although were the other answers posted at the same time? Or significantly before?
You didn't post any links to the answer(s) it duplicates, so it's hard to tell...
The highest answer I can find that suggests the same idea was posted at basically the same time, just 3 minutes apart
It appears to just be coincidence that one is at a score of -1 and the one from 3 minutes before is at a score of 297 (!) and accepted
Unless there's another older one (like, at least a day older), I'm not sure we should punish the other answer via deletion just because, in essence, their fingers moved a bit slower that day
The accepted one mentions the up-to-par solution alongside the subpar one. The -1 one only mentions the subpar one, and not only that but says 'you will have to' implying that the subpar one is the only solution, which is straight up wrong.
Yeah, I mean, you can describe the algorithm at a high level/in pseudocode, I think, but it can quickly spiral into "post an answer for every language", which is ... bad
(would love a "how to ask and answer language-agnostic algorithm questions" guide)
Regarding this question, Find how many persons can deliver to a location, the OP posts working code but desires to reduce the "time complexity". Is this on-topic, or does it belong on the code-review site? Or even the CS site? Thanks!
@RyanM the answer is probably 'ask on softwareengineering.SE instead'
or math.se
SO is a programming site. If the question isn't in a programming context, or about a given programming language or even a set of languages to choose from, how can it be a "programming" question? If it's not at all about any programming language or paradigm, just about a set of operations, that's a math question or maybe comp sci/software engineering question (if the intent is to enter a programming context somewhere down the line in the future)
otherwise questions about efficient Rubik's cube algorithms you can solve with your hands are also on-topic here