cswork / OAOpen practice workspace

OracleOA #8

Last and Second-Last

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

Return a new string made of the last character of the string, one ordinary space, and the second-to-last character.

Input

The input is one JSON string whose length, counted in Unicode code points, is 2..100 (the original length bound). The source does not restrict the character set; this site allows all Unicode scalar values, including whitespace, NUL, and non-BMP characters, but no lone surrogate code points. Characters are preserved through JSON encoding, and the input is ≤1230 bytes.

Output

Output one canonical ASCII JSON string with no extra whitespace; a trailing newline is optional. Printable ASCII other than double quotes and backslashes is output as is (including /); double quotes and backslashes are each escaped; backspace, form feed, newline, carriage return, and tab use \b, \f, \n, \r, \t respectively; other control characters, DEL, and non-ASCII characters use lowercase four-digit \uXXXX, and non-BMP characters use lowercase UTF-16 surrogate pairs. The surrounding double quotes must be kept; this is equivalent to Python json.dumps(value,ensure_ascii=True).

Example 1

Input:

"APPLE"

Output:

"E L"

Example 2

Input:

"bat"

Output:

"t a"

Example 3

Input:

"\u0000\ud83d\ude00"

Output:

"\ud83d\ude00 \u0000"

Example notes

The outputs of the three public examples are, in order: "E L"; "t a"; "\ud83d\ude00 \u0000". They were verified by independent enumeration or direct simulation.

Editorial

Loading solution…