<![CDATA[Programmer's Town - Etudes for Programmers]]>
http://www.progtown.com/
Fri, 03 Mar 2017 06:58:00 +0000PunBB<![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<![CDATA[We transpose a matrix in place]]>
http://www.progtown.com/topic2049896-we-transpose-a-matrix-in-place.html
Fri, 13 Jan 2017 05:05:00 +0000http://www.progtown.com/topic2049896-we-transpose-a-matrix-in-place.html<![CDATA[Children's problem for the missing]]>
http://www.progtown.com/topic2049897-childrens-problem-for-the-missing.html
There are two rectangles one with the sides a, b and the second with the sides c, d It is necessary to write check function: whether it is possible to allocate the second in the first]]>Fri, 06 Jan 2017 17:21:00 +0000http://www.progtown.com/topic2049897-childrens-problem-for-the-missing.html<![CDATA[Re: wood of even trees]]>
http://www.progtown.com/topic2049899-re-wood-of-even-trees.html
Hello, Kodt, you wrote: https://www.hackerrank.com/challenges/even-tree It is given: a tree (the coherent acyclic graph) from N peaks. To find the maximum quantity of edges which should be deleted that in the turned out wood all trees consisted of an even number it is possible to delete so that in the turned out wood all trees consist of an even number of peaks. Fixed. An input: an amount of peaks N, an amount of edges M, and further the list from M edges in a type of pairs peaks (where peaks are enumerated from 1 to N) the Output: the amount of remote edges Like all is simple. If N odd, the answer 0. Otherwise, we consider numbers of peaks in subtrees (recursively from a root to leaves). As soon as we type "the even" subtree, we cut off it, increasing result. Complexity - O (N).]]>Wed, 21 Dec 2016 08:16:00 +0000http://www.progtown.com/topic2049899-re-wood-of-even-trees.html<![CDATA[To arrange players on commands]]>
http://www.progtown.com/topic2047024-to-arrange-players-on-commands.html
Is N players. It is necessary to arrange them on M commands, on K to the player in each command (for convenience, N shares on M without residual, i.e. M*K = N) For each player its level which is defined by number (we tell, from 0 to 1000) is known. Command level is defined as the total of levels of players of it. The task - to arrange players on commands so that all commands were as more as possible identical. I.e. it is necessary to minimize the maximum deviation from middle tier.]]>Wed, 14 Dec 2016 22:18:00 +0000http://www.progtown.com/topic2047024-to-arrange-players-on-commands.html<![CDATA[Re: an etude or not an etude]]>
http://www.progtown.com/topic2043870-re-an-etude-or-not-an-etude.html
Hello, , you wrote: the familiar girl of the junior on java filled up on interview by the following problem: and who your girlfriend, the Black woman or a cat? Possibly from it it is necessary to be repelled]]>Wed, 30 Nov 2016 06:08:00 +0000http://www.progtown.com/topic2043870-re-an-etude-or-not-an-etude.html<![CDATA[To lay out matches min and max number]]>
http://www.progtown.com/topic2043871-to-lay-out-matches-min-and-max-number.html
Mon, 21 Nov 2016 08:21:00 +0000http://www.progtown.com/topic2043871-to-lay-out-matches-min-and-max-number.html<![CDATA[The interesting and vital task with the useful result]]>
http://www.progtown.com/topic2043872-the-interesting-and-vital-task-with-the-useful-result.html
So useful that is quite possible, someone already solved it and laid out as function in any library. It is given: a picture of the arbitrary form on a canvas with the sizes *Y. We consider that coordinates of the left upper corner of a canvas 0,0. The task: to Find the maximum sides of a rectangle with the given ratio of the sides k, completely being in a picture. [Length of the horizontal side of a rectangle] / [length of the vertical side of a rectangle] =k. Function should return an array from three numbers: 1-2) r [0], r [1] - coordinates of the upper left corner of a rectangle on a canvas. 3) r [2] - length of the horizontal side of a rectangle.]]>Wed, 16 Nov 2016 02:44:00 +0000http://www.progtown.com/topic2043872-the-interesting-and-vital-task-with-the-useful-result.html<![CDATA[The simple task or...?]]>
http://www.progtown.com/topic2043874-the-simple-task-or.html
The maximum operating time on one test: 2 seconds the Maximum memory size: 256 MB Are set n various tasks. And, to do some jobs it is possible only after others are fulfilled. For each task it is defined, how many minutes are necessary, that it to fulfill. As to carry out in time all tasks it does not turn out, therefore the decision to make all tasks except one - because of one outstanding task of problems does not arise. Now it is necessary to select, what task not to fulfill, that other tasks to fulfill as soon as possible. A format of an input file the First line of an input file contains integer numbers n and m - an amount of tasks and an amount of dependences between tasks (1 <= n <= 100, 0 <= m <= 1000). The second line contains n integer numbers: t 1, t 2..., t n. The number t i means an amount of the minutes necessary for performance of i tasks (1 <= t i <= 1000). Further goes m lines, each of which contains two integer numbers. Numbers an and b mean that an it is necessary to fulfill the task earlier, than the task b. It is guaranteed that all tasks can be fulfilled. An output file format to Deduce one number - the minimum quantity of the minutes necessary for performance of all tasks except one. input.txt output.txt 5 5 11 1 2 3 4 5 1 2 5 3 1 3 3 4 2 4 in the given example it is possible not to carry out the fourth task. All remaining tasks will be fulfilled for 11 minutes. From the job and an example follows: 1) the graph where each peak has the weight is given; 2) it is necessary to discard 1 peak so that: all remaining peaks remained accessible in the column; on the remained peaks - minimum. My decision: 1) to find Suma - scales for all peaks; 2) to create the list of all peaks-leaves; 3) under the list of peaks-leaves: if (minSuma> Suma - (peak-leaf weight)) then minSuma = Suma - (peak-leaf weight) the Key moment of my decision: search of peaks-leaves which as it is represented to me, it is possible to fulfill in time About (1). A question: 1) whether provides a condition not only the acyclic graph, but also wood from such graphs? 2) whether really such algorithm all task, and not just the resulted example dares: whether it is correct, what I focus attention only on peaks-leaves?]]>Tue, 15 Nov 2016 03:21:00 +0000http://www.progtown.com/topic2043874-the-simple-task-or.html