Posts

uva online judge self describing sequence problem solution python | uva 10049

The self describing sequence problem  (uva 10049) is also very straight forward and easy programming challenge in competitive programming once understood well. Which can be stated as (from online judge) Solomon Golomb’s self–describing sequence ⟨f(1),f(2),f(3),...⟩ is the only nondecreasing sequence of positive integers with the property that it contains exactly f(k) occurrences of k for each k. A few moments thought reveals that the sequence must begin as follows: n 1 2 3 4 5 6 7 8 9 10 11   12 f(n) 1 2 2 3 3 4 4 4 5 5 5 6 In this problem you are expected to write a program that calculates the value of f(n) given the value of n. Sample Input 100  9999  123456  1000000000  0 Sample Output 21  356  1684  438744 Programming Explanation This is very simple problem states that for given range of n ...

uva online judge contest scoreboard problem solution python | uva 10258

The contest scoreboard problem (uva 10258) is very straight forward programming challenge from competitive programming. Which can be stated as (from online judge) Contestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers. A problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties. This means that for every incorrect submission, contestant receive an penalty of 20 mins. Maximum number of problems solved by contestant in any submission is considered as final problems solved. Our ...

uva online judge poker hands problem solution python | uva 10315

The Poker Hands  is a lengthy, tricky and one of the most interesting programming challenge in competitive programming, which can be stated as (from online judge) A suit of 52 cards card contains each of following card with a value which is one of 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace (denoted 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A ). They are ranked suck that 2 being lowest value and 'A' ace being highest valued card. Poker hand game can be played as follows: 1) Each player has 2 cards and 3 card are placed common for all on table facing downwards. 2) At start by seeing their 2 cards players can choose weather to continue playing or not. 3) At each round, one of the card from table is faced upward and let players decide again to continue or quit. 4)Finally when all three cards are faced up, then players can compare their two card and common 3 cards (i.e 5 cards pair) by poker hands order given below. Poker hands are ranked by the following par...

uva online judge jolly jumper problem solution python | uva 10038

The jolly jumper problem (uva 10038) is a sequence problem, stated as (from onlinejudge) A sequence of n > 0 integers (n is number of integers) is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n−1. For instance, 1 4 2 3   is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. But don't get confuse with this example, many students get confused and end up thinking jolly jumper difference must be in decreasing order. This is totally wrong!!. Any sequence with N as length of that sequence, then if all the absolute differences are in range of 1 to N-1 then it is said to jolly jumper. Example, 4 3 4   is a jolly jumper, since 3 is length of sequence and absolute differences 1 (|4-3|),  1 (|3-4|) are lies between 1 to N-1 i.e 1 to 2 (since N = 3). 3 -1 5 is not a jolly jumper, since 3 is length of sequence  (N=3) and absolute differ...

uva online judge australian voting problem solution python | uva 10142

The australian voting problem is little tricky but very easy problem, which can be stated as, Australian ballots require that the voter rank the candidates in order of choice. Initially only the first choices are counted and if one candidate receives more than 50% of the vote, that candidate is elected. If no candidate receives more than 50%, all candidates tied for the lowest number of votes are eliminated. Ballots ranking these candidates first are recounted in favour of their highest ranked candidate who has not been eliminated.  This process continues [that is, the lowest candidate is eliminated and each ballot is counted in favour of its ranked non-eliminated candidate] until one candidate receives more than 50% of the vote or until all candidates are tied. Sample Input 1 3  John Doe  Jane Smith  Sirhan Sirhan  1 2 3  2 1 3  2 3 1  1 2 3  3 1 2 Sample Output John Doe Explanation In australian voting...

uva online judge the trip problem solution python | uva 10137

The Trip problem (uva 10137) is a very interesting mathematical operation problem, which can be stated as (from onlinejudge) A number of students are members of a club group agrees in advance to share expenses equally, but it is not practical to have them share every expense as it occurs. So individuals in the group pay for particular things, like meals, hotels, taxi rides, plane tickets, etc. After the trip, each student’s expenses are tallied and money is exchanged so that the net cost to each is the same, to within one cent. Challenge is to find minimum amount required to exchange so that total spend can be equally divided. Sample Input 3  10.00  20.00  30.00  0 Sample output $10.00  Explanation For given first lined input, number of students followed by their spends, we have to sum up all and find the minimum amount which can be exchanged in order to equally distribute it among students. Pretty straight forward solution given as ...

uva online judge minesweeper problem solution python | uva 10189

Image
The minesweeper problem (uva 10189) is a loop programming problem states that (from onlinejudge) The goal of the game minesweeper  is to find where are all the mines within a m * n field. The game shows a number in a square which tells you how many mines there are adjacent to that square. In this problem, given  a line indicating '*' as bomb and '.' as empty box we have to calculate the number of bombs placed adjecent to each box and replace '.' with number of bombs. In above game example, we have to find number of bombs in adjecent boxes marked by black lines. Once number of bombs founded, replace value of center box with number of bombs. That's it. Sample Input    4 4     *...      ....      .*..      ....      3 5      **...      .....      .*...     0 0 Sample Output Field #1...

uva online judge 3n+1 problem solution python | uva 100

3n+1 problem (uva 100) is basically an even odd problem which can be stated as (from onlinejudge) Consider the following algorithm:            1. input n             2. print n             3. if n = 1 then STOP             4. if n is odd then n ←3n + 1             5. else n ←n/2             6. GOTO 2  Given the input 22, the following sequence of numbers will be printed            22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 It is conjectured that the algorithm above will terminate (when a 1 is printed) for any integral input value . Despite the simplicity of the algorithm, it is unknown whether this conjecture is true. It has been verified, however, for all integers n such that 0 < n < 1, 000, 000 (and, in fact, for many mo...

Popular posts from this blog

uva online judge the trip problem solution python | uva 10137

uva online judge jolly jumper problem solution python | uva 10038

uva online judge self describing sequence problem solution python | uva 10049