import itertools


def create_discrete_actions(num_buttons, max_buttons_down):
    """
    Return list of available actions, when we have
    num_buttons buttons available and we are allowed
    to press at most max_buttons_down, as
    a discrete action space.

    Parameters:
        num_buttons (int): Number of buttons available
        max_buttons_down (int): How many buttons can be pressed
                                down at once.

    Returns:
        actions (List of Lists): A list of available actions
    """
    # Remove no-op action
    actions = [
        list(action) for action in itertools.product((0, 1), repeat=num_buttons)
        if (sum(action) <= max_buttons_down and sum(action) > 0)
    ]
    return actions