Skip to main content

Posts

Showing posts with the label Strings

URI Problem 2690 Solution New Password RA - URI Online Judge Solution

URI Online Judge Solution 2690 New Password RA Using Python Programming Language.  A new set of authentication will be implemented at the Federal Institute of South of Minas, Muzambinho campus, so users will not have much difficulty, plus you ... Well, the new authentication service is safe, without bugs and headaches even though we are at the end of the semester. It will allow your password to have spaces, but not numbers or special characters. The update always occurs during the vacation period, so tpdps adjustments are made and in the end please all users. As a trainee at the school's support center, your duty is to implement the new authentication. For now the new standard for user names is being studied.  As we can see for each set of letters we will have a specific number. Make a bad program to do this conversion of the letters to the numbers, and since you will not access the passwords of the students, make an algorithm so that the same one does the process alone u...

URI Problem 1257 Solution Array Hash - URI Online Judge Solution

URI Online Judge Solution 1257 Array Hash  Using Python Programming Language. You will be given many input lines with strings. The value of each character in input is computed as follows: Value = (Alphabet Position) + (Element of input) + (Position in Element) All positions are 0-based. 'A' has alphabet position 0, 'B' has alphabet position 1, ... The returned hash is the sum of all character values in input. For example, if input is: CBA DDD then each character value would be computed as follows: 2 = 2 + 0 + 0 : 'C' in element 0 position 0 2 = 1 + 0 + 1 : 'B' in element 0 position 1 2 = 0 + 0 + 2 : 'A' in element 0 position 2 4 = 3 + 1 + 0 : 'D' in element 1 position 0 5 = 3 + 1 + 1 : 'D' in element 1 position 1 6 = 3 + 1 + 2 : 'D' in element 1 position 2 The final hash would be 2+2+2+4+5+6 = 21. Input The input contains many test cases. The first line of input contains an integer N that indicates the amount of test cases...

URI Problem 1234 Solution Dancing Sentence - URI Online Judge Solution

URI Online Judge Solution 1234 Dancing Sentence  Using Python Programming Language. A sentence is called dancing if its first letter is uppercase and the case of each subsequent letter is the opposite of the previous letter. Spaces should be ignored when determining the case of a letter. For example, "A b Cd" is a dancing sentence because the first letter ('A') is uppercase, the next letter ('b') is lowercase, the next letter ('C') is uppercase, and the next letter ('d') is lowercase. Input The input contains several test cases. Each test case is composed by one line that contais a string sentence. This string will contain between 1 and 50 characters ('A'-'Z','a'-'z' or space ' '), inclusive, or at least, one letter ('A'-'Z','a'-'z'). Output Turn the sentence into a dancing sentence (like following examples) by changing the cases of the letters where necessary. All spaces i...

URI Problem 1168 Solution LED - URI Online Judge Solution

  URI Online Judge Solution 1168 LED Using C, Python Programming Language. John wants to set up a panel containing different numbers of LEDs. He does not have many leds, he is not sure if he will be able to mount the desired number. Considering the configuration of the LEDs of the numbers below, make an algorithm that helps John to discover the number of LEDs needed to set the value.  Input The input contains an integer N, (1 ≤ N ≤ 2000) corresponding to the number of test cases, followed by N lines, each line containing a number (1 ≤ V ≤ 10100) corresponding to the value that John wants to set with the leds. Output For each test case, print one line containing the number of LEDs that John needs to set the desired value, followed by the word "leds". Input Sample Output Sample 3 115380 2819311 23456 27 leds 29 leds 25 leds Solution Using Python: Dic = { '0' : 6 , '1' : 2 , '2' : 5 , '3' : 5 , '4' : 4 , '5' : 5 , '6' : 6 ,...

URI Online Judge Solution 1120 Contract Revision

URI Online Judge Solution 1120 Contract Revision using C Programming Language. For years, all contracts of the Association of Contracts for Modernization (ACM) were typed using an old typewriter machine. Recently Mr. Miranda, one of the accountants of the ACM, realized that the machine had a failure in one, and only one, numerical digit. More specifically, the flawed digit, when typed, is not printed on the sheet, as if the corresponding key was not pressed. He realized that this could have changed the numerical representation of contract values. Worried about accounting, Mr. Miranda wants to know, from the original values agreed for the contracts (which he kept in handwritten notes) which values are actually represented in the contracts. For example, if the failed digit in the machine is 5, an agreed value of 1500 would be represented in the corresponding contract as 100, because the digit 5 would not be printed. Note that Mr. Miranda wants to know the numeric value represented...

URI Online Judge Solution 1024 Encryption

URI Online Judge Solution 1024 Encryption using C Programming Language. You have been asked to build a simple encryption program. This program should be able to send coded messages without someone been able to read them. The process is very simple. It is divided into two parts. First, each uppercase or lowercase letter must be shifted three positions to the right, according to the ASCII table: letter 'a' should become letter 'd', letter 'y' must become the character '|' and so on. Second, each line must be reversed. After being reversed, all characters from the half on (truncated) must be moved one position to the left in ASCII. In this case, 'b' becomes 'a' and 'a' becomes '`'. For example, if the resulting word of the first part is "tesla", the letters "sla" should be moved one position to the left. However, if the resulting word of the first part is "t#$A", the letters "$A...