scanf

You have a 128-byte long buffer that is initially filled with zeroes. Given a scanf format string, some offsets in the buffer, and some text, fill the buffer according to the format string and print the final contents of the buffer.

The format string consists of a sequence of directives which describe how to process the sequence of input characters. A directive is one of the following:

  • A sequence of space characters. This directive matches any amount of space characters, including none, in the input.
  • An ordinary character (i.e., one other than white space or '%'). This character must exactly match the next character of input.
  • A conversion specification, which commences with a '%' (percent) character. A sequence of characters from the input is converted according to this specification, and the result is placed in the corresponding position in the buffer (the result of the ith conversion should be stored in the buffer starting at the ith offset).
There are four conversion specifiers:
%u
Matches an unsigned 4 byte long integer. It is stored in the buffer in little-endian order (least significant byte first).
For example, 1241251 (which is 12F0A316) is stored as A3 F0 12 00.
%x
Matches 0x followed by an unsigned 4 byte long hexadecimal integer. It is stored in the buffer in little-endian order.
For example, 0xFEE1DEAD is stored as AD DE E1 FE.
%s
Matches a sequence of non-white-space characters.
For example, hello is stored as 68 65 6C 6C 6F 00
%c
Matches a single character
For example, x is stored as 78

Input

On the first line, a format string and several integer offsets. The format string and offsets are separated by commas. There is no space before or after a comma.
On the second line, the text you should scan.

Output

Exactly 256 uppercase hex digits (0-9A-F) representing the contents of the buffer. You may append a final newline.

Notes

  • The format string is at most 150 characters long.
  • Each position in the buffer will be set at most once. In other words, the memory areas do not overlap.
  • For the %s specifier it is guaranteed that the next character will NOT be a space character.

Sample

InputOutput
Alina are %u %s cu ID:%x,10,100,4
Alina are 3 mere cu ID:0xABCDEF
00000000EFCDAB0000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006D657265000000000000000000000000000000000000000000000000
Things we have here: %c%c%c %s (less than %u units).,0,2,4,5,50
Things we have here: ^_^ word!with!bangs!!! (less than 40000 units).
5E005F005E776F726421776974682162616E6773212121000000000000000000000000000000000000000000000000000000409C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Questions?

Sponsors Gold