Weird midterm results vol. 3


I've graded many tests from 2025. From 2026 I taught 3 subject in university: C programming, Python programming and C/C++ modern features. Here are the most hilarious results from C,Python programming midterms and C++ assignments.

from 2025. second semester to 2026. first semester


consts are missing:


void operator*=(Ratio &r1, const Ratio &r2){
    r1 = r1 * r2;
}
					

Old but missed (vibe coded chess engine code snippets):


//Overall, the code is inconsistent. Some use undeclared structs and there is code duplication, unsafe operations, AI hallucinations, Windows api calls everywhere. This is supposed to run on cross platform.
//The specification for this type of assignment must be a pdf. For this specific assignment I received a txt file where the extension was renamed to .pdf. So not a real PDF file.
#define DEBUGMALLOC_ENABLED //This was hallucinated by AI. Debugmalloc is our university's in-house leak detector and does not need this.

#include "moves.h"
#include "board.h"
#include "debugmalloc.h"

static char* moves[4096];
static int move_count = 0;
static int game_over = 0;
static int checks_enabled = 1; //Global variables are not allowed inside the assignment
//...
typedef struct {
    char ***tabla; //WTF
    int *oszlop;
    int sor_szam;
} kerdesek;
//...
void record_move(const char* move) {
    if (move_count < 4096)
        moves[move_count++] = strdup(move);
}
char** get_moves(void) { return moves; }
//...
void fixfelfedett(int size, int felfedett[size][size], int board[size][size]) {
    int copy[size][size];
    makezero(size, copy);
    while (memcmp(copy, felfedett, sizeof(int)*size*size) != 0) {
        memcpy(copy, felfedett, sizeof(int)*size*size);
        for (int x=0; x<size; x++) {
            for (int y=0; y<size; y++) {
                if (felfedett[x][y]==1 && board[x][y]==0) {
                    for (int i=x-1; i<=x+1; i++) {
                        for (int j=y-1; j<=y+1; j++) {
                            if (i>=0 && j>=0 && i<size && j<size) {
/*Hadooken*/                    felfedett[i][j]=1;
                            }
                        }
                    }
                }
            }
        }
    }
}
//...
int fm_load_moves(const char* filename, char*** moves_out); //What are these params??
int fm_save_moves(const char* filename, char** moves, int count);
//Board.c:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wchar.h>

#include "debugmalloc.h"
#include "board.h"

wchar_t* white_pieces_unicode[] = {[0]=L"♚",[1]=L"♛",[2]=L"♜",[3]=L"♝",[4]=L"♞",[5]=L"♟"}; //Wtf? assignment must be cross platform.
wchar_t* black_pieces_unicode[] = {[0]=L"♔",[1]=L"♕",[2]=L"♖",[3]=L"♗",[4]=L"♘",[5]=L"♙"};
//...
//Holy hell... just look. This is not cross platform at all.
#include <windows.h>

void print_board(Piece*** board) {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    wchar_t buffer[32];

    wprintf(L"  a b c d e f g h\n");
    for (int r = 0; r < 8; r++) {
        wsprintfW(buffer, L"%d ", 8-r);
        DWORD written;
        WriteConsoleW(hConsole, buffer, wcslen(buffer), &written, NULL);

        for (int c = 0; c < 8; c++) {
            Piece* p = board[r][c];
            wchar_t* s = L".";
            if (p) {
                int id = -1;
                if (p->type == 'K') id = 0;
                else if (p->type == 'Q') id = 1;
                else if (p->type == 'R') id = 2;
                else if (p->type == 'B') id = 3;
                else if (p->type == 'N') id = 4;
                else if (p->type == 'P') id = 5;

                s = (p->color == 'w') ? white_pieces_unicode[id] : black_pieces_unicode[id];
            }
            wsprintfW(buffer, L"%ls ", s);
            WriteConsoleW(hConsole, buffer, wcslen(buffer), &written, NULL);
        }

        wsprintfW(buffer, L"%d\n", 8-r);
        WriteConsoleW(hConsole, buffer, wcslen(buffer), &written, NULL);
    }
    wprintf(L"  a b c d e f g h\n");
}
					

Formatting only AI would do:


int days_in_month(int year, int month){
    switch(month){
    case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31;
    case 4: case 6: case 9: case 11: return 30;
    case 2: return (leap_year(year)? 29 : 28);
    }
    return 0;
}
					

Very manual string ops:


void elso_menupont(Lista **telefonkonyv){
    Temp t;
    int i=0;
    int c=0;
    if(scanf(" %[^\n]", t.temporary)!=1) return;

    while(t.temporary[c]!=',' && i<50){
        t.nev[i++]=t.temporary[c++];
    }
    t.nev[i]='\0';
    if(t.temporary[c]==',') c++;
    while(t.temporary[c]==' ') c++;
    i=0;

    while(t.temporary[c]!=',' && i<50){
        t.foglalkozas[i++]=t.temporary[c++];
    }
    t.foglalkozas[i]='\0';
    i=0;
    if(t.temporary[c]==',') c++;
    while(t.temporary[c]==' ') c++;

    while(t.temporary[c]!=',' && i<100){
        t.cim[i++]=t.temporary[c++];
    }
    t.cim[i]='\0';
    i=0;
    if(t.temporary[c]==',') c++;
    while (t.temporary[c] == ' ' || t.temporary[c] == '\r' || t.temporary[c] == '\t') c++;

    while(t.temporary[c]!='\0' && t.temporary[c]!='\n' && t.temporary[c]!='\r' && i<30){
        t.telefonszam[i++]=t.temporary[c++];
    }
    t.telefonszam[i]='\0';
    Rekord uj={0};
    strcpy(uj.nev, t.nev);
    strcpy(uj.foglalkozas, t.foglalkozas);
    strcpy(uj.cim, t.cim);
    strcpy(uj.telefonszam, t.telefonszam);
    printf("telefonszam:%s\n", uj.telefonszam);

    hozzaad(telefonkonyv, uj);
}
					

Some weird things but not necessary coding:


someone uploaded a "kanyewest.c" named file for assignment. It is wholesome.

There was a "Magán[ ]tanárt keresek!" (Translates to: "I seek a private tutor.") on a test which scored low points. It was hilarious but we couldn't accept it because of university contracts.
					

ER symbols in UML:



					

Veryyyy nice UML:



					

EER IS-A relation in UML:



					

Whaaaat?:


//The task was to determine that what grade should a test point sum worth (from 0-150 points). Lol.
#include <stdio.h>

int jegy (int pontszam) {
    switch (pontszam)
        case 1: if (pontszam =< 55)
            Return 1;
            Break;
        case 2: if (pontszam <= 79 && pontszam >= 56)
            Return 2;
            Break;
        case 3: if (pontszam <= 103 && pontszam >= 80)
            Return 3;
            Break;
        case 4: if (pontszam <= 121 && pontszam >= 104)
            Return 4;
            Break;
        case 5: if (pontszam >= 122)
            Return 5;
            Break;
        default
					

Weird array syntax:


int int arr = ...;
//Hmm, apparently int^2 is an int array, huh?
					

0 has 2 divisors :/ :


//...
if(x == 0) return 2;
//...
					

No comment:


#include <std.io>
					

If true:


//...
if (n % 1 == 0) return 1;
//...
					

intlen??:


//...
return intlen(input_num);
//...
					

???:


//...
int char[1] = {*};
//...
					

O(1) max in unsorted input, heh:


int max (int szam) {
    int max = 0;
    if (szam > max) {
        max = szam
    }
    return max;
}
					

You get an IMMERSEly large grade!:


int pont (int pontszam) {
    int jegy;
    for (int i = 0; i <= pontszam; i++) {
        if (pontszam[i] < 55)
            jegy += 1;
        if (pontszam >= 56 && pontszam <= 79)
            jegy += 2;
        if (pontszam >= 80 && pontszam <= 103)
            jegy += 3;
        if (pontszam >= 104 && pontszam <= 121)
            jegy += 4;
        if (pontszam >= 122)
            jegy += 5;
    return jegy;
					

Weird indent:


int jegyszamolo (int pont) {
    if (pont >= 122)
        return 5;
    else
        if (pont >= 104)
            return 4;
        else
            if (pont >= 80)
                return 3;
            else
                if (pont >= 56)
                    return 2;
                else
                    return 1;
}
					

Functor in C??:


#include <stdio.h>

typedef struct {
    int pontszam;
} szamito;

int 1db, 2db, 3db, 4db, 5db;

szamito (void) {
    szamito jegy;
    scanf("%d", & jegy.pontszam);
    return jegy; 
}

szamol (szamito jegy) {
    if (jegy == 1) {
        1db++;
    }
    else if (jegy == 2) {
        2db++;
    }
    else if (jegy == 3) {
        3db++;
					

wtf python syntax:


szemelyek[] = ""
oradb = 0
be = int(input())

while be != "":

    szemelyek.append(split.be(" "))))
    ido = split.be(0)
    szemelydb = split.be(1)
    split.ido(":")
    ora = split.ido(0)

    for orak in range(0,23):
        if ora == orak:
            oradb += szemelydb
    print(f"{ora:2}:00-{ora:2}:59 -> {oradb}")
					


Go back to main page