Rosetta Code:Village Pump/Suggest a programming task: Difference between revisions

Content added Content deleted
(→‎General: I've added most of these suggestions as draft tasks.)
Line 708: Line 708:


=== ICMP Ping ===
=== ICMP Ping ===
Send an ICMP ping to some local resource, such as the current default gateway or even just 127.0.0.1 or ::1, and display information about the response or the absence of the response.
Send an ICMP ping to some local resource, such as the current default gateway or even just 127.0.0.1 or ::1, and display information about the response or the absence of the response.

=== Generate a Regular Expression for a Range of Integers ===

Write a function that, given the integers 0 <= min < = max, returns a regular expression that will match the decimal representation of any integer in the range [min, max]. You may assume there are no thousand-separators, leading 0's, or other problematic characters in the string to be processed. You may also assume the caller of your function will prepend/append appropriate anchors (e.g., ^, $, or \b) depending on need, so don't include them. Don't use \d as an alias for [0-9] since \d can match weird unicode characters on some systems.

Example:
min = 1
max = 31
possible result = [1-9]|[1-2][0-9]|3[0-1]
possible result = [1-9]|[12][0-9]|3[01]

Example:
min = 91
max = 417
possible result = 9[1-9]|[1-3][0-9]{2}|4(0[0-9]|1[0-7])
possible result = 9[1-9]|[1-3][0-9][0-9]|4(0[0-9]|1[0-7])

Hint: Use a recursive, divide-and-conquer approach. You will have to handle cases where max contains more digits than min.

Bonus: support ranges containing negative integers.


=== Partitioning ==
=== Partitioning ==