language-agnostic

A travelling salesman that has state

我的梦境 提交于 2020-01-04 06:40:28
问题 Let's say we have a directed graph. We want to visit every node exactly once by traveling on the edges of this graph. Every node is annotated with one or more tags; some nodes may share tags, and even have the exact same set of tags. As we go along our walk, we are collecting a list of every distinct tag we have encountered - our objective is to find the walk which postpones acquisition of new tags as much as possible. To restate this as a traveler analogy, let's say that a carpet salesman is

Bounding boxes in coordinate system based on right triangle quadrants of square tiles

安稳与你 提交于 2020-01-04 05:12:44
问题 I'm creating a 2D, tile-based system of terrain for a game. However, I'm also using in-game coordinates that need to be able to map a bounding box into the "tile coordinates" and hit each tile the bounding box touches (don't worry, have a kd-tree and all that working fine). Using fixed point "real world" coordinates, I can make each tile count as 2^n of them and simply right shift the bits off to truncate down to tile coordinates. I form a bounding box using the smallest x,y pair and the

how does a non-blocking event loop work?

∥☆過路亽.° 提交于 2020-01-04 04:08:12
问题 Twisted has a "non-blocking" event loop. I understand what a blocking event loop does (sort of, from the Wikipedia page) but can't figure out how a non-blocking one does. 回答1: while (true) wait_for_events handle_events Basically, non-blocking event loop utilizes device that allows for waiting for multiple events simultaneously ( select / poll on UNIX, WaitForMultipleEvents on Windows, epoll on Linux kqueue on FreeBSD etc). In each iteration of main loop, events (file descriptors, timers etc)

Worst Case Time Complexity for an algorithm

孤街醉人 提交于 2020-01-04 02:19:09
问题 What is the Worst Case Time Complexity t(n) :- I'm reading this book about algorithms and as an example how to get the T(n) for .... like the selection Sort Algorithm Like if I'm dealing with the selectionSort(A[0..n-1]) //sorts a given array by selection sort //input: An array A[0..n - 1] of orderable elements. //output: Array A[0..n-1] sorted in ascending order let me write a pseudocode for i <----0 to n-2 do min<--i for j<--i+1 to n-1 do ifA[j]<A[min] min <--j swap A[i] and A[min] -------

Integration testing - seeking your knowledge, advice and links!

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 01:52:06
问题 Hey guys, I'm after some advice and pointers on integration testing for a web app. Our project has been running for a number of years and it's reasonably complex. We're pretty well covered with unit tests but we're missing a decent set of integration tests. We don't have documented use cases or even a reasonable set of test cases beyond our unit tests. 'Integration testing' today consists of the developer's knowledge of the likely impact of a change and manual, ad-hoc testing of the app. It's

should I write more descriptive function names or add comments?

∥☆過路亽.° 提交于 2020-01-03 17:05:42
问题 This is a language agnostic question, but I'm wandering what people prefer in terms of readability and maintainability... My hypothetical situation is that I'm writing a function which given a sequence will return a copy with all duplicate element removed and the order reversed. /* *This is an extremely well written function to return a sequence containing *all the unique elements of OriginalSequence with their order reversed */ ReturnSequence SequenceFunction(OriginalSequence) {...} OR

Is there a way to obtain IExplorerBrowser interface of running or newly open explorer window for subsequent BrowseToXXX call?

孤街醉人 提交于 2020-01-03 16:49:47
问题 Asking because in the previous question i was pointer to IExplorerBrowser, however it creates a child window, while Explorer's "Find Target..."behaviour i want to simulate (see previous) exhibits some level of control over newly open or existing Explorer window (i believe that right term is folder view, feel free to correct). Also looking for other API(s) to accomplish BrowsingTo or similar behaviour. 回答1: This isn't possible. See Raymond Chen's blog post on the subject. 来源: https:/

Automatic tracking algorithm

会有一股神秘感。 提交于 2020-01-03 08:41:36
问题 I'm trying to write a simple tracking routine to track some points on a movie. Essentially I have a series of 100-frames-long movies, showing some bright spots on dark background. I have ~100-150 spots per frame, and they move over the course of the movie. I would like to track them, so I'm looking for some efficient (but possibly not overkilling to implement) routine to do that. A few more infos: the spots are a few (es. 5x5) pixels in size the movement are not big. A spot generally does not

What does Exclusive in XOR really mean?

北慕城南 提交于 2020-01-03 07:18:19
问题 Maybe this is just obvious to everyone but can someone explain where XOR (or Exclusive-OR) got its name from? What does the word Exclusive really mean? Not that it matters, but its just stuck in my head since morning. OR: 0 0 0 0 1 1 1 0 1 1 1 1 XOR: 0 0 0 0 1 1 1 0 1 1 1 0 Is it "exclusively 0 for inputs 1,1", "special version of OR" or something else? 回答1: XOR is an "exclusive OR" because it only returns a "true" value of 1 if the two values are exclusive, i.e. they are both different. 回答2:

Getting the path & filename of the open document in any Windows application

情到浓时终转凉″ 提交于 2020-01-03 05:21:13
问题 Goal Let me start with my final vision of what I'd like to be able to do first: In Windows, I'd like to be able to use a global keyboard shortcut that I define (say, Ctrl + Alt + C ) to copy the full path and filename of the open document in the foreground application to the clipboard. This would be useful to, for example, be able to subsequently paste the path & filename into an "Open File" dialog in an email client to attach that document to an email, without having to manually browse to