{"id":20466037,"url":"https://github.com/rizerphe/tiny-brainfuck-experiments","last_synced_at":"2025-03-05T12:29:26.589Z","repository":{"id":251432300,"uuid":"837401739","full_name":"rizerphe/tiny-brainfuck-experiments","owner":"rizerphe","description":"A dump of my old hacky brainfuck scripts; I don't remember what they do exactly.","archived":false,"fork":false,"pushed_at":"2024-08-02T22:48:30.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T01:16:52.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rizerphe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-02T22:26:02.000Z","updated_at":"2024-08-02T22:48:33.000Z","dependencies_parsed_at":"2024-08-03T00:31:38.390Z","dependency_job_id":"7faf1688-2360-4272-ba9c-ad472babfb3b","html_url":"https://github.com/rizerphe/tiny-brainfuck-experiments","commit_stats":null,"previous_names":["rizerphe/tiny-brainfuck-experiments"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Ftiny-brainfuck-experiments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Ftiny-brainfuck-experiments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Ftiny-brainfuck-experiments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Ftiny-brainfuck-experiments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizerphe","download_url":"https://codeload.github.com/rizerphe/tiny-brainfuck-experiments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242027475,"owners_count":20060105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T13:21:14.181Z","updated_at":"2025-03-05T12:29:26.551Z","avatar_url":"https://github.com/rizerphe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiny brainfuck experiments\n\nA little while ago, I had an assignment the goal of which was designing an algorithm to solve some problem efficiently. I don't remember what the problem was anymore. What's important is that the problem required a single true/false answer, and that for each test case we knew whether the code failed. The idea to use this as a sidechannel to leak the test cases emerged pretty quickly. Then I joined in, and used the execution time and memory used as extra sidechannels - we had access to those as well. Pretty quickly we knew the index and value of the first unique character in each test case, leading to impossibly fast solutions.\n\nThen, I decided that I want to submit my assignment in brainfuck. Why not? The problem was, for several of the test cases, the first unique character was a couple thousand characters in. So I needed a way to read a precise number of characters. A number into the thousands. In brainfuck. Of course, I could just spam a couple megabytes of the read command. But I wanted to be just a bit more efficient. As in, I wanted the brainfuck program to be as small as I can get it.\n\nSo, the solution was generating loops. This is a collection of scripts I very quickly wrote (the assignment was due in a couple hours) that let me accurately input thousands of characters. I'm writing this readme half a year after the assignment, so I don't really remember how it works, and don't have the energy to read it all and try to understand. Iirc, the basic idea is that, for example, by just incrementing a cell, you get a loop of length 255, and within it you can read several characters, and have a nested loop that also reads several characters per iteration.\n\nMy brainfuck solution ended up being 950 bytes. If I remember it all right, it was only ever beaten by my own C solution, and the only other solution that came close was one hardcoded in java. Moral of the story: if you have cool teachers and know brainfuck, you actually can get away with hardcoding the testcases.\n\nThese scripts were just chilling in my projects directory, so I decided to upload them as is, in case anyone finds them interesting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizerphe%2Ftiny-brainfuck-experiments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizerphe%2Ftiny-brainfuck-experiments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizerphe%2Ftiny-brainfuck-experiments/lists"}