コード例 #1
0
ファイル: compare.py プロジェクト: JunHill/Test_generator
                                           PERCENTAGE["total"],
                                           PERCENTAGE["coin_value"]):
    end = floor(p * TEST_NUM)
    for i in range(current_test, end):
        # Define a Problem
        Problem = {}
        Problem["N"] = random.randint(last_total,
                                      floor(p_total * CONSTRAINTS["total"]))
        Problem["S"] = []
        NUM_COIN = random.randint(last_num_coin,
                                  floor(p_num_coin * CONSTRAINTS["num_coin"]))
        for k in range(0, NUM_COIN):
            Problem["S"].append(
                random.randint(last_coin_value,
                               floor(p_value * CONSTRAINTS["coin_value"])))

        res = str(solution(Problem))
        line = file.readline()
        if not line:
            break
        try:
            assert res + "\n" == line
            print(f"Passed test {i}")
        except:
            print(f"Failed Test {i}, Expect {line} , Got {res}")

    last_coin_value = floor(p_value * CONSTRAINTS["coin_value"])
    last_num_coin = floor(p_num_coin * CONSTRAINTS["num_coin"])
    last_total = floor(p_total * CONSTRAINTS["total"])
    current_test = end
コード例 #2
0
        Problem = {}
        Problem["X"] = ""
        Problem["Y"] = ""

        LENGTH = random.randint(last_length, floor(p_length * C_LENGTH))
        for k in range(0, LENGTH):
            Problem["X"] += random.choice(C_LETTERS[0:floor(p_variation *
                                                            C_WORD_VARIATION)])

        LENGTH = random.randint(last_length, floor(p_length * C_LENGTH))
        for k in range(0, LENGTH):
            Problem["Y"] += random.choice(C_LETTERS[0:floor(p_variation *
                                                            C_WORD_VARIATION)])

        # Write problem to file inp.txt
        inp = open("inp.txt", 'a')
        inp.write(Problem["X"] + "\n")
        inp.write(Problem["Y"] + "\n")
        inp.close()

        # Write solution to file out.txt
        out = open("out.txt", 'a')
        out.write(str(solution(Problem)) + "\n")
        out.close()

        print(f"TEST {i} CREATED!")

    last_length = floor(p_length * C_LENGTH)
    last_variation = floor(p_variation * C_WORD_VARIATION)
    current_test = end
コード例 #3
0
import solution2

print(solution2.solution([2, 1, 3, 2], 2))  # 1
print(solution2.solution([1, 1, 9, 1, 1, 1], 0))  # 5
コード例 #4
0
# 2번
from solution2 import solution


a = [1,2,3,4]
b = [-3,-1,0,2]
print(solution(a, b))

a = [-1,0,1]
b = [1,0,-1]
print(solution(a, b))


コード例 #5
0
def test_solution():
    assert solution('2018/input/input2.txt') == (7776, 'wlkigsqyfecjqqmnxaktdrhbz')
コード例 #6
0
from solution2 import solution
print(solution([1, 3, 4, 1]))  # [2, 4, 5, 7]
print(solution([7, 3, 9, 3, 8, 4]))  # [6, 7, 10, 11, 12, 13, 15, 16, 17]
コード例 #7
0
from solution2 import solution

nums = [1, 1, 2, 2, 3, 4]
print(solution(nums))

nums = [1, 2, 2, 2, 2, 2, 5, 5]
print(solution(nums))

nums = [300, 1, 2, 5, 10, 4, 4]
print(solution(nums))

nums = [1, 1, 1, 1]
print(solution(nums))