Skip to content

Instantly share code, notes, and snippets.

char * b = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." - 1;
/* TINYBF - LLASARUS - 2016 */
#include <string.h>
#define N(x) abs(*b-x)==1
main(){char*m=calloc(1,20000),*p=m;while(*++b){p+=N(61)?(*b-61):0;*p-=N(44)?(*
b-44):0;if(N(92)&&*b!=91!=!*p){int c=1,x=*b-92;b-=x;while(c){c+=N(92)?(*b-92)*x:
0;b-=x;}b+=x;}if(N(45))(*b-46)?*p=getchar():putchar(*p);}}
@lasarus
lasarus / loop.c
Created August 23, 2014 21:08
Find the bug
#include <stdio.h>
int main()
{
unsigned int i;
int array[4] = {40, 20, 40, 10};
for(i = 3; i >= 0; i--)
printf("%i\n", array[i]);
Read input until newline and translate into a number
, ----- ----- [ +++++ +++++
> [ - > +++++ +++++ < ]
+++++ +++ [ - < ----- - > ]
< [ - >> + << ]
>> [ - < + > ]
<< , ----- ----- ]
Start loop and run the algorithm on each number between zero and the input number
>> - < [ > +
@lasarus
lasarus / Image creating program in brainfuck
Created July 22, 2014 12:32
This file is really long
>>>,----- -----[+++++ +++++>,----- -----]<
[<]
<<<
++++ ++++[>+++++ +++++>+++ +++<<-]>.[-]>+.[-]<<
+++++ +++++..----- -----
>>>
>
[[-<<+>>]<[->+<]>+>]
<[<++++>-]
@lasarus
lasarus / brainfuck_challenge1.bf
Created August 8, 2013 19:33
Brainfuck code to calculate the largest number with n digits divisible by m
;; solution to problem in pseudo code ;;
; maxval:=10^a-1
; minval:=10^(a-1)
; result:=maxval-(maxval%b)
; read n from input:
; cell layout (every cell is surrounded by brackets): [n][tmp][char]
>>, ; goto char and take input from stdin
----- ----- ----- ----- ----- ----- -- ; if character is 32 (' '), stop loop before it has begun
[+++++ +++++ +++++ +++++ +++++ +++++ ++ ; reset character
@lasarus
lasarus / c-array-adding.c
Created August 29, 2012 19:52
Adding numbers in C without "+"
#include <stdio.h>
/* DISCLAIMER: THIS IS NOT MEANT TO BE USED IN REAL PROGRAMS */
int main(int argc, char ** argv)
{
void * a = (void *)10;
void * b = (void *)5;
void * r;
@lasarus
lasarus / digraphs.c
Created August 27, 2012 15:41
digraphs in C
%:include <stdio.h>
int main(int argc, char ** argv)
<%
int i;
char array<:8:> = <% 'H', 'E', 'L', 'L', 'O', '!', '\n', '\0' %>;
for(i = 0; array<:i:>; i++)
fputc(array<:i:>, stdout);
@lasarus
lasarus / ascii-raycasting.c
Created August 25, 2012 17:40
ASCII Raycasting
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <math.h>
int quit = 0;
/*int screen_width = 640, screen_height = 480, screen_bpp = 32;*/
int screen_width = 1280, screen_height = 720, screen_bpp = 32;
int char_width = 8, char_height = 12;
int text_width = 80;