<![CDATA[Programmer's Town - Etudes for Programmers]]>
http://www.progtown.com/
Fri, 17 Nov 2017 09:06:00 +0000PunBB<![CDATA[Cool problem]]>
http://www.progtown.com/topic2077653-cool-problem.html
Fri, 17 Nov 2017 09:06:00 +0000http://www.progtown.com/topic2077653-cool-problem.html<![CDATA[Eternal subject: happy tickets]]>
http://www.progtown.com/topic2077654-eternal-subject-happy-tickets.html
The natural number from N digits (<=100) is set. To find minimum happy number which is more the than set. The number is called as happy, if: the total of digits which stand on even positions, is equal to the total of digits which stand on odd positions. It is clear that "moving" from the given number towards magnification it is necessary to construct number-answer. The task, most likely dares through dynamic programming. However, a question: what heuristics here followed use for search abbreviation?]]>Mon, 13 Nov 2017 15:57:00 +0000http://www.progtown.com/topic2077654-eternal-subject-happy-tickets.html<![CDATA[Parameters]]>
http://www.progtown.com/topic2077655-parameters.html
All greetings. Such etude. It is set N (<=500) parameters, each of which can accept value from 1 to 26. Is M (<=500) buttons, pushing each of which changes values of initial parameters (optionally all). Also some starting state of parameters S0 is set. It is required for a dial-up of states S [1. K] (K <=100) to define, whether it is possible to come into fortune Si from state S0 by pushing of some sequence of buttons (buttons can be pushed arbitrary, each button the unlimited number of times can be used). There are ideas? Thanks.]]>Wed, 08 Nov 2017 09:29:00 +0000http://www.progtown.com/topic2077655-parameters.html<![CDATA[Twain levels, the third level and prime numbers]]>
http://www.progtown.com/topic2072387-twain-levels-the-third-level-and-prime-numbers.html
Tue, 26 Sep 2017 16:35:00 +0000http://www.progtown.com/topic2072387-twain-levels-the-third-level-and-prime-numbers.html<![CDATA[To find the amount formula]]>
http://www.progtown.com/topic2072388-to-find-the-amount-formula.html
The square on the screen with square with the side n is given. How to describe such square words, I do not know, but on a picture all should be clear. To find the amount formula in dependence from n: f (n) For example, Here, at n=4 , like, 25. Separate plus that who can correctly describe the task without a picture.]]>Fri, 08 Sep 2017 12:12:00 +0000http://www.progtown.com/topic2072388-to-find-the-amount-formula.html<![CDATA[Re: Pioneers and vodka]]>
http://www.progtown.com/topic2067504-re-pioneers-and-vodka.html
Hello, Kodt, you wrote: the Question: to what strategy the leader should adhere to maximize the advantage a minus costs? Well and accordingly, what pioneers should undertake? About scorings of pioneers from successful drinking in different places you did not tell. I think that for the leader there will be optimal a casual choice of a place of check. The probability of a choice of each place should be different. It is possible to minimize both average and maximum losses from loss.]]>Fri, 01 Sep 2017 07:10:00 +0000http://www.progtown.com/topic2067504-re-pioneers-and-vodka.html<![CDATA[Swap]]>
http://www.progtown.com/topic2067505-swap.html
The task simple, I write it here, that not in other subject: http://rsdn.org/forum/job/6878320.1 the Author: Titus Date: 19.08 11:40 There I I did not ask to solve this task, and asked absolutely about other, but for some reason there write the candidate solutions of this task, and do not write that is required on a subject. Anybody there while and did not offer the simple correct decision. Its canonical form: two whole variables an and b Are given. To make a program fragment after which execution of value of variables would exchange in places. We enter a variable c. c=a; a=b; b=c; solve the previous task, without using an additional variable.]]>Tue, 29 Aug 2017 14:39:00 +0000http://www.progtown.com/topic2067505-swap.html<![CDATA[To find the plane equation minimum remote from a cloud.]]>
http://www.progtown.com/topic2065657-to-find-the-plane-equation-minimum-remote-from-a-cloud.html
There is a cloud of points in 3D. It is necessary to find the plane equation the total distance from which to all points would be minimum. There is a pair of ideas how to make, but who offers that? Or can eat generally on computing geometry. But it is not interesting, it would be desirable variants of algorithms .]]>Sun, 02 Jul 2017 04:13:00 +0000http://www.progtown.com/topic2065657-to-find-the-plane-equation-minimum-remote-from-a-cloud.html<![CDATA[volatile-only lock]]>
http://www.progtown.com/topic2065658-volatileonly-lock.html
To write synchronization between flows, using only volatile variables (at which only a read and write, but not modification)]]>Fri, 30 Jun 2017 06:36:00 +0000http://www.progtown.com/topic2065658-volatileonly-lock.html<![CDATA[Problem on probability theory]]>
http://www.progtown.com/topic2065659-problem-on-probability-theory.html
All greetings! The problem from last year's entrance examination in interested: are Abreast allocated m subjects. Are casually selected k subjects, k <m. The Random variable X is equal to an amount of such subjects i that i is selected, and all its neighbors are not selected. To find mathematical expectation X. I twist some days, there should be rather simple decision, but I it do not see. Tried to build allocation X explicitly, but for this purpose it is necessary to find number of methods to select k subjects so that exactly X from the selected had no selected neighbors. For this amount of methods the difficult recursion is visible only, with explicit expression there are problems. Counted for different k and m statistically, saw that dependence from k well lays down on a cubic parabola... Found it on several points in a general view. But it did not approach me to the analytical decision. If who has ideas, share!]]>Thu, 29 Jun 2017 08:51:00 +0000http://www.progtown.com/topic2065659-problem-on-probability-theory.html<![CDATA[Re: Correction of brackets]]>
http://www.progtown.com/topic2064534-re-correction-of-brackets.html
Hello, Kodt, you wrote: the Problem with , a head to itself broke, - how to make gracefully. It is given: a line, in which there are brackets (one type - round) and other characters. Brackets, probably, unbalanced. It is necessary: to delete the minimum quantity of brackets so that to recover balance. (Well it is simple). And to deduce all possible decisions. For example, "(a) ()) ())) ((b (b)" - three superfluous ")" and two superfluous "("> (a (())) b (b) (a (())) (bb) (a () ()) b (b) (a () ()) (bb) (a ()) () b (b) (a ()) () (bb) (a) (()) b (b) (a) (()) (bb) (a) () () b (b) (a) () () (bb) Quickly somehow so #include <stdio.h> #include <string.h> #include <set> #include <string> using std:: string; struct Check {const char *text; int len; char* mask; typedef std:: set <string> variants_t; typedef variants_t:: iterator variants_it; variants_t variants; int check () {int level=0, rm_close=0, i, r2=0; char c; for (i=0; c=text [i]; i ++) {if (c == ' (') level ++; if (c == ') ') {if (level> 0) level-; else {rm_close ++; mask [i] =c;}}} for (int l2=0; i> =0; i-) {c=text [i]; if (c == ') ') l2 ++; if (c == ' (') {if (l2> 0) l2-; else {r2 ++; mask [i] =c;}}} if (rm_close || level) printf ("\" %s \"- %d superfluous \") \"and %d superfluous \" (\"\n %s\n\n", text, rm_close, level, mask); return rm_close+level;} void insert () {string s; for (int i=0; i <len; i ++) if (text [i]! =mask [i]) s + = text [i]; variants.insert (s);} void right (int pos) {insert (); while (pos> =0 && mask [pos]! = ' (') pos-; if (pos <0) return; char type=mask [pos]; mask [pos] = ' '; for (int i=pos+1; i <len; i ++) {if (mask [i] == ' ' && text [i] == type) {mask [i] =type; right (i-1); mask [i] = ' ';}} mask [pos] =type;} void left (int pos) {right (len-1); while (pos <len && mask [pos]! = ') ') pos ++; if (pos> =len) return; char type=mask [pos]; mask [pos] = ' '; for (int i=pos-1; i> =0; i-) {if (mask [i] == ' ' && text [i] == type) {mask [i] =type; left (pos+1); mask [i] = ' ';}} mask [pos] =type;} void find () {variants.clear (); left (0);} void show_variants () {int i=0; }}; int main (int argc, char ** argv) {enum {mask_max=64}; char mask [mask_max]; const char* list [] = {"(a) ()) ())) ((b (b)", 0}; for (const char ** s=list; *s; s ++) {Check c; c.text =*s; c.len=strlen (*s); c.mask=mask; memset (mask, ' ', c.len); mask [c.len] =0; if (c.check ()) c.show_variants ();} return 0;} "(a) ()) ())) ((b (b)" - 3 superfluous ")" and 2 superfluous "("))) ((1 (a (())) (bb) 2 (a (())) b (b) 3 (a () ()) (bb) 4 (a () ()) b (b) 5 (a ()) () (bb) 6 (a ()) () b (b) 7 (a) (()) (bb) 8 (a) (()) b (b) 9 (a) () () (bb) 10 (a) () () b (b)]]>Mon, 12 Jun 2017 22:50:00 +0000http://www.progtown.com/topic2064534-re-correction-of-brackets.html<![CDATA[How to add in the white list :)]]>
http://www.progtown.com/topic2064535-how-to-add-in-the-white-list.html
Wed, 07 Jun 2017 13:43:00 +0000http://www.progtown.com/topic2064535-how-to-add-in-the-white-list.html<![CDATA[The job from Unified State Examination on computer science]]>
http://www.progtown.com/topic2060427-the-job-from-unified-state-examination-on-computer-science.html
Tue, 30 May 2017 07:45:00 +0000http://www.progtown.com/topic2060427-the-job-from-unified-state-examination-on-computer-science.html<![CDATA[To find all remaining three-digit numbers]]>
http://www.progtown.com/topic2060428-to-find-all-remaining-threedigit-numbers.html
Example. We take, for example, 250 and it is attributed to it 2. We receive 2250. 2250 in 9 times more 250. It is necessary to find all remaining three-digit numbers, at attributing to which in the beginning any digit, the received result would be in 9 times more initial number. Direct search and generally programming do not roll. The common decision is necessary.]]>Thu, 27 Apr 2017 09:29:00 +0000http://www.progtown.com/topic2060428-to-find-all-remaining-threedigit-numbers.html<![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