Hello, World! (Harder)

View as PDF

Submit solution

Points: 40 (partial)
Time limit: 1.0s
Memory limit: 1G

Author:
Problem type
Allowed languages
Python

Sucram314 found the problem Hello, World! to be very nice. He also found the problem Hello, World! (Hard) to be even nicer. So nice, he asks you to output Hello, World! followed by a newline character \n in Python 3 while satisfying all of the following constraints:

  • Your code must consist only of whitespace and the following characters: ()._abcdefghijklmnopqrstuvwxyz
  • All builtin functions are deleted. Notably, this includes print and __import__.
  • All initialized variables in the global scope, such as __file__, __name__, etc. are deleted.
  • For full marks, you must minimize the length of your program. Refer to the Scoring section below for more information.

The code which deletes all builtin functions and global variables is provided in the Sandbox section below (Credits to jdabtieu).

After you've gotten the hang of submitting, try out an easier problem like Loop Town.

Input Specification

There is no input.

Output Specification

Output Hello, World!, followed by a newline character \n. The checker is byte identical, so your output must match exactly.

Scoring

If your code contains any characters which are not whitespace and are not in the set ()._abcdefghijklmnopqrstuvwxyz, you will receive 0 marks and a Wrong Answer verdict.

If your code does not output Hello, World!, followed by a newline character \n, you will receive 0 marks and a Wrong Answer verdict.

Otherwise, you will receive an Accepted Verdict and your score will be based on the length of your program.

Let L be the length of your program in bytes. Let L_{opt} be the current known optimum. Your score will be calculated as

\displaystyle \min\left(100, 50 + 50 \cdot 2^{-\frac{1}{128}\left(L-L_{opt}\right)}\right)

In particular, you will receive at least 50 marks for any solution which correctly outputs Hello, World! followed by a newline character \n under the given constraints. Your program must have a length less than or equal to L_{opt} bytes for a full 100 marks.

Currently, L_{opt} = 291, found by Dingledooper in collaboration with nipo.

History of known optimum The following graph shows the known optimum over time. The name of a user appears the first time they improve the known optimum.

Sandbox

Credits: jdabtieu

class Sandbox(object):
    def __init__(self):
        import sys
        for attr in ["__file__","__loader__","__name__","__doc__","__package__","__annotations__","__spec__","__cached__"]:
            if hasattr(sys.modules["__main__"],attr):
                delattr(sys.modules["__main__"],attr)

        if hasattr(sys.modules["__main__"].__dict__["__builtins__"],"__dict__"):
            original_builtins = sys.modules["__main__"].__dict__["__builtins__"].__dict__.copy()
            for builtin in original_builtins:
                del sys.modules["__main__"].__dict__["__builtins__"].__dict__[builtin]
        else:
            original_builtins = sys.modules["__main__"].__dict__["__builtins__"]
            for builtin in list(original_builtins):
                del sys.modules["__main__"].__dict__["__builtins__"][builtin]

        del sys.modules["__main__"].__dict__["__builtins__"]
        del sys

Sandbox()
del Sandbox

# your code goes here

Note

Some relevant Python features for this problem are platform dependent. Code working locally does not necessarily mean it will work on DMOJ.


Comments


  • 4
    do_ur_homwork  commented on Dec. 30, 2025, 7:51 p.m.

    Yay! Its published now! My one week of pain is finally over!


  • 9
    danplus6  commented on Dec. 27, 2025, 1:40 a.m. edit 18
    • Every hour wasted = 10 pushups

    • I am allowed to take breaks from the problem to do other problems if I am bored or bcuz I gotta sleep

    • However during break time, I am not allowed to make progress or perform research regarding the problem in any way shape or form

    Counter: 9 h

    Edit: I am taking a break for my physical and mental health