countPossibleWords static method

BigInt countPossibleWords(
  1. int length,
  2. String chars
)

Implementation

static BigInt countPossibleWords(int length, String chars) {
  int charsetSize = chars.length;
  int maxLength = length;
  BigInt base = BigInt.from(charsetSize);
  BigInt numerator = base.pow(maxLength + 1) - base;
  BigInt denominator = BigInt.from(charsetSize - 1);
  BigInt total = numerator ~/ denominator;
  return total;
}