Last active
August 1, 2020 21:34
-
-
Save mojobojo/3722dabc35ad0a4d0fce0b30c45ab93d to your computer and use it in GitHub Desktop.
just need some metacode for it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
cfile = open("even.c", "w") | |
cfile.write("#include <stdio.h>\n#include <stdlib.h>\n\n#define true 1\n#define false 0\n\n") | |
cfile.write("int is_even(int n) {\nn = abs(n);\n") | |
for i in range(0, 2147483647 + 1): | |
# just here so I can see progress... | |
if i % 1000000 == 0: | |
print(str(i)) | |
if i % 2 == 0: | |
cfile.write("if(n == " + str(i) + ") return true;\n") | |
else: | |
cfile.write("if(n == " + str(i) + ") return false;\n") | |
cfile.write("}\n\nint main(int argc, char **argv) {\n int num = atoi(argv[1]);\n int result = is_even(num);\n\n if (result) {\n printf(\"even\");\n } else {\n printf(\"odd\");\n }\n return 0;\n}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment