# Definition

A **_Tidy number_**  *is a number whose*  **_digits are in non-decreasing order_**.
___
# Task

**_Given_** a number, **_Find if it is Tidy or not_** . 
____

# Warm-up (Highly recommended)

# [Playing With Numbers Series](https://www.codewars.com/collections/playing-with-numbers)
___

# Notes 


* **_Number_** *passed is always*  **_Positive_** .

* **_Return_** *the result as* a **_Boolean_** 

~~~if:prolog
* Since prolog doesn't have booleans,  return value should be 1 for (True) or 0 for (false)
~~~
___

# Input >> Output Examples

```
tidyNumber (12) ==> return (true)
```

## **_Explanation_**:

**_The number's digits_**    `{ 1 , 2 }`  are *in non-Decreasing Order* (i.e) *1 <= 2* .
____

```
tidyNumber (32) ==> return (false)
```

## **_Explanation_**:

**_The Number's Digits_**  `{ 3, 2}`  are **_not in non-Decreasing Order_** (i.e) *3 > 2* .
___

```
tidyNumber (1024) ==> return (false)
```

## **_Explanation_**:

**_The Number's Digits_**  `{1 , 0, 2, 4}`  are **_not in non-Decreasing Order_**  as  *0 <= 1* .

___

```
tidyNumber (13579) ==> return (true)
```

## **_Explanation_**:

**_The number's digits_**    `{1 , 3, 5, 7, 9}`  are *in non-Decreasing Order* .
____

```
tidyNumber (2335) ==> return (true)
```

## **_Explanation_**:

**_The number's digits_**    `{2 , 3, 3, 5}`  are *in non-Decreasing Order* , **_Note_**   *3 <= 3* 

___
___
___

# [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers)

# [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)

# [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored)
___

## ALL translations are welcomed

## Enjoy Learning !!
# Zizou

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def tidyNumber(n):
	

Solutions:
def tidyNumber(n):
	s = list(str(n))
	return s == sorted(s)


def tidyNumber(n):
	s = str(n)
	return all((a <= b for (a, b) in zip(s, s[1:])))


def tidyNumber(n):
	return n == int(''.join(sorted(str(n))))


def tidyNumber(n):
	n = str(n)
	for i in range(0, len(n) - 1):
		if n[i] > n[i + 1]:
			return False
	return True


def tidyNumber(n):
	n = str(n)
	backnumber = n[0]
	for number in n:
		if number < backnumber:
			return False
		backnumber = number
	return True


def tidyNumber(n):
	l = list(str(n))
	return sorted(l) == l


def tidyNumber(n):
	o = str(n)[0]
	for i in str(n):
		if i >= o:
			o = i
		else:
			return False
	return True


def tidyNumber(n):
	a = str(n)
	index = 0
	while index < len(a) - 1:
		if int(a[index]) > int(a[index + 1]):
			return False
		index += 1
	return True


def tidyNumber(n):
	str_num = str(n)
	digit_list = [d for d in str_num]
	return digit_list == sorted(digit_list)


def tidyNumber(n):
	string_n = str(n)
	for (n1, n2) in zip(string_n, string_n[1:]):
		if n1 > n2:
			return False
	return True


tidyNumber = lambda n, f=lambda x: list(str(x)): f(n) == sorted(f(n))


import re

def tidyNumber(n):
	return bool(re.fullmatch('0*1*2*3*4*5*6*7*8*9*', str(n)))


def tidyNumber(n):
	i = n % 10
	n = n // 10
	while n > 0:
		s = n % 10
		print((i, s, n))
		n = n // 10
		if i < s:
			return False
		i = s
	return True


def tidyNumber(n):
	before = list(str(n))
	after = sorted(before)
	if after == before:
		return True
	else:
		return False


def tidyNumber(n):
	l = len(str(n))
	x = [int(x) for x in str(n)]
	return all((x[i + 1] >= x[i] for i in range(l - 1)))


def tidyNumber(n):
	print(n)
	previous = n % 10
	while n > 0:
		n //= 10
		checking = n % 10
		if previous < checking:
			return False
		previous = checking
	return True


from functools import reduce

def tidyNumber(n):
	if n < 10:
		return True
	l = [str(n)[i] <= str(n)[i + 1] for i in range(len(str(n)) - 1)]
	return reduce(lambda x, y: x & y, l)


def tidyNumber(n):
	a = list(str(n))
	return sorted(a) == a


def tidyNumber(n):
	prev = 10
	while n:
		(n, curr) = divmod(n, 10)
		if curr > prev:
			return False
		prev = curr
	return True


def tidyNumber(n):
	for (idx, val) in enumerate(str(n)):
		if idx != 0:
			if val < str(n)[idx - 1]:
				return False
	return True


def tidyNumber(n):
	print(n)
	nums = [int(x) for x in str(n)]
	for (m, i) in enumerate(nums[:-1]):
		if i <= nums[m + 1]:
			continue
		else:
			return False
	return True


def tidyNumber(n):
	d = [int(x) for x in str(n)]
	if all((i <= j for (i, j) in zip(d, d[1:]))):
		return True
	else:
		return False


def tidyNumber(n):
	return True if sorted([int(x) for x in str(n)]) == [int(x) for x in str(n)] else False


def tidyNumber(n):
	for x in range(len(str(n)) - 1):
		if str(n)[x] <= str(n)[x + 1]:
			continue
		else:
			return False
	return True


def tidyNumber(n):
	n = list(str(n))
	n = [int(i) for i in n]
	sorted = n[:]
	sorted.sort()
	print(sorted)
	if n != sorted:
		return False
	else:
		return True


def tidyNumber(n):
	n = str(n)
	p = 0
	for i in n:
		if int(i) < int(p):
			return False
		else:
			p = i
	return True


def tidyNumber(n):
	for (i, digit) in enumerate(str(n)[1:]):
		if int(digit) >= int(str(n)[i]):
			pass
		else:
			return False
	return True


def tidyNumber(n):
	for (i, c) in enumerate(str(n)):
		if i != 0:
			if c < str(n)[i - 1]:
				return False
	return True


def tidyNumber(n):
	tidy = True
	for i in range(1, len(str(n))):
		if int(str(n)[i]) < int(str(n)[i - 1]):
			tidy = False
	return tidy


def tidyNumber(n):
	numLst = list(str(n))
	for i in range(len(numLst) - 1):
		if not numLst[i + 1] >= numLst[i]:
			return False
	return True


def tidyNumber(n):
	return [x for x in range(len(str(n)) - 1) if int(str(n)[x]) > int(str(n)[x + 1])] == []


def tidyNumber(n, p=''):
	for s in str(n):
		if s < p:
			return False
		else:
			p = s
	return True


def tidyNumber(n):
	n = str(n)
	tidy = True
	for i in range(1, len(n)):
		if int(n[i]) >= int(n[i - 1]):
			continue
		else:
			tidy = False
			break
	return tidy


def tidyNumber(n):
	last_seen = 10
	while n:
		if n % 10 > last_seen:
			return False
		last_seen = n % 10
		n //= 10
	return True


def tidyNumber(n):
	j = str(n)
	for x in range(len(j) - 1):
		if int(j[x]) > int(j[x + 1]):
			return False
	return True


def tidyNumber(n):
	count = 0
	play = str(n)
	for i in range(1, len(play)):
		if int(play[i]) >= int(play[i - 1]):
			count += 1
	return count == len(play) - 1


def tidyNumber(n):
	nums = list(map(int, str(n)))
	for i in range(len(nums) - 1):
		if nums[i] > nums[i + 1]:
			return False
	return True


def tidyNumber(n):
	print(n)
	n = [int(x) for x in str(n)]
	prev = n[0]
	for (i, x) in enumerate(n[1:]):
		if x >= prev:
			prev = x
		else:
			return False
	return True


def tidyNumber(n):
	previous_number = 0
	for number in str(n):
		if previous_number > int(number):
			return False
		previous_number = int(number)
	return True


def tidyNumber(n):
	return n == int(''.join((x for x in sorted(list(str(n))))))


tidyNumber = lambda n: list(str(n)) == sorted(str(n))


def tidyNumber(n):
	nums = [int(num) for num in str(n)]
	srted = sorted(nums)
	if nums == srted:
		return True
	else:
		return False


def tidyNumber(n):
	n = str(n)
	print(n)
	for i in range(1, len(n)):
		if n[i] >= n[i - 1]:
			continue
		else:
			return False
	return True


def tidyNumber(n):
	x = str(n)
	arr = list(x)
	if len(x) == 1:
		return True
	else:
		for j in range(0, len(x) - 1):
			if arr[j] > arr[j + 1]:
				return False
		return True


def tidyNumber(n):
	if n != int(''.join(sorted(str(n)))):
		return False
	return True


def tidyNumber(n):
	digits = [int(i) for i in str(n)]
	return all([digits[i] <= digits[i + 1] for i in range(len(digits) - 1)])


def tidyNumber(n):
	return all(map(lambda x: int(str(n)[x]) >= int(str(n)[x - 1]), range(1, len(str(n)))))


def tidyNumber(n):
	n = list(map(str, str(n)))
	return sorted(n) == n


def tidyNumber(n):
	s = 0
	if len(str(n)) > 1:
		for i in str(n):
			if int(i) >= s:
				s = int(i)
				continue
			else:
				return False
	return True


def tidyNumber(n):
	s = str(n)
	return all((x <= y for (x, y) in zip(s, s[1:])))


def tidyNumber(n):
	numbers = [int(num) for num in str(n)]
	flag = True
	while len(numbers) > 1:
		if numbers[0] > numbers[1]:
			flag = False
			break
		numbers.pop(0)
	return flag


def tidyNumber(n):
	new_string = str(n)
	count = 0
	for i in range(0, len(new_string) - 1):
		if new_string[i] <= new_string[i + 1]:
			count += 1
	return count == len(new_string) - 1


def tidyNumber(n):
	z = [int(x) for x in str(n)]
	print(z)
	return all((v <= y for (v, y) in zip(z, z[1:])))


def tidyNumber(n):
	return int(''.join(sorted(f'{n}'))) == n


def tidyNumber(n):
	s = str(n)
	return ''.join(sorted(s)) == s


def tidyNumber(n):
	digits = []
	while n > 0:
		digit = n % 10
		n = n // 10
		digits.append(digit)
	tidy = True
	i = 1
	while i < len(digits):
		if digits[i] > digits[i - 1]:
			tidy = False
			break
		i = i + 1
	return tidy


def tidyNumber(n):
	return n == int(''.join(sorted((i for i in str(n)))))


def tidyNumber(n):
	return sorted([el for el in str(n)]) == [el for el in str(n)]


def tidy_number(n):
	return list(str(n)) == sorted(str(n))
tidyNumber = tidy_number


def tidyNumber(n):
	x = list(str(n))
	return True if x == sorted(x) else False


def tidyNumber(n):
	lst = [x for x in list(str(n))]
	lst1 = sorted(lst, key=int)
	return int(''.join(lst1)) == n


def tidyNumber(n):
	a = list(str(n))
	a.sort()
	b = ''.join(a)
	c = int(b)
	if c == n:
		return True
	else:
		return False


def tidyNumber(n):
	for (k, v) in enumerate(str(n)):
		if k == 0:
			pass
		elif v < str(n)[k - 1]:
			return False
	return True


def tidyNumber(n):
	digits = [int(d) for d in str(n)]
	for i in range(len(digits) - 1):
		if digits[i] > digits[i + 1]:
			return False
	return True


def tidyNumber(n):
	print(n)
	for i in range(len(list(str(n)))):
		try:
			if not int(str(n)[i]) <= int(str(n)[i + 1]):
				return False
		except:
			return True


def tidyNumber(n):
	digits = [int(s) for s in str(n)]
	return sorted(digits) == digits


def tidyNumber(n):
	digits = list(map(int, str(n)))
	actual_digit = digits[0]
	for digit in digits[1:]:
		if digit < actual_digit:
			return False
		actual_digit = digit
	return True


def tidyNumber(n):
	n = str(n)
	if ''.join(sorted(n)) == n:
		return True
	else:
		return False


def tidyNumber(n):
	cpy = n
	l = len(str(cpy))
	cpy = [int(i) for i in str(cpy)]
	for i in range(l):
		for j in range(i, l - 1):
			if cpy[j] <= cpy[j + 1]:
				continue
			else:
				return False
	return True


def tidyNumber(n):
	s = str(n)
	for c in list(zip(s[1:], s)):
		if c[0] < c[1]:
			return False
	return True


def tidyNumber(n):
	return True if all([front <= behind for (front, behind) in zip(str(n), str(n)[1:])]) else False


def tidyNumber(number):
	number = str(number)
	return sorted(number) == list(number)


import unittest

def tidyNumber(n):
	n = str(n)
	return all((e0 <= e1 for (e0, e1) in zip(n, n[1:])))

class TestTidyNumber(unittest.TestCase):

	def test_should_return_true_when_given_n_is_12(self):
		n = 12
		actual = tidyNumber(n)
		self.assertEqual(actual, True)

	def test_should_return_false_when_given_n_is_102(self):
		n = 102
		actual = tidyNumber(n)
		self.assertEqual(actual, False)


import unittest

def tidyNumber(n):
	return all((False for ele in zip(str(n), str(n)[1:]) if int(ele[1]) - int(ele[0]) < 0))

class TestTidyNumber(unittest.TestCase):

	def test_should_return_true_when_given_n_is_12(self):
		n = 12
		actual = tidyNumber(n)
		self.assertEqual(actual, True)

	def test_should_return_false_when_given_n_is_102(self):
		n = 102
		actual = tidyNumber(n)
		self.assertEqual(actual, False)


def tidyNumber(n):
	n = str(n)
	k = list(map(int, n))
	l = sorted(k)
	if k == l:
		return True
	else:
		return False


def tidyNumber(n):
	string = str(n)
	j = 0
	for i in string:
		if int(i) >= j:
			j = int(i)
			continue
		else:
			return False
	return True


def tidyNumber(n):
	tidy = True
	y = ''
	for x in str(n):
		if y != None:
			if x < y:
				tidy = False
			else:
				y = x
	return tidy


def tidyNumber(n):
	A = []
	Count = 0
	for i in str(n):
		A.append(int(i))
	for i in range(1, len(A)):
		if A[i - 1] > A[i]:
			return False
	return True