This was the nicest plausible-looking Perl solution I could come up with (Untested & Generated by Claude™)
use Number::Range::Regex qw(range_to_regex);
my $N = range_to_regex(0, 255);
my $IP = qr/^$N\.$N\.$N\.$N/;
sub is_valid_ip {
return $_[0] =~ $IP;
}
According to Claude, in TCL integers are just strings so there’s no conversion step necessary
proc digitDiff {n} {
set digits [split $n ""]
expr {
[join [lsort -decreasing $digits] ""]
-
[join [lsort $digits] ""]
}
}