0
Find Matching pairs of numbers
How could code be written to output a number for every two numbers that are identical? For example given 223323436577 would print out 2 3 7.
3 Respuestas
+ 2
'''With 2 numbers that are identical I assume you mean 2 characters that are next to each other that are the same
In that case, try this in Python.'''
'''Find Matching pairs of numbers
How could code be written to output a number for every two numbers that are identical? For example given 223323436577 would print out 2 3 7.'''
inp='223323436577'
print(*[inp[i] for i in range(len(inp)-1) if(inp[i]==inp[i+1])])
+ 1
You have not mentioned the language but in python its very simple,
l=set(map(int,list(input())))
for i in l:
print(i,end=' ')
Here we have split the input and the set converts all the same type of digits into a single value or in short deletes all duplicate values from the input.
0
The best way, in my opinion, would be to convert whatever it is into a String, then run it through a Regular Expression Comparison.
Find recurring numbers, assign them to an array then print the result.
For a step-interval of 2 if looping through, use your language's equivalent of the 'continue' statement to repeat without execution.