mod11 function

int mod11(
  1. String value,
  2. List<int> weights
)

Implementation

int mod11(String value, List<int> weights) {
  int reducedValue = 0;
  List<String> splitValue = value.split("");

  for (int i = 0; i < splitValue.length; ++i) {
    reducedValue += int.parse(splitValue[i]) * weights[i % weights.length];
  }
  return ((11 - (reducedValue % 11)) % 11);
}