#K52427. Rearranged Digits Number Formation

    ID: 29307 Type: Default 1000ms 256MiB

Rearranged Digits Number Formation

Rearranged Digits Number Formation

You are given a list of jumbled digits (each digit is provided as a string) and a target integer number. Your task is to determine if the jumbled digits can be rearranged to form the target number exactly.

For example, if the given digits are 5 2 3 1 and the target number is 1235, then the answer is True because these digits can be rearranged to form 1235. However, if the digits given are 3 1 4 2 and the target is 1235, the answer is False.

Note: Leading zeros are significant. That is, if the target number has no leading zeros, the jumbled digits must also not create extra zeros when rearranged. Formally, if we let \( D \) be the sorted list of digit characters from the input and \( S \) be the sorted list of characters from the string representation of the target number, then you should output True if and only if \( D = S \).

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains the jumbled digits separated by a single space.
  • The second line contains the target number (an integer).

Example:

5 2 3 1
1235

outputFormat

Output to standard output (stdout) a single line containing True if the digits can be rearranged to form the target number exactly, or False otherwise.

Example:

True
## sample
5 2 3 1
1235
True