aboutsummaryrefslogtreecommitdiff
path: root/challenge-250/barroff/d/ch_2.d
blob: 47c9cff6746f413e8b5b6d5549fb96b647b1ab94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env -S rdmd -unittest
import std.algorithm : map, maxElement;
import std.conv : to;
import std.string : isNumeric;

auto alphanumeric_string_value(string[] alphanumstr)
{
    return alphanumstr.map!(a => isNumeric(a) ? a.to!int : a.length).maxElement;
}

unittest
{
    assert(alphanumeric_string_value(["perl", "2", "000", "python", "r4ku"]) == 6);
    assert(alphanumeric_string_value(["001", "1", "000", "0001"]) == 1);
}

void main()
{
}