huikang's blog

By huikang, history, 3 years ago, In English

I used OpenAI API to translate Python code written by Kiri8128 in the recent combined division contest. These are the results.

How to use the translation tool

  • You will need an email and a phone number to sign up for the OpenAI Beta.
  • Create a new code translation Playground.
  • Press "Submit" to see an example of how the code is generated for Haskell.
  • Change Haskell to C++ in the starting prompt and at the stop sequence. You can see how C++ code is generated as well.
  • Insert the Python code you want to translate.
  • Change the maximum length to a larger number so that you generate the code all at once. The total number of tokens in the input and output is limited to 4000.
  • Copy code from Kiri8128.
  • Press "Submit" to generate the code.
  • Copy the C++ code and submit to Codeforces.

Kiri8128 is the first to reach Grandmaster with python3/pypy3 without ever switching to C++. Kiri8128 writes clean code which probably made it easier for the model to translate.

I am curious to see if this tool can produce code that resolves the various instances where Kiri8128's Python code TLE or MLE. I haven't been successful, as the code that seem to TLE/MLE because of the language is usually the more complicated ones.

Feel free to share your thoughts and findings!

  • Vote: I like it
  • +45
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Why there was CE before the accepted solution? Does the program generates code differently each time

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There is a temperature parameter, and its default value is 0.7. The lower the temperature, the more deterministic the code generation.

»
3 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Did it translate Python deque to vector even though C++ has its own deque?