Knowee
Questions
Features
Study Tools

A number ‘n’ in a list at index ‘i’ (human indexing) is said to be a factor indexed number if ‘i’ is a factor ‘n’. Given two lists of numbers l1 and l2 form a list l3 by inserting factor indexed numbers of l1 and l2. Intialize index to ‘0’ visit elements of l1 and l2 at index, if one of them is factored indexed insert and increment index and go till end of the list. If both of them are factor indexed then insert element of l1 at index and then element of l2 at index and increment index. If end of one of the list is reached then add elements of other list to l3 if they are factor indexed. After construction of l3, Print the numbers which continues to be factor indexed in l3.For example, if l1 contains 15, 12, 17, 32, 26, 42 and l2 contains 45, 34, 64, 80 then l3 will be 15, 45, 12, 34, 32, 80, 42 then print 15, 12, 42.Input FormatFirst line contains the number of elements in l1, n1Next ‘n1’ lines contain the elements of l1Next line contains the number of elements in l2, n2Next ‘n2’ lines contain the elements of l2Output FormatPrint good numbers of l3 one number in a line

Question

A number ‘n’ in a list at index ‘i’ (human indexing) is said to be a factor indexed number if ‘i’ is a factor ‘n’. Given two lists of numbers l1 and l2 form a list l3 by inserting factor indexed numbers of l1 and l2. Intialize index to ‘0’ visit elements of l1 and l2 at index, if one of them is factored indexed insert and increment index and go till end of the list. If both of them are factor indexed then insert element of l1 at index and then element of l2 at index and increment index. If end of one of the list is reached then add elements of other list to l3 if they are factor indexed. After construction of l3, Print the numbers which continues to be factor indexed in l3.For example, if l1 contains 15, 12, 17, 32, 26, 42 and l2 contains 45, 34, 64, 80 then l3 will be 15, 45, 12, 34, 32, 80, 42 then print 15, 12, 42.Input FormatFirst line contains the number of elements in l1, n1Next ‘n1’ lines contain the elements of l1Next line contains the number of elements in l2, n2Next ‘n2’ lines contain the elements of l2Output FormatPrint good numbers of l3 one number in a line

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To solve this problem, we need to follow the given steps:

  1. Read the number of elements in list l1, n1.
  2. Read the elements of list l1.
  3. Read the number of elements in list l2, n2.
  4. Read the elements of list l2.
  5. Initialize an index variable to 0.
  6. Create an empty list l3 to store the factor indexed numbers.
  7. Iterate through the elements of l1 and l2 simultaneously using the index variable.
  8. Check if either element at the current index is a factor indexed number.
  9. If only one of them is a factor indexed number, insert it into l3 and increment the index.
  10. If both elements are factor indexed numbers, insert the element from l1 into l3, then insert the element from l2 into l3, and increment the index.
  11. If the end of one of the lists is reached, add the remaining elements of the other list to l3 if they are factor indexed.
  12. After constructing l3, iterate through its elements and print the numbers that continue to be factor indexed.

For example, if l1 contains [15, 12, 17, 32, 26, 42] and l2 contains [45, 34, 64, 80], the resulting l3 will be [15, 45, 12, 34, 32, 80, 42]. From l3, we need to print the numbers 15, 12, and 42.

Input Format:

  • The first line contains the number of elements in l1, n1.
  • The next n1 lines contain the elements of l1.
  • The next line contains the number of elements in l2, n2.
  • The next n2 lines contain the elements of l2.

Output Format:

  • Print the good numbers of l3, one number per line.

This problem has been solved

Similar Questions

number if ‘i’ is a factor ‘n’. Given two lists of numbers l1 and l2 form a list l3 by inserting factor indexed numbers of l1 and l2. Intialize index to ‘0’ visit elements of l1 and l2 at index, if one of them is factored indexed insert and increment index and go till end of the list. If both of them are factor indexed then insert element of l1 at index and then element of l2 at index and increment index. If end of one of the list is reached then add elements of other list to l3 if they are factor indexed. After construction of l3, Print the numbers which continues to be factor indexed in l3.

What is an Index?

A(n) _____________________ is a list collection has elements whose elements can be referenced using a numeric index. A. indexed list B. array C. ordered list D. linked list E. unordered list

List items have an index number. In the following list , which item has index number 3?["John", "Harry", "Jesse", "John", "Harry", "Harry"]A"John"B"Harry"C"Jesse"DThere is no single right answer

Indexing is used to:1 pointCreate order to multiple subjectsTo identify who, what, or whereTo indicate directionNone of the above

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.