aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/deadmarshal/d/ch1.d
blob: ef8f7bed15be386960c97dc95bfd7187c4023428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import std.stdio:writeln;

bool is_alphabetical_order(string str)
{
  for(size_t i = 1; i < str.length; ++i)
    if(str[i] < str[i-1]) return false;
  return true;
}

int odd_one_out(string[] arr)
{
  int count = 0;
  foreach(s;arr) if(!is_alphabetical_order(s)) count++;
  return count;
}

void main()
{
  writeln(odd_one_out(["abc", "xyz", "tsu"]));
  writeln(odd_one_out(["rat", "cab", "dad"]));
  writeln(odd_one_out(["x","y","z"]));
}