Skip to content

Instantly share code, notes, and snippets.

@naemazam
Last active October 30, 2021 10:17
Show Gist options
  • Save naemazam/2b93b092c7493ccdec95b7ffe8e9148a to your computer and use it in GitHub Desktop.
Save naemazam/2b93b092c7493ccdec95b7ffe8e9148a to your computer and use it in GitHub Desktop.
''' Given a list b with a length of 12, output its shape. If its shape can be
changed to n * m, output the changed array, otherwise output NO.
[input form] integer n and m
[output form] if n * m = 12 is satisfied, the array is output, otherwise ”NO" is
output.
[sample input]
1 12
[sample output]
[[ 1 2 3 4 5 6 7 8 9 10 11 12]]
'''
new_list = []
user = input().split()
x = int(user[0])
y = int(user[1])
n = x * y
for s in range(x):
if n <= 12:
x_list = []
for i in range(1, y+1):
x_list.append(i)
new_list.append(x_list)
else:
print("No")
print(new_list)
@naemazam
Copy link
Author

naemazam commented Oct 30, 2021

You can do it By this way also

import numpy as np
n,m=map(int,input("Enter n,m: ").split())
a=np.arange(1,13)
if n*m==a.shape[0]:
print(a)
else:
print("NO")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment