MahmoudElShaer's blog

By MahmoudElShaer, history, 4 years ago, In English

I'm new to problem-solving, I begin with python but my submission keeps show run time error also it runs very well on Terminal this the problem link

and this my code

import numpy as np

def input_func():
    return list(map(int, input().split()))

def cum_sum(gold_array):
    return np.cumsum(gold_array)

def re_arrange(gold_array):
    np.random.shuffle(gold_array)
    return cum_sum(gold_array)


for _ in range(num_cases):
    _, x = input_func()
    gold_array = np.array(input_func())

for i in range(num_cases):
    if x not in cum_sum(gold_array):
        print("YES")
        print(*gold_array)
    elif True:
        flag = 10
        while flag > 0 :
            if x not in re_arrange(gold_array):
                print("YES")
                print(*gold_array)
                break
            flag -= 1
    else:
        print("NO")

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it