Find the first perfect square in a given base N that has at least N digits and
exactly N significant unique digits when expressed in base N.

E.G. In base 10, the first perfect square with at least 10 unique digits is 1026753849 (32043²).

You may use analytical methods to reduce the search space, but the code must do a search. Do not use magic numbers or just feed the code the answer to verify it is correct.

Task
 Find and display here, on this page, the first perfect square in base N, with N significant unique digits when expressed in base N, for each of base 2 through 12. Display each number in the base N for which it was calculated.
 (optional) Do the same for bases 13 through 16.
 (stretch goal) Continue on for bases 17 - ?? (Big Integer math)


See also

 OEIS A260182: smallest square that is pandigital in base n.
Related task
 Casting out nines


import algorithm, math, strformat
 
const Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
 
func toBaseN(num, base: Natural): string =
  doAssert(base in 2..Alphabet.len, &"base must be in 2..{Alphabet.len}")
  var num = num
  while true:
    result.add(Alphabet[num mod base])
    num = num div base
    if num == 0: break
  result.reverse()
 
 
func countUnique(str: string): int =
  var charset: set['0'..'Z']
  for ch in str: charset.incl(ch)
  result = charset.card
 
 
proc find(base: Natural) =
  var n = pow(base.toFloat, (base - 1) / 2).int
  while true:
    let sq = n * n
    let sqstr = sq.toBaseN(base)
    if sqstr.len >= base and countUnique(sqstr) == base:
      let nstr = n.toBaseN(base)
      echo &"Base {base:2d}:  {nstr:>8s}² = {sqstr:<16s}"
      break
    inc n
 
 
when isMainModule:
  for base in 2..16:
    base.find()