`
文章列表
Now it comes to the Scale class. The main job of it is to weight both sides. So the class is pretty simple, sum the weights of balls and compare. Now based on these classes, the translation of the algorithm is straight forward: java 代码   package solve;      import scale.Ball;   im ...
The problem is: There is one counterfeit coin among 12 coins. It is unknown whether the counterfeit is lighter or heavier than a genuine coin(all genuine coins weigh the same). Using 3 weighings on a pan balance, how can the counterfeit be identified and determined to be lighter or heavier than a g ...
Programming is an art, the same solution to a problem could have different versions of coding. Enterprise programming, due to its large code base, is about to provide functionalities while managing code dependencies and data encapsulation. The essence of managing dependencies and encapsulation is abs ...
We could add more functionalities, but in separate classes. 1. We may add a class for the following operations: sorting, querying, and merging. java 代码   import java.util.List;      public class DataMatrixRowManipulator   {       public DataMatrix query(String queryString, Dat ...
Though, as I wrote before, it's very hard to come up a universal dynamic data structure to fit all needs, sometimes we still need a somewhat general dynamic data structure due to requirements. For example, the spreadsheet could have as many columns during runtime, we can't determine the number of col ...
Recently, I read two articles about data holders, search the key word 元数据、开放数据模型及动态系统. The scenario is that constantly we need to change the data fields, e.g., add/delete some fields. This task is tedious because usually we need to update a database table, and then add fields in all corresponding cla ...
The roadmap to compute all fixed points of f(x) is to start from boundaries 1, or 10^10, and keep acting f on it. If x is a boundary point, first compare x and f(x) to see whether we should generate the series using f or f inverse. Once we know which one to use, then keep doing that until we get a fi ...
The entire class is as follows: java 代码   /**  * GOOGLE GLAT question #20:  * Consider a function which, for a given whole number n, returns the number  * of ones required when writing out all numbers between 0 and n. For example,  * f(13)=6. Notice that f(1)=1. What is the next ...
Now, we can deduct the recursion formula on digits Lemma 4 Let  n = a_k * 10^k  + a_(k-1) * 10^(k-1) + ....... + a_1 * 10 + a_0 denote the base 10 expansion, then when a_k = 1 (A)   f(n) = f(n - 10^k) + (n - 10^k) + f(10^k) = f(n - 10^k) + (n - 10^k) + k * 10^(k-1) + 1 and when a_k > 1 ...
Question: Consider a function which, for a given whole number n, returns the number of ones required when writing out all numbers between 0 and n. For example, f(13) = 6. Notice that f(1) = 1. What's the next largest n such that f(n) = n? As always, start with simple cases: f(1) = 1, f(2) = 1, . ...
Global site tag (gtag.js) - Google Analytics