implement_crc32.py 569 B

1234567891011121314151617
  1. from evaluator import *
  2. DESCRIPTION = "Test if the model understands the CRC-32 spec well enough to implement it."
  3. TAGS = ['code', 'c']
  4. import zlib
  5. 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.'
  6. answer = "%x"%zlib.crc32(b'correct horse battery staple')
  7. TestCRC32 = question >> LLMRun() >> ExtractCode(keep_main=True) >> Echo() >> CRun() >> SubstringEvaluator(answer, lower=True)
  8. if __name__ == "__main__":
  9. print(run_test(TestCRC32))