Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from random import uniform
- import sys
- import os
- os.system('gcc -m32 -Wall -Wfloat-equal -Wsign-conversion -Warray-bounds -Wdiv-by-zero -Wdouble-promotion -Wbool-compare -Wformat -Wformat -Werror -ftrapv -fsanitize=undefined -fsanitize=address ku02-3CHECK.c')
- MAX = 100
- myList = []
- inputList = []
- for i in range(int(sys.argv[1])):
- insert_number = randint(0, MAX)
- inputList = []
- inputList.append(insert_number)
- myList = []
- with open('test.tst', 'w') as tst:
- print(insert_number, file=tst)
- for j in range(insert_number):
- lenStr = randint(1, 10)
- string = ""
- for k in range(lenStr):
- byte = randint(32, 255)
- symbol = chr(byte)
- if symbol != ' ' and symbol != '\n':
- string += symbol
- if string == "":
- string += "sorry"
- delete_number = randint(-2 * MAX, 2 * MAX)
- print(string, delete_number, file=tst)
- inputList.append([string, delete_number])
- if delete_number < 0:
- delete_number = 0
- if len(myList) == 0:
- myList.append(string)
- else:
- found = 0
- for k in range(len(myList)):
- if myList[k] == string:
- found = 1
- break
- if not found:
- if myList[0] > string:
- myList.insert(0, string)
- else:
- found_k = 0
- not_found = 1
- for k in range(len(myList)):
- if myList[k] > string:
- not_found = 0
- found_k = k
- myList.insert(k, string)
- break
- if not_found == 1:
- myList.append(string)
- found_k = len(myList) - 1
- if delete_number != 0:
- if delete_number > found_k:
- delete_number = found_k
- start_index = found_k - delete_number
- index = start_index
- while myList[index] != string:
- myList.remove(myList[index])
- myList2 = list(map(str, os.popen('./a.out < test.tst').read().split(' ')))
- if len(myList2) > 0:
- if myList2[len(myList2) - 1] == "":
- myList2.remove("")
- if myList != myList2:
- print(i + 1, 'WA!')
- print('number of input strings was', inputList[0])
- for k in range(inputList[0]):
- print('another string and number to delete', inputList[k + 1][0], inputList[k + 1][1])
- print('your list', myList2)
- print('real list', myList)
- break
- else:
- print(i + 1, 'OK!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement