2056 - GEC1506-2020 Python Quiz 2 (Advance) Scoreboard

Time

2020/06/09 12:30:00 2020/06/09 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12773 GEC1506 N-gram Sum
12836 GEC1506 - Encoder & Decoder

12773 - GEC1506 N-gram Sum   

Description

Given a line of numbers, you need to calculate the sum of the numbers by n-gram of the line.

An example is demonstrated below.

 

Input

Several lines of text

  1. N for N-gram SUM
  2. Skip size for the N-gram
  3. Numerical text line 1
  4. Numerical text line 2
  5. Numerical text line ...

In the following example, there are four lines.

2

2

12345

1234

 

Note that there is no numerical text line start with the text digit "0."

Output

The sums of all the n-grams of the given numerical text lines.

 

As the N for n-gram is 2 and the skip size is 2, the result of the above example is calculated by

12+34 = 46  (for the line of 12345, 23 and 45 are skipped)

12+34 = 46 (for the line of 1234, 23 is skipped)

Here is an illustration,

Taking another example, if the skip size is 1, the result of the above example is calculated by

12+23+34+45 = 114  (for the line of 12345)

12+23+34 = 69 (for the line of 1234)

Here is another illustration,

Sample Input  Download

Sample Output  Download

Tags




Discuss




12836 - GEC1506 - Encoder & Decoder   

Description

 

In this problem, we will learn how to encode the text and decode the encoded message.

If the characters have the same frequency,  please order them in alphabetical order. 

(Hint: Take into account "space" and use function ord())

Input

 

There are several lines of text, the input is separated into two-part. 

The first part (several lines) which learns the text and encoding rule. 

The second part (one line) is the message for you to decode it.

 

Example Input:

Hello  
John
0000000001011000000000101

 

Note that

1. You can use the function .lower()  to convert the character to lower-case. 

2. Not all elements are characters.

 

Encode:

Please encode the least frequency to '1', and order the characters in alphabetical order.

' ' was encoded it to '1'
'e' was encoded it to '01'

'j' was encoded it to '001'
...

'o' is encode to '000000'

Output

 

Decode:

You need to decode the input number 0000000001011000000000101 to the character.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss