<![CDATA[Programmer's Town - Etudes for Programmers]]>
http://www.progtown.com/
Wed, 14 Dec 2016 22:18:00 +0000PunBB<![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<![CDATA[Almost Hanoi towers]]>
http://www.progtown.com/topic2043876-almost-hanoi-towers.html
The task. Almost Hanoi towers time Limit 1. The game field represents sequence from N columns on K i counters in everyone. For one course from a column with number N i it is possible to take away and move on m counters to an adjacent left and right column. (2 * m <= K i) from extreme left and right columns it is authorized to move counters only to one of adjacent accordingly. Define what least amount of the allowed courses it is necessary to fulfill, that in each column there was an equal amount of counters. It is guaranteed that the TOTALS (K i) / N always an integer number. The input data the First line of an input file contains number N - an amount of columns. Next line it is written down K i - amounts of counters in each of columns. (I belongs [1: N]) (2<=N<=200) (0<=Ki<=2000) the Initial data the Output file should contain one number - the minimum quantity of the allowed courses. Input.txt Output.txt 5 7 5 2 4 8 16 Remark a column 3 we take on 2, a column 2 we take on 2, a column 5 we take 16, a column 4 we take on 13, a column 3 we take on 7, a column 5 we take 12, a column 4 we take on 6. My idea of the decision: It is given: 1) a vector of counters v = {5 2 4 8 16} 2) maxFish = the TOTALS (K i); Algorithm: to "weigh" left left and right right half of vector calculating for each side suma (v [i]-maxFish) / N if left <right then For each column i (from left to right) f (i) =f (i-1) + (an amount of courses for Noi). Otherwise For each column i (from right to left) f (i) =f (i-1) + (an amount of courses for Noi). answ = f (n) the Question: how it is possible to receive the task answer faster?]]>Thu, 03 Nov 2016 08:33:00 +0000http://www.progtown.com/topic2043876-almost-hanoi-towers.html<![CDATA[How economically to analyze the graph]]>
http://www.progtown.com/topic2038410-how-economically-to-analyze-the-graph.html
Time limit 1. Constructed new school. The school contains N the offices enumerated from 1 to N, between some of them doors. When the pupil transits through a door, it receives a certain amount of knowledge. The input in school is in an office 1, and an output in N. Each pupil transits school exactly once and arrives in certain high school depending on the typed points (at an input in school this point is equal to zero). Your task to show the best result. The input data the First line of an input file contains integer numbers N (1 <= N<=2000) - an amount of offices and M (1<=M<=10000) an amount of doors. In each of following M of lines the door description contains: office number from which and in which they conduct, and also the integer number which defines an amount of knowledge received at passage through a door (this number on the unit does not exceed 10000). Doors can conduct from an office in that office, between two offices can be more than one door. The initial data In the output file deduce "yes" - if it is possible to receive beyond all bounds a large supply of knowledge, "no" - if it is impossible to transit school, and the maximum quantity of knowledge an opposite case. That is clear: 1) oriented graph 2) is set if there are no loops and cycles, the graph - coherent then 1 - a source, N - a sink, and the decision is we received loops or a cycle (check by algorithm bfs or dfs) where the total after arcs is positive - then "yes" 4) if between 1 are algorithm of "finding of the maximum flow" 3) if and N there is no way (algorithm bfs or dfs), then "no". That causes a question: if to apply all these algorithms for "the big" graph preliminary check on acyclicity, connectivity check can occupy a lot of time. On what it is possible (within the limits of a task in view) - to spare?]]>Tue, 25 Oct 2016 07:19:00 +0000http://www.progtown.com/topic2038410-how-economically-to-analyze-the-graph.html<![CDATA[Hare]]>
http://www.progtown.com/topic2038411-hare.html
In small fit there lives a hare. Jumping out of a hole and running on snow, it left traces. To define where there is a hare. The input data the Card of driving of a hare is set N (1<=N<=100) by lines which contain sequence of capital Latin letters the first letter whence the following where. Output data Deduce sequence of letters in a column in ascending order which specify a possible location of a hare if the card cannot be driving of a hare to deduce NO SOLUTION. An example 10 B C D K M A C D K L D L R K L Q N M M N A A P N N P Q P R L L R R P Answer B L the Question, whether the understanding of an example that is correct: 1) the way part is B-> C-> D-> K-> M-> A-> P-> R-> L-> Q-> N | |--------------- 2) "Deduce sequence of letters... In ascending order" - means, what topological sorting where L receives smaller number, than And though both peaks are in one cycle beforehand is fulfilled? 3) NO SOLUTION - the answer when there is no way on which it is possible to transit all peaks (in an example - quitting from In it is possible to visit all peaks)?]]>Tue, 25 Oct 2016 07:03:00 +0000http://www.progtown.com/topic2038411-hare.html<![CDATA[Re: problems from the headhunter]]>
http://www.progtown.com/topic2038413-re-problems-from-the-headhunter.html
Hello, Kodt, you wrote: On article with as it was clarified, unsuccessful decisions of problems https://habrahabr.ru/post/311908/I Suggest to knead a head independently. So the Task 1 equality in which digits are replaced with letters Is given: rqr + rqq = sqr. Find how many at it decisions if to various letters there correspond various digits (leading zero in number does not happen). With running start dared . In the image: q = 0, s = 2r it is possible . Remaining I will look then.]]>Tue, 18 Oct 2016 14:30:00 +0000http://www.progtown.com/topic2038413-re-problems-from-the-headhunter.html<![CDATA[Re: to find the superfluous]]>
http://www.progtown.com/topic2037450-re-to-find-the-superfluous.html
Sat, 20 Aug 2016 08:28:00 +0000http://www.progtown.com/topic2037450-re-to-find-the-superfluous.html<![CDATA[How to count probability]]>
http://www.progtown.com/topic2037451-how-to-count-probability.html
Hello! It is not assured that I can correctly count probability even in sober mind, and in passion - especially. Statements of the problem such: There are three football matches, in each of which the recognized favourite against other command which unexpectedly not bad showed itself on tournament start plays. The bookmaker accepts rates with coefficients 1:4, 1:4, 1:9. A question: how correctly to count probability at least to remain at the? One scoring of any of commands-nefavoritov at least pays back loss in other matches. Empirically I estimated that the chance is quite good, and the Author delivered: Marty Date: 01.07 22:11, and it is similar, did not lose. But the mathematical deal too is interesting]]>Tue, 19 Jul 2016 04:03:00 +0000http://www.progtown.com/topic2037451-how-to-count-probability.html<![CDATA[SETI Decryption Challenge]]>
http://www.progtown.com/topic2028369-seti-decryption-challenge.html
Rules we Present that earth dwellers registered a series of signals from a certain source outside of Solar system. Signals proceed from a star which are on distance about 50 luminous years from the Earth and represent long and short electromagnetic waves in very narrow range, with frequency about 452.12919 megahertz. Algorithms SETI found out the nature of signals. Obviously that by means of signals a certain message in the binary code is transferred. Now present that you assigned responsible for decryption of this message. If you correctly decrypted the message, you can answer following questions: 1. What growth our space interlocutors? 2. What duration of their life? 3. What physical scales of technics which they use for message sending? 4. How for a long time they communicate with far stars? 5. What nature of places of their dwelling? 6. How many years to their star system? Rules: 1. You can cooperate with everybody 2. Open arguing (in social networks and on other platforms) is in every possible way encouraged 3. You can address to us and receive 3 helps 4. Send your candidate solutions on my electronic address heller@mps.mpg.de, in twitter (@DrReneHeller) or in facebook (DrReneHeller). Answers in all formats which the person can read are accepted. 5. The list coped with the task (in the chronological order) will be published on June, 3rd, 2016 Update 6 May 2016: the Author mail, be not surprised that he does not answer. However the right answers still are accepted. Update 7 May 2016 E-mails traffic still reads off scale. From this point on helps are not delivered, only answers to the correct or very creative answers. Here three helps mentioned in rules: 1. Number of bits 1902341. This product of three simple 7, 359, and 757. 2. The message this black-and-white image. 3. The image contains 7 pictures or pages. As self-examination, you can recover duration of flight (50 years) from page 4.]]>Thu, 12 May 2016 11:37:00 +0000http://www.progtown.com/topic2028369-seti-decryption-challenge.html<![CDATA[Points on sphere]]>
http://www.progtown.com/topic2027610-points-on-sphere.html
Fri, 29 Apr 2016 17:34:00 +0000http://www.progtown.com/topic2027610-points-on-sphere.html