blob: 91178462c1dc1eaded2004b0914be12767134cdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env python3
import sys
def good_integer(n: int) -> str:
# Convert the integer to a string
value = str(n)
length = len(value)
for pos in range(length-2):
if (
value[pos] == value[pos+1]
and value[pos] == value[pos+2]
and (pos == 0 or value[pos] != value[pos-1])
and (pos + 3 == length or value[pos] != value[pos+3])
):
return value[pos:pos+3]
return '-1'
def main():
# Convert input into an integer
result = good_integer(int(sys.argv[1]))
print(result)
if __name__ == '__main__':
main()
|