This file contains hidden or 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
| #include <signal.h> | |
| #include <sys/ioctl.h> | |
| #include <unistd.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| static void winch_handler(int); | |
| static void print_tdim(void); |
This file contains hidden or 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
| Note 'author' | |
| The Computer Language Benchmarks Game | |
| http://benchmarksgame.alioth.debian.org/ | |
| contributed by Robert Clausecker <[email protected]> | |
| ) | |
| NB. entry at x,y of infinite matrix A | |
| A =: >:@:[ %@:+ -:@:(* >:)@:+ | |
| NB. get the first y by y elements of A |
This file contains hidden or 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
| /* | |
| * access the array b at row d, column e. Allow extra index parts before the | |
| * closing bracket. Usually used as I] to get b[d * g + e]. All occurances of | |
| * this macros are commented in the next parts. | |
| */ | |
| #define I b[d*g+e | |
| /* int */ a; /* updated content of cell at b[d*g+e] */ | |
| /* int */ b[65536]; /* array containing the board */ | |
| /* int */ c; /* cleared if the flood-fill fills something, score */ |
This file contains hidden or 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
| /*- | |
| * Reference implementation and judging program for the Paeth challenge. | |
| * Published under CC-BY by Robert Clausecker (FUZxxl). | |
| */ | |
| #include <stdarg.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <time.h> |
This file contains hidden or 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
| /* http://codegolf.stackexchange.com/q/48528/134 */ | |
| /* by Robert Clausecker (FUZxxl) */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <limits.h> | |
| #include <stdint.h> | |
| enum opcode { HALT, PRINTX, INCX, INCY, JMP, DJZX, DJZY }; | |
| const char *mnemonics[7] = { |
This file contains hidden or 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
| /* http://stackoverflow.com/a/1732454/417501 */ | |
| %{ | |
| #include <ctype.h> | |
| #include <string.h> | |
| #include "urlscanner.h" | |
| %} | |
| /* yylineno ist unportabel und nicht Teil von POSIX! */ |
This file contains hidden or 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
| .section .text | |
| .type bcd2dpd,@function | |
| .globl bcd2dpd | |
| # convert three digits in packed BCD to DPD | |
| # input in edi, all but the lower three nibbles are ignored | |
| # does not check if nibble > 9 | |
| .align 8 | |
| bcd2dpd: | |
| # prepare arguments for call to decimal2dpd |
This file contains hidden or 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
| extern unsigned | |
| decimal2dpd(unsigned a, unsigned b, unsigned c) | |
| { | |
| unsigned result = c & 1 | (a & 7) << 7; | |
| if (a < 8) { | |
| if (b < 8) | |
| return result | b << 4 | c; | |
| else | |
| return result | (c > 7 ? 0104 : (c & 6) << 4) | (b & 1) << 4 | 0012; |
This file contains hidden or 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
| .section .text | |
| .type bcd2dpd_mul,@function | |
| .globl bcd2dpd_mul | |
| # convert BCD to DPD with multiplication tricks | |
| # input abcd efgh iklm in edi | |
| .align 8 | |
| bcd2dpd_mul: | |
| mov %edi,%eax # = 0000 abcd efgh iklm | |
| shl %al # = 0000 abcd fghi klm0 |
This file contains hidden or 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
| package main | |
| // https://www.reddit.com/r/coding/comments/3vsw5o/gettin_arithmetic_mean_right/ | |
| import "fmt" | |
| import "math/big" | |
| import "math/rand" | |
| func naiveMean(rnd *rand.Rand, n int) float64 { | |
| sum := 0.0 |