gpt-4o-2024-05-13· openai
from WildChat-4.8M
Write a python program that takes two 11 integer array element (one input per line) and…
- User
Write a python program that takes two 11 integer array element (one input per line) and gives output YES if there is a permutation of the first array that is equal to the second array or gives output NO, if there is no such permutation. Only use input() to get input from the console
- Assistant
Certainly! Below is a simple Python program that checks if there is a permutation of one array that matches another array. The program takes two sets of 11 integers as input (one integer per line) and outputs "YES" if they are permutations of each other, otherwise "NO".
pythondef get_input_array(size): array = [] for _ in range(size): array.append(int(input())) return array def are_permutations(array1, array2): return sorted(array1) == sorted(array2) # Define the size of the arrays size = 11 # Get input arrays print("Enter 11 integers for the first array (one per line):") array1 = get_input_array(size) print("Enter 11 integers for the second array (one per line):") array2 = get_input_array(size) # Check if one array is a permutation of the other if are_permutations(array1, array2): print("YES") else: print("NO")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.