benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d54b5646-7b17-5326-9e12-b6a5cf09086d

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import re
import socket

def task_func(ip_addresses: list) -> dict:
    """
    Given a list of IP addresses, this function returns a dictionary mapping each valid IP address to its 
    respective hostname. If the hostname cannot be determined, the value will be None.
    
    Parameters:
    ip_addresses (list): A list of IP addresses.
    
    Returns:
    dict: A dictionary with IP addresses as keys and their hostnames as values. If the hostname cannot be determined,
          the value will be None.
    
    Requirements:
    - re
    - socket
    
    Example:
    >>> task_func(['8.8.8.8', '8.8.4.4'])
    {'8.8.8.8': 'dns.google', '8.8.4.4': 'dns.google'}
    """

instruct prompt

Given a list of IP addresses, this function returns a dictionary mapping each valid IP address to its respective hostname. If the hostname cannot be determined, the value will be None.
The function should output with:
    dict: A dictionary with IP addresses as keys and their hostnames as values. If the hostname cannot be determined,
    the value will be None.
You should write self-contained code starting with:

Code

import re
import socket
def task_func(ip_addresses: list) -> dict:

code prompt

Code

import re
import socket
def task_func(ip_addresses: list) -> dict:

entry point

task_func

libs

  • re
  • socket

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import