#B3981. JSFuck Code Generation

    ID: 11638 Type: Default 1000ms 256MiB

JSFuck Code Generation

JSFuck Code Generation

This problem is inspired by the famous JSFuck challenge. You are given an integer \(n\) and you have to generate a snippet of JavaScript code (using only the 6 characters ( ) + [ ] !) such that when the code is executed, it evaluates exactly to the integer \(n\).

For example, note that in JavaScript, automatic type conversion allows expressions such as +![] to equal \(0\) (because ![] is false and +false is \(0\)), and +!![] to equal \(1\) (since !![] is true and +true is \(1\)). Using these ideas, any non-negative integer \(n\) can be built up using exactly these characters.

Your task is to generate such a JSFuck snippet for the given integer \(n\). The generated JavaScript code must consist exclusively of the characters ( ) + [ ] ! and must, when executed, reveal the integer \(n\) as its result.

Note: You do not need any in-depth knowledge of JavaScript to solve this problem.

inputFormat

The input consists of a single line with one non-negative integer \(n\) (where \(0 \le n \le 10^4\)).

outputFormat

Output a single line containing a valid JavaScript code snippet that uses only the characters ( ) + [ ] ! which, when executed, evaluates to \(n\).

For example:

  • For \(n = 0\), output should be: +![]
  • For \(n = 1\), output should be: +!![]
  • For \(n = 3\), one valid output is: +!![]+(+!![])+(+!![])

sample

0
+![]