In this Kata, you will be given a ```number```, two indexes (```index1``` and ```index2```) and a ```digit``` to look for. Your task will be to check if the ```digit``` exists in the ```number```, within the ```indexes``` given.

Be careful, the ```index2``` is not necessarily more than the ```index1```.

```
  index1 == 2 and index2 == 5 -> snippet from 2 to 5 positons;
  index1 == 5 and index2 == 2 -> snippet from 2 to 5 positons;

  number.length = 14;
  
  0 <= index1 < 14;
  
  0 <= index2 < 14;
  
  index2 is inclusive in search snippet;
  
  0 <= digit <= 9;

```

Find more details below: 

```

  checkDigit(12345678912345, 1, 0, 1) -> true, 1 exists in 12
  
  checkDigit(12345678912345, 0, 1, 2) -> true, 2 exists in 12
  
  checkDigit(67845123654000, 4, 2, 5) -> true, 4 exists in 845
  
  checkDigit(66688445364856, 0, 0, 6) -> true, 6 exists in 6
  
  checkDigit(87996599994565, 2, 5, 1) -> false, 1 doesn't exist in 9965
  
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Ad-hoc

Starter code: def check_digit(number, index1, index2, digit):
	

Solutions:
def check_digit(n, idx1, idx2, digit):
	return str(digit) in str(n)[idx1:idx2 + 1] + str(n)[idx2:idx1 + 1]


def check_digit(n, i1, i2, d):
	return str(d) in str(n)[min(i1, i2):max(i1, i2) + 1]


def check_digit(number, index1, index2, digit):
	(number, digit) = (str(number), str(digit))
	(index1, index2) = sorted((index1, index2))
	return digit in number[index1:index2 + 1]


def check_digit(n, i, j, x):
	(i, j) = sorted([i, j])
	return str(x) in str(n)[i:j + 1]


def check_digit(n, i, j, d):
	return True if str(d) in str(n)[min(i, j):max(i, j) + 1] else False


def check_digit(number, index1, index2, digit):
	nums = str(number)
	if index2 < index1:
		(index2, index1) = (index1, index2)
	return str(digit) in nums[index1:index2 + 1]


def check_digit(number, index1, index2, digit):
	return str(digit) in str(number)[min(index1, index2):max(index1, index2) + 1]


def check_digit(s, t, p, q):
	if t < p:
		return True if str(q) in str(s)[t:p + 1] else False
	return True if str(q) in str(s)[p:t + 1] else False


def check_digit(number, index1, index2, digit):
	left = min([index1, index2])
	right = max([index1, index2])
	return True if str(digit) in str(number)[left:right + 1] else False


def check_digit(number, index1, index2, digit):
	number = str(number)
	if index1 < index2:
		index2 = index2 + 1
		return str(digit) in number[index1:index2]
	elif index2 < index1:
		index1 = index1 + 1
		return str(digit) in number[index2:index1]
	elif index1 == index2 and str(digit) == number[index1]:
		return True
	else:
		return False