Find the smallest number that can be framed using the series created by the digits obtained by raising the given number  (  "a"  ) to the power from 1 to  n  i.e.  a^1 , a^2 , a^3 .......a^n . We get  b1,b2 , b3 , ........... bn . 
Using all the digits  ( including repeating ones )  that appear inb1 ,b2 , b3 .... bn . Frame a number that contains all the digits ( including repeating ones )  and find out the combination of digits that make the smallest number of all possible combinations. Excluding or neglecting zeroes  ( " 0 " )  . 
Example 1:
Input : A = 9 and N = 4
Output : 1125667899
Explanation:
9^1 = 9
9^2 = 81
9^3 = 729
9^4  = 6561 
9 81 729 6561
We get  9817296561 .
Using 9817296561 number we need to find 
the smallest possible number that can be 
framed using other combinations of the 
samenumber .
1298796561
8799265611
2186561997
.
.
.
1125667899
The smallest possible number that can be 
framed is1125667899 . 
Example 2:
Input : A = 5 and N = 1
Output : 5
Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function tiny_miny() that takes two integers A, N, and return a string which is the smallest number out of all combinations .how many tabs are open at the end. The driver code takes care of the printing.
Expected Time Complexity: O(N^{2}LogA).
Expected Auxiliary Space: O(1).
 
Constraints:   
0 ≤ N ≤ 5
0 ≤ A ≤ 70

Source: geeksforgeeks | Difficulty: MEDIUM
Tags: Data structures

Starter code: #User function Template for python3

class Solution:
    def tiny_miny (self, a, n) : 
        #Complete the function



Solutions:
class Solution:

	def tiny_miny(self, a, n):
		s = ''
		i = 1
		while i <= n:
			s += str(int(pow(a, i)))
			i += 1
		s = s.replace('0', '')
		s = sorted(s)
		s = ''.join(s)
		return s


class Solution:

	def tiny_miny(self, a, n):
		s = []
		for i in range(1, n + 1):
			s.append(str(a ** i))
		all = list((c for e in s for c in e if c != '0'))
		all.sort()
		return ''.join(all)


class Solution:

	def tiny_miny(self, a, n):
		z = ''
		for i in range(1, n + 1):
			k = pow(a, i)
			z += str(k)
		p = list(z)
		x = sorted(p)
		for i in range(len(x)):
			if '0' in x:
				x.remove('0')
		return ''.join(x)


class Solution:

	def tiny_miny(self, a, n):
		b = ''
		for i in range(1, n + 1):
			b += str(a ** i)
		c = ''
		for i in sorted(b):
			c += i
		return int(c)


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			d = a ** i
			s = s + str(d)
		v = ''.join(sorted(s))
		v = v.replace('0', '')
		return v


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			s += str(a ** i)
		s = sorted(s)
		s = ''.join(s)
		s = int(s)
		return str(s)


class Solution:

	def tiny_miny(self, a, n):
		x = ''
		for i in range(1, n + 1):
			x += str(a ** i)
		x = list(x)
		x.sort()
		y = ''
		for i in x:
			y += i
		y = str(int(y))
		return y


class Solution:

	def tiny_miny(self, a, n):
		d = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
		ans = ''
		for i in range(1, n + 1):
			x = str(pow(a, i))
			for i in x:
				d[i] += 1
		for i in range(1, 10):
			for j in range(d[str(i)]):
				ans += str(i)
		return ans


class Solution:

	def tiny_miny(self, a, n):
		output = ''
		num = 1
		for _ in range(n):
			num *= a
			output += str(num)
		return int(''.join(sorted(output)))


class Solution:

	def tiny_miny(self, a, n):
		c = ''
		for i in range(1, n + 1):
			b = pow(a, i)
			c += str(b)
			c = ''.join(sorted(c))
			c = c.replace('0', '')
		return c


class Solution:

	def tiny_miny(self, a, n):
		st = ''
		for i in range(1, n + 1):
			st += str(a ** i)
		st = sorted(st)
		while st[0] == '0':
			st.pop(0)
		return ''.join(st)


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			s += str(a ** i)
		l = list((i for i in s))
		l.sort()
		return int(''.join(l))


class Solution:

	def tiny_miny(self, a, n):
		A = [0] * 10
		x = 1
		while n:
			x *= a
			y = x
			while y:
				A[y % 10] += 1
				y //= 10
			n -= 1
		res = ''
		for i in range(1, 10):
			res += str(i) * A[i]
		return res


class Solution:

	def tiny_miny(self, a, n):
		x = ''
		for i in range(1, n + 1):
			x += str(a ** i)
		ans = ''
		for i in sorted(x):
			ans += i
		return int(ans)


class Solution:

	def tiny_miny(self, a, n):
		t = ''
		p = 1
		for i in range(n):
			p = p * a
			t += str(p)
		t = sorted(t)
		t = ''.join(t)
		t = t.lstrip('0')
		return t


class Solution:

	def digit(self, n, A):
		while n > 0:
			if n % 10 != 0:
				A.append(n % 10)
			n = n // 10

	def tiny_miny(self, a, n):
		A = []
		for i in range(1, n + 1):
			ob.digit(pow(a, i), A)
		A.sort()
		s = 0
		for i in A:
			s = s * 10 + i
		return s


import math

class Solution:

	def tiny_miny(self, a, n):
		u = []
		for i in range(1, n + 1):
			u.append(int(math.pow(a, i)))
		u = list(map(str, u))
		x = ''.join(u)
		x = sorted(x)
		x = ''.join(x)
		return int(x)


class Solution:

	def tiny_miny(self, a, n):
		ans = ''
		k = 1
		for i in range(n):
			k *= a
			ans += str(k)
		ans = ans.replace('0', '')
		ans = list(ans)
		ans.sort()
		return ''.join(ans)


class Solution:

	def tiny_miny(self, a, n):
		if n == 0 and a == 0:
			return '01'
		if n == 0:
			return 1
		if a == 0:
			return 0
		i = 1
		z = ''
		while i <= n:
			y = a ** i
			z = z + str(y)
			i += 1
		A = sorted(z)
		for i in z:
			if i == '0':
				A.remove(i)
		return ''.join(A)


class Solution:

	def tiny_miny(self, a, n):
		res = []
		for i in range(1, n + 1):
			res.extend(list(str(a ** i)))
		res.sort()
		return int(''.join(res))


class Solution:

	def tiny_miny(self, a, n):
		l = ''
		b = []
		for i in range(1, n + 1):
			l = l + str(a ** i)
		for i in l:
			if i == '0':
				continue
			else:
				b.append(i)
		b.sort()
		k = ''.join(b)
		return k


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			temp = a ** i
			s += str(temp)
		s = sorted(s)
		c = ''
		for j in s:
			if j != '0':
				c += j
		return c


import math

class Solution:

	def tiny_miny(self, a, n):
		l = []
		for i in range(1, n + 1):
			l.append(int(math.pow(a, i)))
		s = ''
		for i in l:
			s += str(i)
		v = list(s)
		while v.count('0'):
			v.remove('0')
		k = []
		for i in v:
			k.append(int(i))
		k.sort()
		l = ''
		for i in k:
			l += str(i)
		return l


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			s += str(pow(a, i))
		ar = []
		for j in s:
			if int(j) != 0:
				ar.append(j)
		ar.sort()
		k = ''.join(ar)
		return k


class Solution:

	def tiny_miny(self, a, n):
		string = ''
		for i in range(1, n + 1):
			string += str(a ** i)
		stri = sorted(str(string))
		res = ''
		for i in stri:
			if i not in '0':
				res += i
		return res


class Solution:

	def tiny_miny(self, a, n):
		res = ''
		for i in range(1, n + 1):
			res += str(a ** i)
		s = sorted(str(res))
		d = ''
		for i in s:
			if i != '0':
				d += i
		return d


class Solution:

	def tiny_miny(self, a, n):
		res = []
		for i in range(1, n + 1):
			res.append(a ** i)
		s = [str(i) for i in res]
		ans = ''.join(sorted(str(s)))
		result = []
		for i in ans:
			if i.isnumeric() == True and int(i) > 0:
				result.append(i)
		return ''.join(result)


class Solution:

	def tiny_miny(self, a, n):
		ans = ''
		for i in range(1, n + 1):
			x = str(a ** i)
			ans += x
		freq = [0] * 10
		for i in ans:
			freq[int(i)] += 1
		finalans = ''
		for i in range(1, 10):
			while freq[i] != 0:
				finalans += str(i)
				freq[i] -= 1
		return finalans


class Solution:

	def tiny_miny(self, a, n):
		B = []
		for i in range(1, n + 1):
			B.append(a ** i)
		word = ''
		for i in range(0, len(B)):
			word = word + str(B[i])
		K = list(word)
		ans = ''
		while len(K) > 0:
			ans = ans + min(K)
			K.remove(min(K))
		ans2 = int(ans)
		return ans2


class Solution:

	def tiny_miny(self, a, n):
		dibba = ''
		for i in range(1, n + 1):
			b = a ** i
			dibba += str(b)
		dibba = list(dibba)
		dibba.sort()
		z = ''.join(map(str, dibba))
		return int(z)


class Solution:

	def tiny_miny(self, a, n):
		l = []
		s = ' '
		k = ' '
		t = 0
		p = ' '
		num = 0
		for i in range(1, n + 1):
			l.append(str(pow(a, i)))
		s = ''.join(l)
		k = sorted(s)
		p = ''.join(k)
		p = p.replace('0', '')
		return p


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			s = s + str(pow(a, i))
			result = s.strip('0')
		return int(''.join(sorted(result)))


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(n):
			m = pow(a, i + 1)
			s += str(m)
		s = ''.join(sorted(s)).replace('0', '')
		return s


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(1, n + 1):
			p = a ** i
			p1 = str(p)
			s = s + p1
		k1 = sorted(s)
		p1 = []
		for i in k1:
			if i != '0':
				p1.append(i)
		k = ''.join(sorted(p1))
		return k


class Solution:

	def tiny_miny(self, a, n):
		l = ''
		for i in range(1, n + 1):
			s = a ** i
			s1 = str(s)
			l = l + s1
		l2 = sorted(l)
		for i in range(len(l2)):
			c = 0
			if l2[i] == '0':
				c = 1
			if c == 0:
				p = i
				break
		l2 = l2[i:]
		l1 = ''.join(sorted(l2))
		return l1


class Solution:

	def tiny_miny(self, a, n):
		s = ''
		for i in range(n):
			r = pow(a, i + 1)
			s = s + str(r)
		l2 = sorted(list(map(int, list(s))))
		l3 = list(map(str, l2))
		l4 = list(filter(lambda x: x != '0', l3))
		return ''.join(l4)