Amazon Lab126 firmware validation may need to inspect an integer configuration value and transform selected flag bits. Given a non-negative integer n and two bit indices, determine whether n is prime and swap the bits at those positions using bit manipulation.
Bit index 0 is the least significant bit. The swap must work even when one position currently contains 0. Return both results in a dictionary with keys is_prime and swapped.
Implement prime_and_swap(n, i, j):
n, a non-negative integer; i and j, zero-based bit indices.is_prime, a Boolean indicating whether the original n is prime, and swapped, the integer after exchanging bits i and j.def prime_and_swap(n, i, j):