as I see it, it works like this: (25x3)[WHATEVER IS 25 CHARS]<rest> --> [WHATEVER IS 25 CHARS][WHATEVER IS 25 CHARS][WHATEVER IS 25 CHARS]<rest> --> ...
@alex That depends on what's in bits. Generally, anything that's not "false-ish" will evaluate to True in an if test (or other Boolean context). False-ish values include numeric values of 0 (so integer, float and complex zeros), and empty containers: the empty string, the empty list, tuple, dict, or set. If a container object contains anything, then it's true-ish, so if bit is the string "0" then if bit will be True
I just quelled a comments battle by quoting the docs. :) But I must admit, the behaviour of os.path.join with absolute components is a little surprising if you don't know about it. http://stackoverflow.com/questions/35132342/python-unable-to-save-file-with-slash-in-front-of-name
@AndrasDeak Which part do I allegedly disagree with? I didn't see anything wrong with what you wrote above ..
as long as the markers are taken one-by-one... you shouldn't expand a marker from within a recursion, because the markers can reach beyond their own window
And this is not just my "interpretation", it was confirmed by AoC author
After reading all the stuff in the transcript about unclear instructions for some of the recent AoC puzzles I'm kinda glad I decided not to participate. I hate ambiguous or otherwise poorly-specified problem descriptions.
FWIW, caching can boost performance of recursive functions, but it depends on the nature of the recursion. If it has to re-compute sub-problems, definitely give caching a go. The simple way is to decorate with functools.lru_cache
Doing your own cache with a default arg dict will probably be faster, because decorators give you an extra level of function call, and because lru_cache tracks caching stats. OTOH, those stats can be useful to know, and it's nice to be able to limit the size of the cache if it would otherwise eat too much RAM.
@wim BFS = basic form of search that can also be thought of as Dijkstra's algorithm with all edge weights equal to 1, Dijkstra's algorithm = BFS that can take into account different edge costs, and A* algorithm = like Dijkstra's algorithm except it also uses a heuristic
@wim dijkstra finds the "least expensive path" to many nodes
a* is dijkstra + future nodes are prioritized by a heuristics value...
A* is an informed search algorithm, or a best-first search, meaning that it solves problems by searching among all possible paths to the solution (goal) for the one that incurs the smallest cost (least distance travelled, shortest time, etc.), and among these paths it first considers the ones that appear to lead most quickly to the solution.
and "For the algorithm to find the actual shortest path, the heuristic function must be admissible, meaning that it never overestimates the actual cost to get to the nearest goal node."
your algorithm is dijkstra with constant cost, a kind of BFS.
@thefourtheye I was talking to Bhargav the other day and he told me you were based in Chennai. I've got a team in Chennai but I don't know much about the do's and don't of Chennai. Would you have some link you can share by any chance or some advices...?
@Amposter That's not quite correct: dir() without parameters shows the names in the current namespace. So if you call it inside a function, you'll get the names that are local to that function. To get the stuff that's global to your module you need to call it in the global context, i.e., outside a function.
When I have to return a notebook because I am leaving the job, what is the best way to clean up the notebook without reinstalling the OS? Are there good tools? System recovery (if possible). Does this overwrite the data with zeros?
@RomanLuštrik It isn't my notebook and I am not leaving. It is a friends one. I meet him on Wed and I will ask him. I think the problem nowadays is, that it is hard to work with a notebook all the time and only have company property on it.
@wim I might have lost track of who believes what:D My impression was that our interpretation of the rules is different (then again, for valid inputs, it shouldn't matter)
@AnttiHaapala I was
it might just be due to juggling lists of tuples around...
anyway, I'm happy with my kludge-from-wikipedia answer:D
even if it's godsawful, the fact that it gave the correct answer for first run warms my heart
I'm trying to make a int64_t module for python because python doesn't have a long long type. I found one in ctypes but I can't use it.
So, I have embedded an intro in my application so the best way is to create a module that returns int64_t from c++.
PyObject *Py_int64_t(PyObject *poSelf, PyObje...
@Ramy Numpy has 64 bit integers, both signed and unsigned. But if this is just for pure Python what's the point? As Mark Ransom says in the comment, Python has arbitrary precision integers, and if you need to restrict them to 64 bits that's easy enough to do using an appropriate bit mask.
OTOH, the way Python handles the sign can be a little annoying when doing bitwise operations on fixed-width numbers, but that's only a minor annoyance, and it's easily dealt with.
@RomanLuštrik It was only a little question, so it's ok here. I'd feel guilty winning rep for something that simple. :)
And if you posted it on the main site it'd probably get 5 answers in 5 minutes before someone dupe-hammered it. :)