<![CDATA[Programmer's Town - Etudes for Programmers]]>
http://www.progtown.com/
Sat, 08 Apr 2017 15:28:00 +0000PunBB<![CDATA[Output path]]>
http://www.progtown.com/topic2056974-output-path.html
Greetings to all! Once for a long time heard such task: someone appeared in wood without any navigation instruments and he needs to come out of the wood. On what path it needs to move, that is guaranteed to come out of the wood and also that it was an optimal path. Something such seems... Precisely I do not remember. Who knows this task prompt as it what its strict mathematical decision, is precisely formulated also!]]>Sat, 08 Apr 2017 15:28:00 +0000http://www.progtown.com/topic2056974-output-path.html<![CDATA[Rational numbers]]>
http://www.progtown.com/topic2056975-rational-numbers.html
Let S is the least set of rational numbers containing number 0 and satisfying condition: * If numbers p and q belong S, and |p-q | <1 the number (p+q+1)/2 also belongs S. To write the program which accepts a rational number and defines, whether it belongs to set S.]]>Fri, 07 Apr 2017 06:24:00 +0000http://www.progtown.com/topic2056975-rational-numbers.html<![CDATA[Superfluous equalities]]>
http://www.progtown.com/topic2056976-superfluous-equalities.html
The task of the second class, seemed interesting, to us such for some reason did not set (and it is a pity). Underline "superfluous" equality: 7*7 - 22 = 27 4*4 - 11 = 5 8*8 - 44 = 20 29 - 2*2 = 25 6*6 - 21 = 15 8*5 - 23 = 17 Actually, it was necessary to find at first values of expressions, and then already to search for "superfluous". It is required to find one superfluous, but the teacher allows to find some "superfluous". All variants of "superfluous" equalities now are just interesting to us. Variants "in studio". P.S. I think, it is clear that such equality which possesses some property is superfluous, thus others do not possess it.]]>Thu, 06 Apr 2017 03:19:00 +0000http://www.progtown.com/topic2056976-superfluous-equalities.html<![CDATA[To relieve the person from BigData by means of 5 lines of the code]]>
http://www.progtown.com/topic2056977-to-relieve-the-person-from-bigdata-by-means-of-5-lines-of-the-code.html
Subject a bit cheerful, on it not in algorithms. Particulars: https://habrahabr.ru/post/324772/it is short. It is necessary for the person ID-shki in format XX000000, where XX - two letters of the Latin alphabet, 0 - number from 0 to 9. A principal condition - that damned competitors could not ID calculate under number how many all clients in basis. Competitors can do records on purpose to receive n ID, going successively. For the person the task seemed mega-difficult, what even it was necessary to attract this terrible BigData which neither the friend nor the enemy in the person does not know. I.e. sorted out all possible variants, mixed, saved in one big = on 20 and then long optimized basis quickly to select these ID. How by means of the genius of engineering thought and 5-10 lines on the pseudocode to relieve the person from big and BigData?]]>Tue, 04 Apr 2017 22:53:00 +0000http://www.progtown.com/topic2056977-to-relieve-the-person-from-bigdata-by-means-of-5-lines-of-the-code.html<![CDATA[Optimization of search of anagrams]]>
http://www.progtown.com/topic2056978-optimization-of-search-of-anagrams.html
Received recently curious job for interview. Here the job text: Anagrams are defined as words with the same length and same number of characters in any order. Eg: bat/tab/abt are anagrams aabb/baba/bbaa/abab - anagrams abcd/abce - are not anagrams (different characters) aaab, aabb - are not anagrams (different character count) Given a list of words - {abcd, bbb, abc, bat, cat, yyyyxxxx, tab, atb, rat, cab, xxyyxxyyxx, atb} Print out the anagram pairs - {{abc, cab}, {bat, tab, atb, atb}} Assuming that the input is of type [a-z], can you optimize the solution. With anagrams all is simple - they easily are if to compare the sorted copies of lines. And here with optimization I and did not understand. I so understand, sense there in generation unique for every line but how to make identical to the different lines containing the same dial-up of letters, I yet did not understand. The colleague looked and told supposedly "about, here all is simple - it is necessary to use prime numbers". If I correctly understand, it is necessary to select prime numbers from this variant from 2 and more (and can and from 3, it is not assured) and to take result of multiplication. But 26 prime number in this variant will be 101, i.e. for everyone ' z ' we need to multiply on 101. Then 6. 7 letters ' z ' give which gets out for limits 64 bit. Prompt, what here would be the correct algorithm? And, what is more interesting - prompt, it is necessary to look at what else useful methods of hash coding better to understand this subject?]]>Tue, 04 Apr 2017 08:48:00 +0000http://www.progtown.com/topic2056978-optimization-of-search-of-anagrams.html<![CDATA[Coloring of a surface of a cube]]>
http://www.progtown.com/topic2056979-coloring-of-a-surface-of-a-cube.html
The daughter from the Olympic Games brought: There is a white cube with the side of 3 cells. Surface cells (54 pieces) can be painted over in black color but so that no two painted over cells adjoined on the side (including lying on different edges). What maximum number of cells can be painted over? The answer is quickly, and here to prove why it maximum - was necessary to break a head. Probably, someone from you finds more simple proof.]]>Fri, 31 Mar 2017 13:32:00 +0000http://www.progtown.com/topic2056979-coloring-of-a-surface-of-a-cube.html<![CDATA[Google Code Jam 2017]]>
http://www.progtown.com/topic2056980-google-code-jam-2017.html
Registration on codejam 2017 is opened: https://code.google.com/codejam/contest/registration Registration comes to an end Sunday, April 9, 2017 2:00 UTC. The schedule here: https://code.google.com/codejam/schedule]]>Wed, 22 Mar 2017 04:19:00 +0000http://www.progtown.com/topic2056980-google-code-jam-2017.html<![CDATA[Search of loops in dependences]]>
http://www.progtown.com/topic2056981-search-of-loops-in-dependences.html
There is a sequence of entities - A, B, a C, D, E, F..... Any essence can comprise the link to any other of this sequence, except itself. Mandatory there is an essence which does not depend from any another. A question two 1) whether How to find is loops in dependences? That is to eliminate cases when In depends from With, With depends from D and And, and D depends from F and B? 2) How to sort this sequence by a principle of dependences? That is the first should stand what on anybody what depend only on the first and so on do not depend, further? However, on the second at me the decision was invented. To enter number for each essence - coefficient of dependences. At what on anybody do not depend - it is equal to zero, and at what - from it is equal (a maximum of coefficient of children + 1). And by this number and to sort. This approach will work? There are no reefs? And here on the first something of anything optimal was not invented, except a heap of searches.]]>Wed, 15 Mar 2017 03:06:00 +0000http://www.progtown.com/topic2056981-search-of-loops-in-dependences.html<![CDATA[Context-free self-described grammar]]>
http://www.progtown.com/topic2053995-contextfree-selfdescribed-grammar.html
Fri, 03 Mar 2017 06:58:00 +0000http://www.progtown.com/topic2053995-contextfree-selfdescribed-grammar.html<![CDATA[How to find all?]]>
http://www.progtown.com/topic2053996-how-to-find-all.html
To find all numbers in decimal numeration with such property: if decimal digits of number to write down upside-down, the same number, only in hexadecimal system turns out. For double-valued numbers: a*10+b=b*16+a ==> a*9=b*15 ==> a = b*5/3 ==> b=3 and =5. Guards that in a statement of the problem it is told "to Find all numbers..." The question: 1) whether there is any upper bound for numbers which satisfy a search criterion; 2) whether there is any numerical regularity for the task decision?]]>Mon, 20 Feb 2017 11:06:00 +0000http://www.progtown.com/topic2053996-how-to-find-all.html<![CDATA[Average load]]>
http://www.progtown.com/topic2049891-average-load.html
Is available identical under the form but mutually various on weight. For one operation it is possible to find on weight from 5 . For what least number of such operations it is possible to find average on weight from 7 ?]]>Thu, 02 Feb 2017 07:47:00 +0000http://www.progtown.com/topic2049891-average-load.html<![CDATA[Reproduction of bacteria]]>
http://www.progtown.com/topic2049892-reproduction-of-bacteria.html
On a quarter of a plane with nonnegative whole coordinates there live bacteria. The bacterium with coordinates (m, n) can be divided two with coordinates (m+1, n) and (m, n+1) but only if these two points were empty. The bacterium thus disappears. During the initial moment of time there is only one bacterium with coordinates (0,0) to Prove that as though bacteria did not share, always there will be at least one with both coordinates <= 2]]>Wed, 25 Jan 2017 08:40:00 +0000http://www.progtown.com/topic2049892-reproduction-of-bacteria.html<![CDATA[To sort the big file]]>
http://www.progtown.com/topic2049893-to-sort-the-big-file.html
All greetings! How to sort a file 2TB with numbers, the size in 32 bits which are written down in it so, what everyone since a new line, having only 2 ??]]>Tue, 24 Jan 2017 05:28:00 +0000http://www.progtown.com/topic2049893-to-sort-the-big-file.html<![CDATA[Single experiment as soil for the general outputs]]>
http://www.progtown.com/topic2049895-single-experiment-as-soil-for-the-general-outputs.html
Hello. We present the elementary task. There is a bag with the full-spheres enumerated from 1 and up to the end. Full-spheres - a casual amount. Examined pushes a hand in a bag and pulls one full-sphere, looks at its number and should try to guess, how many all full-spheres was in a bag. Possibility of a tactile or visual estimation of this amount at the moment of a full-sphere taking it is eliminated. The question - as should argue examined as much as possible precisely to guess an initial amount of full-spheres in a bag on some considerable quantity of independent experiments, in cases, if: 1. The maximum of full-spheres is known (that is examined knows that in a bag equiprobablly from one to N full-spheres). 2. The maximum of full-spheres is, but examined is unknown (the examiner himself solved, how many full-spheres the maximum can be in a bag, but allocation all the same linear). 3. The maximum of full-spheres is not defined absolutely not (I do not know, whether such setting of the task generally has sense). In each experiment an amount of full-spheres in a bag a miscellaneous, but a maximum if it is installed - one.]]>Thu, 19 Jan 2017 05:56:00 +0000http://www.progtown.com/topic2049895-single-experiment-as-soil-for-the-general-outputs.html<![CDATA[To count territory of players in game]]>
http://www.progtown.com/topic2049894-to-count-territory-of-players-in-game.html
Wed, 18 Jan 2017 16:08:00 +0000http://www.progtown.com/topic2049894-to-count-territory-of-players-in-game.html