Beautiful examples of bit manipulation
What are the most elegant or useful examples of bit manipulation you have encountered or used? Examples in all languages are welcome. ...
What are the most elegant or useful examples of bit manipulation you have encountered or used? Examples in all languages are welcome. ...
Suppose you were able keep track of the news mentions of different entities, like say "Steve Jobs" and "Steve Ballmer". What are ways that could you tell whether the amount of mentions per entity per a given time period was unusual relative to their normal degree of frequency of appearance? I imagine that for a more popular person like...
I'm looking for web app frameworks and/or database administration tools, either popular and unpopular, written in any language, for any relational database. In short, I'm looking for web accessible CRUD front-ends with minimal programming effort. For example: phpMyAdmin (MySQL administration tool) Ruby on Rails (web app framework wit...
The Challenge The shortest code by character count that takes a single input integer N (N >= 3) and returns an array of indices that when iterated would traverse an NxN matrix according to the JPEG "zigzag" scan pattern. The following is an example traversal over an 8x8 matrixsrc: Examples (The middle matrix is not part of the input...
I have multiple binary trees stored as an array. In each slot is either nil (or null; pick your language) or a fixed tuple storing two numbers: the indices of the two "children". No node will have only one child -- it's either none or two. Think of each slot as a binary node that only stores pointers to its children, and no inherent v...
I just want to know some bad programming practice or code I should avoid to make sure it does not exist in my code. I use c# asp.net but the example you give can be in any language since the idea is still the same. I have follow many suggestions on SO that really cleaned my code up. Now I looking to launch my application and want to make...
Sometimes integration tests are rather complex to write or developers have no enough time to check output - does it make sense to write tests that make sure "no exceptions are thrown" only? Such tests provide some input parameters set(s) and doesn't check the result, but only make sure code not failed with exception? May be such tests a...
I'm asked to find a 2 approximate solution to this problem: You’re consulting for an e-commerce site that receives a large number of visitors each day. For each visitor i, where i € {1, 2 ..... n}, the site has assigned a value v[i], representing the expected revenue that can be obtained from this customer. Each visitor i is shown one ...
I'm looking for Java libraries/applications which are parallel and feature objects that can be queried in parallel. That is, there is/are objects in which multiple types of operations can be made from different threads and these will be synchronized. It would be helpful if someone could ideas of where I could find such applications as w...
Once again, I find myself with a set of broken assumptions. The article itself is about a 10x performance gain by modifying a proven-optimal algorithm to account for virtual memory: On a modern multi-issue CPU, running at some gigahertz clock frequency, the worst-case loss is almost 10 million instructions per VM page fault. If...
Has there been studies on the most powerful language? ...
How can you go about modelling an object that can have multiple simultaneous states? For example, you could have a person that's waiting for a bus. That's one state. But they could also be reading a newspaper while waiting for the bus. Furthermore, they could be thinking about something while reading the newspaper. They could also be sn...
I've been trying to learn how to use the APIs available out there, but I can't seem to find any good book or tutorial out there. So... where can I start learning about using the available APIs (e.g. Twitter API)? I've only gone to Wikipedia so far. ...
Given a few sample points on a bézier curve, is it possible to work out the set of possible curves these points may lie on? In my specific application there is a limited set of endpoints the curve may have, so I want to generate the set of possible curves, enumerate all of them and pick out all the ones which may end on a valid end poin...
When talking about a stack in either computing or "real" life we usually assume a "first on, last off" type of functionality. Because the idea of a stack is based around something in the physical world, does it matter how the data in the stack is stored? I notice in a lot of examples that the storage of the stack data is quite often do...
Code Golf: Rotating Maze Make a program that takes in a file consisting of a maze. The maze has walls given by '#'. The maze must include a single ball, given by a 'o' and any number of holes given by a '@'. The maze file can either be entered via command line or read in as a line through standard input. Please specify which in your s...
The Problem: I have a large double (2d) array populated with various labels. Each element (cell) in the double array contains a set of labels and some elements in the double array may be empty. I need an algorithm to cluster elements in the double array into discrete segments. A segment is defined as a set of pixels that are adjacent wi...
Possible Duplicates: Public Data members vs Getters, Setters Purpose of private members in a class What is the use of getters and setters when you can just make your variables public and avoid the hassle of such lines as A.setVariableX(A.getVariableY())? ...
Many random-number generators return floating numbers between 0 and 1. What's the best and correct way to get integers between a and b? ...
I'm in the beginning of starting a small open source project. When cloning the main repository one gets a complete build environment with all the libraries and all the tools needed to make an official installer file, with correct version numbers. I like the fact that anyone who wants to contribute can clone the repository and get starte...