Search
 
SCRIPT & CODE EXAMPLE
 

CPP

python to java converter

def SeatingStudents(arr):

  K = arr[0]
  occupied = arr[1:]

  rows = int(K/2)

  seats = []
  x = 0
  
  for i in range(rows):
    seats.append([])
    for j in range(2):
      if((x+1) in occupied):
        full_seat = True
      else:
        full_seat = False
      seats[i].append(str(full_seat))
      x+=1

  seating = 0
  for i in range(rows-1):
    if((seats[i][0] == str(False)) and (seats[i][1] == str(False))):
      seating+=1

    if((seats[i][0] == str(False)) and (seats[i+1][0] == str(False))):
      seating+=1

    if((seats[i][1] == str(False)) and (seats[i + 1][1] == str(False))):
      seating+=1
  
  if((seats[rows - 1][0] == str(False)) and (seats[rows - 1][1] == str(False))):
    seating+=1
  return seating

 
print(SeatingStudents([12, 2, 6, 7, 11]))
Comment

PREVIOUS NEXT
Code Example
Cpp :: Consell de forces polítiques de Catalunya 
Cpp :: InstallUtil.exe ConsoleApp 
Cpp :: how atan work c++ 
Cpp :: largest subarray with zero sum 
Cpp :: c++ convert int to string with a fixed number of digits 
Cpp :: vector insert to end 
Cpp :: pointers in cpp 
Cpp :: unambiguous 
Cpp :: coinPiles 
Cpp :: how to use printf with <cinttypes c++ 
Cpp :: finding nth most rare element code in c++ 
Cpp :: sort array in descending order c++ 
Cpp :: sfml disable message 
Cpp :: kruskal algorithm 
Cpp :: cpp module 42 
Cpp :: opengl draw cresent moon c++ 
Cpp :: vowel and consonant program in c++ using if else 
Cpp :: c++ over load oprator to print variable of clas 
Cpp :: c++ program that put a space in between characters 
Cpp :: How to execute a command and get return code stdout and stderr of command in C++ 
Cpp :: unreal engine c++ bind action to function with parameter 
Cpp :: cpprestsdk header 
Cpp :: c++ abs template 
Cpp :: qt_invok 
Cpp :: c++ constructor initializing list 
Cpp :: Explicit conversion casting 
Cpp :: generate random ints and floats 
Cpp :: c++ 
Cpp :: convert c to C language 
Cpp :: convert "c++ to c" code online 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =