Well, those numbers were right and we're going to feed their ego.

Write a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers are narcissistic. Return false for invalid arguments (numbers passed in as strings are ok).

For more information about narcissistic numbers (and believe me, they love it when you read about them) follow this link: https://en.wikipedia.org/wiki/Narcissistic_number

Source: codewars | Difficulty: EASY
Tags: Mathematics

Starter code: def is_narcissistic(*args):
	

Solutions:
def get_digits(n):
	return [int(x) for x in list(str(n))]

def is_narc(n):
	return n == sum([x ** len(get_digits(n)) for x in get_digits(n)])

def is_narcissistic(*values):
	try:
		return all((type(n) in [int, str] and is_narc(int(n)) for n in values))
	except ValueError:
		return False


def narc(n):
	ds = [int(c) for c in str(n)]
	return sum((d ** len(ds) for d in ds)) == n

def is_narcissistic(*ns):
	return all((isinstance(n, int) and n >= 0 or (isinstance(n, str) and n.isdigit()) for n in ns)) and all(map(narc, map(int, ns)))


def is_narcissistic(*arg):
	for e in arg:
		try:
			if e == 0:
				continue
			n = int(e) == sum([int(i) ** len(str(e)) for i in str(e)])
			if not n:
				return False
		except:
			return False
	return True


def narcissistic(n):
	s = str(n)
	l = len(s)
	return n == sum((int(d) ** l for d in s))

def is_narcissistic(*numbers):
	return all((str(n).isdigit() and narcissistic(int(n)) for n in numbers))


def is_narcissistic(*nos):
	try:
		return all([sum([int(i) ** len(str(n)) for i in str(n)]) == int(n) for n in nos])
	except ValueError:
		return False


is_narcissistic = lambda *a: all((n.isdigit() and int(n) == sum((int(d) ** len(n) for d in n)) for n in map(str, a)))


def narcissistic(n):
	try:
		k = len(str(n))
		return sum((d ** k for d in map(int, str(n)))) == int(n)
	except ValueError:
		return False

def is_narcissistic(*args):
	return all(map(narcissistic, args))


def is_narcissistic(*args):

	def check(n):
		n = str(n)
		l = len(n)
		return int(n) == sum((int(d) ** l for d in n))
	return all((str(arg).isdigit() and check(int(arg)) for arg in args))


def is_narcissistic(*args):
	try:
		return all((narcissistic(int(number)) for number in args))
	except (ValueError, TypeError):
		return False

def narcissistic(number):
	n = len(str(number))
	return sum((int(digit) ** n for digit in str(number))) == number