title: Reading in a single line of integers and performing operations in Python
body: <p>I can read in the integers line by line but I am not sure how to modify the code so that it reads in a single line of 5 integers in this question.</p>
  <p>Alice has invented a new card game to play with Bob. Alice made a deck of cards with random values between 1 and 52. Bob picks 5 cards. Then, he has to rearrange the cards so that by utilizing the operations plus, minus, or times, the value of the cards reach Alice's favorite number. 42. More precisely find operations such that ((((val1 op1 val2) op2 val3) op3 val4) op4 val) = 42. Help Bob by writing a program to determine whether it is possible to reach 42 given 5 card values. For example, Bob picks 5 cards out of the deck containing 40, 1, 3, 4, and 20. Bob rearranges the cards and supplies four operations, so that 4 * 20 - 40 + 3 - 1 = 42. Input: The input consists of five integers on a line, separated by spaces. Each integer is between 1 and 52, inclusive, Output: Print a line containing &quot;YES&quot; if it is possible to reach the value 42 according to the rules of the game, or &quot;NO&quot; otherwise.
  Test Input: <code>40 1 3 4 20</code>
  Expected Output: <code>YES</code></p>
  <p>My Solution but it reads numbers line by line:</p>
  <pre><code>import itertools
  
  def Permutations(Lst,size):
      return list(itertools.permutations(Lst,size))
  
  def expression(lst1,lst2):
      for x in lst1:
          for i in lst2:
              op1=i[0]
              op2=i[1]
              op3=i[2]
              op4=i[3]
  
              str1=str(x[0])+op1+str(x[1])
              str2=str(str1)+op2+str(x[2])
              str3=str(str2)+op3+str(x[3])
              str4=str(str3)+op4+str(x[4])
              exp=eval(str4)
  
              if(exp==42):
                  return True
      return False
  
  Numbers=[]
  i=0
  while(i&lt;5):
      n=int(input())
      Numbers.append(n)
      i=i+1
  
  NumPermutations=Permutations(Numbers,5)
  
  Operators=['+','-','*','+','-','*']
  
  OpPermutations=Permutations(Operators,4)
  
  Result=expression(NumPermutations,OpPermutations)
  
  if(Result==True):
      print(&quot;\nYES&quot;)
  else:
      print(&quot;\nNO&quot;)
  </code></pre>