import os
lst = os.listdir("E:/Minecraft/Random_Appearance/Resourcepack/assets/minecraft/items")
flags = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while flags != [1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1]:
    cnt = 0
    func = "select"
    for i in range(10):
        cnt += flags[10-i] * 2 ** (10-i)
        func += "/%d" % flags[10-i]
        try:
            os.mkdir(func)
        except:
            pass
        with open(func + ".mcfunction", 'w+') as text:
            text.write('''$execute as @a if score global ra.model matches %d..%d run function ra:%s/0 {slot: $(slot)}
$execute as @a if score global ra.model matches %d..%d run function ra:%s/1 {slot: $(slot)}\n
''' % (
                cnt, cnt + 2**(9-i) - 1, func,
                cnt + 2**(9-i), cnt + 2**(10-i) - 1, func
                )
            )
        
    cnt += flags[0]
    func += "/%d" % flags[0]
    with open(func + ".mcfunction", 'w+') as text:
        text.write("$execute as @a if score global ra.model matches %d.. run item modify entity @s $(slot) ra:%s\n" % (
            cnt, lst[cnt][:-5]
            )
        )
    flags[0] += 1
    pin = 0
    while flags[pin] == 2:
        flags[pin] = 0
        flags[pin + 1] += 1
        pin += 1
