Menu
Coddy logo textTech

Positions

Lesson 12 of 25 in Coddy's Coding Problems: Volume 2 course.

Create a program that for given two numbers will check if every digit in an odd position from the first number can be found in an even position in the second. If the condition is fulfilled output YES, otherwise output NO. The first position is 0 (even)

challenge icon

Challenge

Medium

Write a program that reads two natural numbers from input and checks if the condition is true, output YES if it is, and NO otherwise

Input
1234567
654321

Output
YES

Explanation
The digit 2 is on index 1 (odd) in the first number, while in the second is on index 4 (even), 4 is on index 3 in the first, while in the second it's on index 2, and finally 6 is on index 5 in the first and on index 0 in the second

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems: Volume 2