<![CDATA[Programmer's Town - Etudes for Programmers]]>
http://www.progtown.com/
Thu, 02 Feb 2017 07:47:00 +0000PunBB<![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<![CDATA[The task about eggs]]>
http://www.progtown.com/topic2043873-the-task-about-eggs.html
Mon, 14 Nov 2016 15:08:00 +0000http://www.progtown.com/topic2043873-the-task-about-eggs.html<![CDATA[The Little Red Riding Hood and Grey Wolf]]>
http://www.progtown.com/topic2043875-the-little-red-riding-hood-and-grey-wolf.html
Time limit 1. The Little Red Riding Hood hastens to visit the sick grandmother and to carry to it medicines and meal. Its way lies through dense wood which is broken into squares. From a square it is possible to get to a square only moving upwards, downwards, to the left or to the right. For wood limits it is impossible to quit, wood is surrounded by an impassable bog. Wood has the rectangle form in which N lines and M columns. The Little Red Riding Hood lives in left upper to a corner of this wood, and its grandmother - in the right lower. The house of the grandmother is protected by hunters. That wood the Grey Wolf whom very much it is necessary to be careful to the Little Red Riding Hood wanders. Fortunately, the home position and its route to it are known. For what least amount of steps the Little Red Riding Hood can achieve the object, observing at driving such rules (the step is a relocation from a cell in an adjacent cell): 1. It is possible to move only in adjacent across or verticals the free cell. 2. Relocation is carried out in turn: at first the Grey Wolf, then the Little Red Riding Hood. 3. Finding in one square of the Little Red Riding Hood and the Grey Wolf is not admitted. 4. Courses of the Little Red Riding Hood and the Grey Wolf are mandatory. 5. If courses of the Grey Wolf ended, it remains in the last reached cell. But it is in advance known that it thus does not block a way of the Little Red Riding Hood to the grandmother. If the Grey Wolf reached finish (a square in which there lives the grandmother) he is killed by hunters. The input data In the first line field size: two numbers through a gap 0 <N, M<=150. Further goes N lines in each of which on M the characters describing a field: a point (.) - The cell is free. A grid (#) - an impassable cell. Next line two numbers - row number and a column where initially there is a Grey Wolf. Further there is a line with the description of a way of the Grey Wolf: R - driving to the right, L - to the left, U - upwards, D - downwards. An amount of courses of the contender no more than 32000. The initial data Singular - the minimum number of steps necessary for achievement of finish. 3 5..... .#... ...#. 1 2 RRLDRRD the answer: 8 As it is represented - here it is possible to use wave algorithm (bypass at width) Truth arises disturbing sensation that to a statement of the problem there can correspond a situation: sees that faces with , recedes on some steps, passing a wolf, and then moves further. Whether be valid can such intellectual in this task? If yes, in what modification of wave algorithm consists? Or here absolutely other approach is necessary? Program performance - 1.]]>Fri, 11 Nov 2016 09:05:00 +0000http://www.progtown.com/topic2043875-the-little-red-riding-hood-and-grey-wolf.html