benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf fdd658ca-ba14-562e-b749-566f884f2e7f
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import subprocess
from ipaddress import IPv4Network
def task_func(ip_range):
"""
Scans the specified IP address range and pings each IP to check if it is active.
The function returns a dictionary with IP addresses as keys and a boolean value indicating
their active status (True if the ping is successful, False otherwise).
Parameters:
ip_range (str): The IP range to scan, in CIDR notation (e.g., '192.168.0.0/24').
Requirements:
- ipaddress
- subprocess
Returns:
dict: A dictionary mapping IP addresses to their active status.
Raises:
subprocess.CalledProcessError: If a ping command fails due to a subprocess error.
Examples:
>>> result = task_func('192.168.1.0/24')
>>> isinstance(result, dict)
True
>>> all(isinstance(key, str) and isinstance(value, bool) for key, value in result.items())
True
"""
instruct prompt
Scans the specified IP address range and pings each IP to check if it is active. The function returns a dictionary with IP addresses as keys and a boolean value indicating their active status (True if the ping is successful, False otherwise).
The function should raise the exception for: subprocess.CalledProcessError: If a ping command fails due to a subprocess error.
The function should output with:
dict: A dictionary mapping IP addresses to their active status.
You should write self-contained code starting with:
Code
import subprocess
from ipaddress import IPv4Network
def task_func(ip_range):
code prompt
Code
import subprocess
from ipaddress import IPv4Network
def task_func(ip_range):
entry point
task_func
libs
- subprocess
- ipaddress
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
initial import