1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from evaluator import *

DESCRIPTION = "Test if the model understands the CRC-32 spec well enough to implement it."

TAGS = ['code', 'c']
import zlib

question = 'Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.'

answer = "%x"%zlib.crc32(b'correct horse battery staple')

TestCRC32 = question >> LLMRun() >> ExtractCode(keep_main=True) >> Echo() >> CRun() >> SubstringEvaluator(answer, lower=True)


if __name__ == "__main__":
    print(run_test(TestCRC32))