Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 205ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
g

generator

Recently created Least recently created Recently updated Least recently updated
myceliatrix

myceliatrix / Is even

Last active 2 months ago shitposts python c generator

A generator that spits out a massive amount of C for a useless task

0 0 1
1 import sys
2
3 def generate_subfunction(file, start, end):
4 file.write(f"int is_even_{start}_{end}(int num) {{\n")
5 conditions = ""
6 for i in range(start, end + 1):
7 even_check = "1" if i % 2 == 0 else "0"
8 conditions += f"(num == {i}) ? {even_check} : "
9 conditions += "0"
10 file.write(f" return {conditions};\n")