Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
- The question must be Community-wiki. Please flag for moderator attention to make it so.
import java.util.List; | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.Iterators; | |
import com.google.common.collect.PeekingIterator; | |
public class Comm { | |
public static class Result { | |
public final ImmutableList<Integer> only1; | |
public final ImmutableList<Integer> only2; | |
public final ImmutableList<Integer> both; |
(define (modexp a b q) | |
(define (modmul a b) | |
(modulo (* a b) q)) | |
(do ((a a (modmul a a)) | |
(b b (quotient b 2)) | |
(r 1 (if (odd? b) (modmul r a) r))) | |
((zero? b) r))) |
package nz.kiwi.chris.j7gs.types; | |
import com.google.common.base.Preconditions; | |
public class GSString implements Comparable<GSString> { | |
private final String value; | |
public GSString(String value) { | |
this.value = value; | |
} |
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <memory> | |
#include <boost/format.hpp> | |
#include <boost/iostreams/categories.hpp> | |
#include <boost/iostreams/copy.hpp> |
#lang racket | |
(require (for-syntax unstable/syntax)) | |
(provide (rename-out [*in-nest-sequence in-nest-sequence])) | |
(define in-nest-sequence | |
(case-lambda | |
[(func init) | |
(make-do-sequence | |
(thunk (values identity func init #f #f #f)))] | |
[(func . inits) |
#lang racket | |
(define (primes-less-than n) | |
(define size (sub1 (quotient n 2))) | |
(define table (build-vector size (lambda (i) (+ i i 3)))) | |
(for ((x (in-vector table 0 (integer-sqrt size))) | |
#:when x | |
(y (in-range (quotient (- (* x x) 3) 2) size x))) | |
(vector-set! table y #f)) | |
(cons 2 (filter values (vector->list table)))) |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
(define-syntax pollute-my-namespace | |
(let ((letters "abcdefghijklmnopqrstuvwxyz_") | |
(char->symbol (compose string->symbol string))) | |
(define (make-macros stx) | |
(lambda () | |
(for*/lists (ids syntaxes) | |
((x letters) | |
(y letters)) | |
(if (char=? x y) | |
(values (datum->syntax stx (char->symbol #\^ x)) |
#lang racket | |
(define (determinant p1 p2) | |
(- (* (car p1) (cdr p2)) | |
(* (cdr p1) (car p2)))) | |
(define points (read)) | |
(define first (cons (read) (read))) | |
(define-values (area last) | |
(for/fold ([area 0] [last first]) | |
([i (in-range (sub1 points))] |
#lang racket | |
(define (expmod base exp m) | |
(let recur ([exp exp]) | |
(cond [(zero? exp) 1] | |
[(even? exp) (let* ([prev (recur (quotient exp 2))] | |
[result (modulo (sqr prev) m)]) | |
(if (and (< 1 prev (sub1 m)) | |
(= result 1)) | |
0 | |
result))] |