code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
const char *coin_err;
typedef unsigned char byte;
int is_hex(const char *s) {
int i;
for (i = 0; i < 64; i++)
if (!isxdigit(s[i])) return 0;
return 1;
}
void str_to_byte(const char *src, byte *dst, int n) {
while (n--) sscanf(src + n * 2, , dst + n);
}
char* base58(byte *s, char *out) {
static const char *tm... | 1,093Bitcoin/public point to address | 5c | yc06f |
null | 1,091Bitmap/Bézier curves/Quadratic | 11kotlin | 25tli |
static int width, height;
static BYTE bitmap[MAXSIZE][MAXSIZE];
static BYTE oldColor;
static BYTE newColor;
void floodFill(int i, int j)
{
if ( 0 <= i && i < height
&& 0 <= j && j < width
&& bitmap[i][j] == oldColor )
{
bitmap[i][j] = newColor;
floodFill(i-1,j);
floodFi... | 1,094Bitmap/Flood fill | 5c | v4d2o |
function replace(input: string, key: number) : string {
return input.replace(/([a-z])/g,
($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 97) % 26 + 97)
).replace(/([A-Z])/g,
($1) => String.fromCharCode(($1.charCodeAt(0) + key + 26 - 65) % 26 + 65));
} | 1,083Caesar cipher | 20typescript | sisqj |
define('src_name', 'input.jpg');
define('dest_name', 'output.jpg');
$img = imagecreatefromjpeg(src_name);
if(empty($img)){
echo 'Image could not be loaded!';
exit;
}
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
$width = imagesx($img);
$height = imagesy($img);
... | 1,089Bitmap/Histogram | 12php | 7k2rp |
Bitmap.quadraticbezier = function(self, x1, y1, x2, y2, x3, y3, nseg)
nseg = nseg or 10
local prevx, prevy, currx, curry
for i = 0, nseg do
local t = i / nseg
local a, b, c = (1-t)^2, 2*t*(1-t), t^2
prevx, prevy = currx, curry
currx = math.floor(a * x1 + b * x2 + c * x3 + 0.5)
curry = math.flo... | 1,091Bitmap/Bézier curves/Quadratic | 1lua | v4z2x |
package raster | 1,092Bitmap/Midpoint circle algorithm | 0go | ludcw |
void cubic_bezier(
image img,
unsigned int x1, unsigned int y1,
unsigned int x2, unsigned int y2,
unsigned int x3, unsigned int y3,
unsigned int x4, unsigned int y4,
color_component r,
color_component g,
color_component b ); | 1,095Bitmap/Bézier curves/Cubic | 5c | ugdv4 |
int main()
{
int i, j;
double degrees[] = { 0.0, 16.87, 16.88, 33.75, 50.62, 50.63, 67.5,
84.37, 84.38, 101.25, 118.12, 118.13, 135.0, 151.87, 151.88,
168.75, 185.62, 185.63, 202.5, 219.37, 219.38, 236.25, 253.12,
253.13, 270.0, 286.87, 286.88, 303.75, 320... | 1,096Box the compass | 5c | gjt45 |
module Circle where
import Data.List
type Point = (Int, Int)
generateCirclePoints :: Point -> Int -> [Point]
generateCirclePoints (x0, y0) radius
= (x0, y0 + radius): (x0, y0 - radius): (x0 + radius, y0): (x0 - radius, y0): points
where
points = concatMap generatePoints $ unfoldr step initialV... | 1,092Bitmap/Midpoint circle algorithm | 8haskell | 1w5ps |
from PIL import Image
image = Image.open()
width, height = image.size
amount = width * height
total = 0
bw_image = Image.new('L', (width, height), 0)
bm_image = Image.new('1', (width, height), 0)
for h in range(0, height):
for w in range(0, width):
r, g, b = image.getpixel((w, h))
greyscal... | 1,089Bitmap/Histogram | 3python | dzqn1 |
import java.awt.Color;
public class MidPointCircle {
private BasicBitmapStorage image;
public MidPointCircle(final int imageWidth, final int imageHeight) {
this.image = new BasicBitmapStorage(imageWidth, imageHeight);
}
private void drawCircle(final int centerX, final int centerY, final int radius) {
int d =... | 1,092Bitmap/Midpoint circle algorithm | 9java | 7k9rj |
const char *coin_err;
int unbase58(const char *s, unsigned char *out) {
static const char *tmpl =
;
int i, j, c;
const char *p;
memset(out, 0, 25);
for (i = 0; s[i]; i++) {
if (!(p = strchr(tmpl, s[i])))
bail();
c = p - tmpl;
for (j = 25; j--; ) {
c += 58 * out[j];
out[j] = c % 256;
c /... | 1,097Bitcoin/address validation | 5c | 258lo |
package main
import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"golang.org/x/crypto/ripemd160"
) | 1,093Bitcoin/public point to address | 0go | 1wup5 |
(require racket/draw)
(define (draw-line dc p q)
(match* (p q) [((list x y) (list s t)) (send dc draw-line x y s t)]))
(define (draw-lines dc ps)
(void
(for/fold ([p0 (first ps)]) ([p (rest ps)])
(draw-line dc p0 p)
p)))
(define (int t p q)
(define ((int1 t) x0 x1) (+ (* (- 1 t) x0) (* t x1)))
(... | 1,091Bitmap/Bézier curves/Quadratic | 3python | 0ibsq |
(require racket/draw)
(define (draw-line dc p q)
(match* (p q) [((list x y) (list s t)) (send dc draw-line x y s t)]))
(define (draw-lines dc ps)
(void
(for/fold ([p0 (first ps)]) ([p (rest ps)])
(draw-line dc p0 p)
p)))
(define (int t p q)
(define ((int1 t) x0 x1) (+ (* (- 1 t) x0) (* t x1)))
(... | 1,091Bitmap/Bézier curves/Quadratic | 13r | ws7e5 |
function Bitmap:circle(x, y, r, c)
local dx, dy, err = r, 0, 1-r
while dx >= dy do
self:set(x+dx, y+dy, c)
self:set(x-dx, y+dy, c)
self:set(x+dx, y-dy, c)
self:set(x-dx, y-dy, c)
self:set(x+dy, y+dx, c)
self:set(x-dy, y+dx, c)
self:set(x+dy, y-dx, c)
self:set(x-dy, y-dx, c)
dy = ... | 1,092Bitmap/Midpoint circle algorithm | 1lua | 5r3u6 |
import Numeric (showIntAtBase)
import Data.List (unfoldr)
import Data.Binary (Word8)
import Crypto.Hash.SHA256 as S (hash)
import Crypto.Hash.RIPEMD160 as R (hash)
import Data.ByteString (unpack, pack)
publicPointToAddress :: Integer -> Integer -> String
publicPointToAddress x y =
let toBytes x = reverse $ unfoldr ... | 1,093Bitcoin/public point to address | 8haskell | t6wf7 |
(ns boxing-the-compass
(:use [clojure.string :only [capitalize]]))
(def headings
(for [i (range 0 (inc 32))]
(let [heading (* i 11.25)]
(case (mod i 3)
1 (+ heading 5.62)
2 (- heading 5.62)
heading))))
(defn angle2compass
[angle]
(let [dirs ["N" "NbE" "N-NE" "NEbN" "NE" "NE... | 1,096Box the compass | 6clojure | k1mhs |
class Pixmap
def histogram
histogram = Hash.new(0)
@height.times do |y|
@width.times do |x|
histogram[self[x,y].luminosity] += 1
end
end
histogram
end
def to_blackandwhite
hist = histogram
median = nil
sum = 0
hist.keys.sort.each do |lum|
sum += hi... | 1,089Bitmap/Histogram | 14ruby | t60f2 |
extern crate image;
use image::{DynamicImage, GenericImageView, ImageBuffer, Rgba}; | 1,089Bitmap/Histogram | 15rust | zy8to |
Define cubic(p1,p2,p3,segs) = Prgm
Local i,t,u,prev,pt
0 pt
For i,1,segs+1
(i-1.0)/segs t Decimal to avoid slow exact arithetic
(1-t) u
pt prev
u^2*p1 + 2*t*u*p2 + t^2*p3 pt
If i>1 Then
PxlLine floor(prev[1,1]), floor(prev[1,2]), floor(pt[1,1]), floor(pt[1,2])
EndIf
EndFor
... | 1,091Bitmap/Bézier curves/Quadratic | 14ruby | od18v |
null | 1,092Bitmap/Midpoint circle algorithm | 11kotlin | ugzvc |
package raster
const b3Seg = 30
func (b *Bitmap) Bzier3(x1, y1, x2, y2, x3, y3, x4, y4 int, p Pixel) {
var px, py [b3Seg + 1]int
fx1, fy1 := float64(x1), float64(y1)
fx2, fy2 := float64(x2), float64(y2)
fx3, fy3 := float64(x3), float64(y3)
fx4, fy4 := float64(x4), float64(y4)
for i := range px... | 1,095Bitmap/Bézier curves/Cubic | 0go | 0i7sk |
int day(int y, int m, int d) {
return 367 * y - 7 * (y + (m + 9) / 12) / 4 + 275 * m / 9 + d - 730530;
}
void cycle(int diff, int l, char *t) {
int p = round(100 * sin(2 * M_PI * diff / l));
printf(, t, p);
if (abs(p) < 15)
printf();
printf();
}
int main(int argc, char *argv[]) {
int d... | 1,098Biorhythms | 5c | ntji6 |
use Crypt::RIPEMD160;
use Digest::SHA qw(sha256);
use Encode::Base58::GMP;
sub public_point_to_address {
my $ec = join '', '04', @_;
my $octets = pack 'C*', map { hex } unpack('(a2)65', $ec);
my $hash = chr(0) . Crypt::RIPEMD160->hash(sha256 $octets);
my $checksum ... | 1,093Bitcoin/public point to address | 2perl | lunc5 |
object BitmapOps {
def histogram(bm:RgbBitmap)={
val hist=new Array[Int](255)
for(x <- 0 until bm.width; y <- 0 until bm.height; l=luminosity(bm.getPixel(x,y)))
hist(l)+=1
hist
}
def histogram_median(hist:Array[Int])={
var from=0
var to=hist.size-1
var left=hist(fr... | 1,089Bitmap/Histogram | 16scala | ycn63 |
function draw() {
var canvas = document.getElementById("container");
context = canvas.getContext("2d");
bezier3(20, 200, 700, 50, -300, 50, 380, 150); | 1,095Bitmap/Bézier curves/Cubic | 10javascript | 920ml |
import 'package:crypto/crypto.dart';
class Bitcoin {
final String ALPHABET =
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
List<int> bigIntToByteArray(BigInt data) {
String str;
bool neg = false;
if (data < BigInt.zero) {
str = (~data).toRadixString(16);
neg = true;
... | 1,097Bitcoin/address validation | 18dart | 69e34 |
use strict;
use warnings;
use Algorithm::Line::Bresenham 'circle';
my @points;
my @circle = circle((10) x 3);
for (@circle) { $points[$_->[0]][$_->[1]] = '
print join "\n", map { join '', map { $_ || ' ' } @$_ } @points | 1,092Bitmap/Midpoint circle algorithm | 2perl | 8nb0w |
null | 1,095Bitmap/Bézier curves/Cubic | 11kotlin | ifko4 |
import binascii
import functools
import hashlib
digits58 = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def b58(n):
return b58(n
def public_point_to_address(x, y):
c = b'\x04' + binascii.unhexlify(x) + binascii.unhexlify(y)
r = hashlib.new('ripemd160')
r.update(hashlib.sha256(c).dige... | 1,093Bitcoin/public point to address | 3python | 25dlz |
Bitmap.cubicbezier = function(self, x1, y1, x2, y2, x3, y3, x4, y4, nseg)
nseg = nseg or 10
local prevx, prevy, currx, curry
for i = 0, nseg do
local t = i / nseg
local a, b, c, d = (1-t)^3, 3*t*(1-t)^2, 3*t^2*(1-t), t^3
prevx, prevy = currx, curry
currx = math.floor(a * x1 + b * x2 + c * x3 + d *... | 1,095Bitmap/Bézier curves/Cubic | 1lua | ntbi8 |
typedef struct genome{
char base;
struct genome *next;
}genome;
typedef struct{
char mutation;
int position;
}genomeChange;
typedef struct{
int adenineCount,thymineCount,cytosineCount,guanineCount;
}baseCounts;
genome *strand;
baseCounts baseData;
int genomeLength = 100, lineLength = 50;
int num... | 1,099Bioinformatics/Sequence mutation | 5c | jbt70 |
function line {
x0=$1
y0=$2
x1=$3
y1=$4
if (( x0 > x1 ))
then
(( dx = x0 - x1 ))
(( sx = -1 ))
else
(( dx = x1 - x0 ))
(( sx = 1 ))
fi
if (( y0 > y1 ))
then
(( dy = y0 - y1 ))
(( sy = -1 ))
else
(( dy = y1 - y0 ))
(( sy = 1 ))
fi
if (( dx > dy ))
then
(... | 1,100Bitmap/Bresenham's line algorithm | 4bash | pe6bb |
package main
import (
"bytes"
"crypto/sha256"
"errors"
"os"
) | 1,097Bitcoin/address validation | 0go | q85xz |
require 'digest/sha2'
def convert g
i,e = '',[]
(0...g.length/2).each{|n| e[n] = g[n+=n]+g[n+1]; i+='H2'}
e.pack(i)
end
X = '50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352'
Y = '2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6'
n = '00'+Digest::RMD160.hexdigest(Digest::SHA256.dig... | 1,093Bitcoin/public point to address | 14ruby | ugtvz |
use ring::digest::{digest, SHA256};
use ripemd160::{Digest, Ripemd160};
use hex::FromHex;
static X: &str = "50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352";
static Y: &str = "2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6";
static ALPHABET: [char; 58] = [
'1', '2', '3', '4', '5... | 1,093Bitcoin/public point to address | 15rust | 5rzuq |
def circle(self, x0, y0, radius, colour=black):
f = 1 - radius
ddf_x = 1
ddf_y = -2 * radius
x = 0
y = radius
self.set(x0, y0 + radius, colour)
self.set(x0, y0 - radius, colour)
self.set(x0 + radius, y0, colour)
self.set(x0 - radius, y0, colour)
while x < y:
if f >= 0:
... | 1,092Bitmap/Midpoint circle algorithm | 3python | odp81 |
package main
import (
"fmt"
"log"
"math"
"time"
)
const layout = "2006-01-02" | 1,098Biorhythms | 0go | rhfgm |
import Control.Monad (when)
import Data.List (elemIndex)
import Data.Monoid ((<>))
import qualified Data.ByteString as BS
import Data.ByteString (ByteString)
import Crypto.Hash.SHA256 (hash)
decode58 :: String -> Maybe Integer
decode58 = ... | 1,097Bitcoin/address validation | 8haskell | mlxyf |
package raster
func (b *Bitmap) Flood(x, y int, repl Pixel) {
targ, _ := b.GetPx(x, y)
var ff func(x, y int)
ff = func(x, y int) {
p, ok := b.GetPx(x, y)
if ok && p.R == targ.R && p.G == targ.G && p.B == targ.B {
b.SetPx(x, y, repl)
ff(x-1, y)
ff(x+1, y)
... | 1,094Bitmap/Flood fill | 0go | so7qa |
package main
import (
"fmt"
"math/rand"
"sort"
"time"
)
const bases = "ACGT" | 1,099Bioinformatics/Sequence mutation | 0go | f3hd0 |
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public class BitcoinAddressValidator {
private static final String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
public static boolean validateBi... | 1,097Bitcoin/address validation | 9java | f3bdv |
import Data.Array.ST
import Data.STRef
import Control.Monad
import Control.Monad.ST
import Bitmap
pushST :: STStack s a -> a -> ST s ()
pushST s e = do
s2 <- readSTRef s
writeSTRef s (e: s2)
popST :: STStack s a -> ST s (Stack a)
popST s = do
s2 <- readSTRef s
writeSTRef s $ tail s2
return $ take... | 1,094Bitmap/Flood fill | 8haskell | 928mo |
package main
import (
"fmt"
"reflect"
"strconv"
)
func main() {
var n bool = true
fmt.Println(n) | 1,090Boolean values | 0go | 7klr2 |
<?
$image = imagecreate(200, 200);
imagecolorallocate($image, 255, 255, 255);
$color = imagecolorallocate($image, 255, 0, 0);
cubicbezier($image, $color, 160, 10, 10, 40, 30, 160, 150, 110);
imagepng($image);
function cubicbezier($img, $col, $x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $n = 20) {
$pts = array();
for($... | 1,095Bitmap/Bézier curves/Cubic | 12php | dzpn8 |
import Data.List (group, sort)
import Data.List.Split (chunksOf)
import System.Random (Random, randomR, random, newStdGen, randoms, getStdRandom)
import Text.Printf (PrintfArg(..), fmtChar, fmtPrecision, formatString, IsChar(..), printf)
data Mutation = Swap | Delete | Insert deriving (Show, Eq, Ord, Enum,... | 1,099Bioinformatics/Sequence mutation | 8haskell | 47i5s |
import java.security.MessageDigest
object Bitcoin {
private const val ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
private fun ByteArray.contentEquals(other: ByteArray): Boolean {
if (this.size != other.size) return false
return (0 until this.size).none { this[it] !=... | 1,097Bitcoin/address validation | 11kotlin | 8nr0q |
data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded) | 1,090Boolean values | 7groovy | ug6v9 |
data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded) | 1,090Boolean values | 8haskell | 8n10z |
cycles = {"Physical day ", "Emotional day", "Mental day "}
lengths = {23, 28, 33}
quadrants = {
{"up and rising", "peak"},
{"up but falling", "transition"},
{"down and falling", "valley"},
{"down but rising", "transition"},
}
function parse_date_string (birthDate)
local year, month, day = birthDate:match("(%d+)... | 1,098Biorhythms | 1lua | k16h2 |
typedef struct genome{
char* strand;
int length;
struct genome* next;
}genome;
genome* genomeData;
int totalLength = 0, Adenine = 0, Cytosine = 0, Guanine = 0, Thymine = 0;
int numDigits(int num){
int len = 1;
while(num>10){
num = num/10;
len++;
}
return len;
}
void buil... | 1,101Bioinformatics/base count | 5c | if4o2 |
void line(int x0, int y0, int x1, int y1) {
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
int err = (dx>dy ? dx : -dy)/2, e2;
for(;;){
setPixel(x0,y0);
if (x0==x1 && y0==y1) break;
e2 = err;
if (e2 >-dx) { err -= dy; x0 += sx; }
if (e2 < dy) { err += ... | 1,100Bitmap/Bresenham's line algorithm | 5c | axm11 |
import java.awt.Color;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.Deque;
import java.util.LinkedList;
public class FloodFill {
public void floodFill(BufferedImage image, Point node, Color targetColor, Color replacementColor) {
int width = image.getWidth();
int height = image... | 1,094Bitmap/Flood fill | 9java | t6ef9 |
Pixel = Struct.new(:x, :y)
class Pixmap
def draw_circle(pixel, radius, colour)
validate_pixel(pixel.x, pixel.y)
self[pixel.x, pixel.y + radius] = colour
self[pixel.x, pixel.y - radius] = colour
self[pixel.x + radius, pixel.y] = colour
self[pixel.x - radius, pixel.y] = colour
f = 1 - radius
... | 1,092Bitmap/Midpoint circle algorithm | 14ruby | ntait |
def cubicbezier(self, x0, y0, x1, y1, x2, y2, x3, y3, n=20):
pts = []
for i in range(n+1):
t = i / n
a = (1. - t)**3
b = 3. * t * (1. - t)**2
c = 3.0 * t**2 * (1.0 - t)
d = t**3
x = int(a * x0 + b * x1 + c * x2 + d * x3)
y = int(a * y0 + b * y1 + c * y2 +... | 1,095Bitmap/Bézier curves/Cubic | 3python | 7k6rm |
bezierCurve <- function(x, y, n=10)
{
outx <- NULL
outy <- NULL
i <- 1
for (t in seq(0, 1, length.out=n))
{
b <- bez(x, y, t)
outx[i] <- b$x
outy[i] <- b$y
i <- i+1
}
return (list(x=outx, y=outy))
}
bez <- function(x, y, t)
{
outx <- 0
outy <- 0
n <- length(x)-1
for (i in 0:n)
{
outx <- ... | 1,095Bitmap/Bézier curves/Cubic | 13r | 5rfuy |
use strict;
use warnings;
use DateTime;
use constant PI => 2 * atan2(1, 0);
my %cycles = ( 'Physical' => 23, 'Emotional' => 28, 'Mental' => 33 );
my @Q = ( ['up and rising', 'peak'],
['up but falling', 'transition'],
['down and falling', 'valley'],
['down but rising', 'transition']... | 1,098Biorhythms | 2perl | zyptb |
import java.util.Arrays;
import java.util.Random;
public class SequenceMutation {
public static void main(String[] args) {
SequenceMutation sm = new SequenceMutation();
sm.setWeight(OP_CHANGE, 3);
String sequence = sm.generateSequence(250);
System.out.println("Initial sequence:");
... | 1,099Bioinformatics/Sequence mutation | 9java | cvx9h |
null | 1,094Bitmap/Flood fill | 11kotlin | odk8z |
object BitmapOps {
def midpoint(bm:RgbBitmap, x0:Int, y0:Int, radius:Int, c:Color)={
var f=1-radius
var ddF_x=1
var ddF_y= -2*radius
var x=0
var y=radius
bm.setPixel(x0, y0+radius, c)
bm.setPixel(x0, y0-radius, c)
bm.setPixel(x0+radius, y0, c)
bm.setPixel(x0-rad... | 1,092Bitmap/Midpoint circle algorithm | 16scala | zyqtr |
null | 1,099Bioinformatics/Sequence mutation | 10javascript | 5rour |
my @b58 = qw{
1 2 3 4 5 6 7 8 9
A B C D E F G H J K L M N P Q R S T U V W X Y Z
a b c d e f g h i j k m n o p q r s t u v w x y z
};
my %b58 = map { $b58[$_] => $_ } 0 .. 57;
sub unbase58 {
use integer;
my @out;
my $azeroes = length($1) if $_[0] =~ /^(1*)/;
for my $c ( map { $b58{$_... | 1,097Bitcoin/address validation | 2perl | 47d5d |
package main
import "fmt" | 1,096Box the compass | 0go | ifhog |
class Pixmap
def draw_bezier_curve(points, colour)
points = points.sort_by {|p| [p.x, p.y]}
xmin = points[0].x
xmax = points[-1].x
increment = 2
prev = points[0]
((xmin + increment) .. xmax).step(increment) do |x|
t = 1.0 * (x - xmin) / (xmax - xmin)
p = Pixel[x, bezier(t, poi... | 1,095Bitmap/Bézier curves/Cubic | 14ruby | hpmjx |
from datetime import date, timedelta
from math import floor, sin, pi
def biorhythms(birthdate,targetdate):
print(+birthdate++targetdate)
birthdate = date.fromisoformat(birthdate)
targetdate = date.fromisoformat(targetdate)
days = (targetdate - birthdate).days
print(+s... | 1,098Biorhythms | 3python | 3m1zc |
(defn draw-line
"Draw a line from x1,y1 to x2,y2 using Bresenham's, to a java BufferedImage in the colour of pixel."
[buffer x1 y1 x2 y2 pixel]
(let [dist-x (Math/abs (- x1 x2))
dist-y (Math/abs (- y1 y2))
steep (> dist-y dist-x)]
(let [[x1 y1 x2 y2] (if steep [y1 x1 y2 x2] [x1 y1 x2 y2])]
(let [... | 1,100Bitmap/Bresenham's line algorithm | 6clojure | sovqr |
math.randomseed(os.time())
bases = {"A","C","T","G"}
function randbase() return bases[math.random(#bases)] end
function mutate(seq)
local i,h = math.random(#seq), "%-6s%3s at%3d"
local old,new = seq:sub(i,i), randbase()
local ops = {
function(s) h=h:format("Swap", old..">"..new, i) return s:sub(1,i-1)..new..... | 1,099Bioinformatics/Sequence mutation | 1lua | 69139 |
$ magick unfilledcirc.png -depth 8 unfilledcirc.ppm | 1,094Bitmap/Flood fill | 1lua | ifbot |
$ jq type
true
"boolean"
false
"boolean" | 1,090Boolean values | 9java | eq7a5 |
$ jq type
true
"boolean"
false
"boolean" | 1,090Boolean values | 10javascript | 0ipsz |
def asCompassPoint(angle) {
def cardinalDirections = ["north", "east", "south", "west"]
int index = Math.floor(angle / 11.25 + 0.5)
int cardinalIndex = (index / 8)
def c1 = cardinalDirections[cardinalIndex % 4]
def c2 = cardinalDirections[(cardinalIndex + 1) % 4]
def c3 = (cardinalIndex == 0 |... | 1,096Box the compass | 7groovy | q84xp |
typedef unsigned char color_component;
typedef color_component pixel[3];
typedef struct {
unsigned int width;
unsigned int height;
pixel * buf;
} image_t;
typedef image_t * image;
image alloc_img(unsigned int width, unsigned int height);
void free_img(image);
void fill_img(image img,
color_componen... | 1,102Bitmap | 5c | v4x2o |
bioR <- function(bDay, targetDay) {
bDay <- as.Date(bDay)
targetDay <- as.Date(targetDay)
n <- as.numeric(targetDay - bDay)
cycles <- c(23, 28, 33)
mods <- n%% cycles
bioR <- c(sin(2 * pi * mods / cycles))
loc <- mods / cycles
current <- ifelse(bioR > 0, ': Up', ': Down')
current <-... | 1,098Biorhythms | 13r | dzhnt |
function validate($address){
$decoded = decodeBase58($address);
$d1 = hash(, substr($decoded,0,21), true);
$d2 = hash(, $d1, true);
if(substr_compare($decoded, $d2, 21, 4)){
throw new \Exception();
}
return true;
}
function decodeBase58($input) {
... | 1,097Bitcoin/address validation | 12php | ifjov |
{if true then YES else NO}
-> YES
{if false then YES else NO}
-> NO | 1,090Boolean values | 11kotlin | k1uh3 |
import Data.Char (toUpper)
import Data.Maybe (fromMaybe)
import Text.Printf (PrintfType, printf)
dirs :: [String]
dirs =
[ "N"
, "NbE"
, "N-NE"
, "NEbN"
, "NE"
, "NEbE"
, "E-NE"
, "EbN"
, "E"
, "EbS"
, "E-SE"
, "SEbE"
, "SE"
, "SEbS"
, "S-SE"
, "SbE"
, "S"
, "SbW"
, "S-SW"
, "... | 1,096Box the compass | 8haskell | v4i2k |
void bitwise(int a, int b)
{
printf(, a & b);
printf(, a | b);
printf(, a ^ b);
printf(, ~a);
printf(, a << b);
printf(, a >> b);
unsigned int c = a;
printf(, c >> b);
return 0;
} | 1,103Bitwise operations | 5c | 92pm1 |
require 'date'
CYCLES = {physical: 23, emotional: 28, mental: 33}
def biorhythms(date_of_birth, target_date = Date.today.to_s)
days_alive = Date.parse(target_date) - Date.parse(date_of_birth)
CYCLES.each do |name, num_days|
cycle_day = days_alive % num_days
state = case cycle_day
when 0, num_days/2 ... | 1,098Biorhythms | 14ruby | yce6n |
use strict;
use warnings;
use feature 'say';
my @bases = <A C G T>;
my $dna;
$dna .= $bases[int rand 4] for 1..200;
my %cnt;
$cnt{$_}++ for split //, $dna;
sub pretty {
my($string) = @_;
my $chunk = 10;
my $wrap = 5 * ($chunk+1);
($string =~ s/(.{$chunk})/$1 /gr) =~ s/(.{$wrap})/$1\n/gr;
}
sub mut... | 1,099Bioinformatics/Sequence mutation | 2perl | peyb0 |
size_t upper_bound(const int* array, size_t n, int value) {
size_t start = 0;
while (n > 0) {
size_t step = n / 2;
size_t index = start + step;
if (value >= array[index]) {
start = index + 1;
n -= step + 1;
} else {
n = step;
}
}
... | 1,104Bin given limits | 5c | mlkys |
package main
import (
"fmt"
"sort"
)
func main() {
dna := "" +
"CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATG" +
"CTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTG" +
"AGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGAT" +
"GGGACGTTTCGTCGACAAAGTCTTGTTTCGAGAGTAACGGCTACC... | 1,101Bioinformatics/base count | 0go | gjo4n |
from hashlib import sha256
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def decode_base58(bc, length):
n = 0
for char in bc:
n = n * 58 + digits58.index(char)
return n.to_bytes(length, 'big')
def check_bc(bc):
try:
bcbytes = decode_base58(bc, 25)
retu... | 1,097Bitcoin/address validation | 3python | gjf4h |
use strict;
use Image::Imlib2;
my $img = Image::Imlib2->load("Unfilledcirc.jpg");
$img->set_color(0, 255, 0, 255);
$img->fill(100,100);
$img->save("filledcirc.jpg");
exit 0; | 1,094Bitmap/Flood fill | 2perl | gj34e |
(import '[java.awt Color Graphics Image]
'[java.awt.image BufferedImage])
(defn blank-bitmap [width height]
(BufferedImage. width height BufferedImage/TYPE_3BYTE_BGR))
(defn fill [image color]
(doto (.getGraphics image)
(.setColor color)
(.fillRect 0 0 (.getWidth image) (.getHeight image))))
(defn set-p... | 1,102Bitmap | 6clojure | rhog2 |
import Data.List (group, sort)
import Data.List.Split (chunksOf)
import Text.Printf (printf, IsChar(..), PrintfArg(..), fmtChar, fmtPrecision, formatString)
data DNABase = A | C | G | T deriving (Show, Read, Eq, Ord)
type DNASequence = [DNABase]
instance IsChar DNABase where
toChar = head . show
fromCha... | 1,101Bioinformatics/base count | 8haskell | so2qk |
(bit-and x y)
(bit-or x y)
(bit-xor x y)
(bit-not x)
(bit-shift-left x n)
(bit-shift-right x n) | 1,103Bitwise operations | 6clojure | ugxvi |
typedef struct str_t {
size_t len, alloc;
unsigned char *s;
} bstr_t, *bstr;
bstr str_new(size_t len)
{
bstr s = malloc(sizeof(bstr_t));
if (len < 8) len = 8;
s->alloc = len;
s->s = malloc(len);
s->len = 0;
return s;
}
void str_extend(bstr s)
{
size_t ns = s->alloc * 2;
if (ns - s->alloc > 1024) ns = s->al... | 1,105Binary strings | 5c | 47x5t |
import java.util.HashMap;
import java.util.Map;
public class orderedSequence {
public static void main(String[] args) {
Sequence gene = new Sequence("CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATGCTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTGAGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGATGGGACGT... | 1,101Bioinformatics/base count | 9java | 1w6p2 |
import random
from collections import Counter
def basecount(dna):
return sorted(Counter(dna).items())
def seq_split(dna, n=50):
return [dna[i: i+n] for i in range(0, len(dna), n)]
def seq_pp(dna, n=50):
for i, part in enumerate(seq_split(dna, n)):
print(f)
print()
tot = 0
for base, co... | 1,099Bioinformatics/Sequence mutation | 3python | 1wmpc |
require 'digest/sha2'
def convert g
i,e = '',[]
(0...g.length/2).each{|n| e[n] = g[n+=n]+g[n+1]; i+='H2'}
e.pack(i)
end
N = [0,1,2,3,4,5,6,7,8,nil,nil,nil,nil,nil,nil,nil,9,10,11,12,13,14,15,16,nil,17,18,19,20,21,nil,22,23,24,25,26,27,28,29,30,31,32,nil,nil,nil,nil,nil,nil,33,34,35,36,37,38,39,40,41,42,43,nil,44,... | 1,097Bitcoin/address validation | 14ruby | 7kzri |
const rowLength = 50;
const bases = ['A', 'C', 'G', 'T']; | 1,101Bioinformatics/base count | 10javascript | q8lx8 |
extern crate crypto;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
const DIGITS58: [char; 58] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'... | 1,097Bitcoin/address validation | 15rust | jb372 |
import java.security.MessageDigest
import java.util.Arrays.copyOfRange
import scala.annotation.tailrec
import scala.math.BigInt
object BitcoinAddressValidator extends App {
private def bitcoinTestHarness(address: String, expected: Boolean): Unit =
assert(validateBitcoinAddress(=1J26TeMg6uK9GkoCKkHNeDaKwtFWdsFn... | 1,097Bitcoin/address validation | 16scala | bamk6 |
import Image
def FloodFill( fileName, initNode, targetColor, replaceColor ):
img = Image.open( fileName )
pix = img.load()
xsize, ysize = img.size
Q = []
if pix[ initNode[0], initNode[1] ] != targetColor:
return img
Q.append( initNode )
while Q != []:
node = Q.pop(0)
if pix[ node[... | 1,094Bitmap/Flood fill | 3python | rh6gq |
if 0 then print "0" end | 1,090Boolean values | 1lua | ba5ka |
public class BoxingTheCompass{
private static String[] points = new String[32];
public static void main(String[] args){
buildPoints();
double heading = 0;
for(int i = 0; i<= 32;i++){
heading = i * 11.25;
switch(i % 3){
case 1:
... | 1,096Box the compass | 9java | ycx6g |
library(png)
img <- readPNG("Unfilledcirc.png")
M <- img[ , , 1]
M <- ifelse(M < 0.5, 0, 1)
image(M, col = c(1, 0))
floodfill <- function(row, col, tcol, rcol) {
if (tcol == rcol) return()
if (M[row, col]!= tcol) return()
M[row, col] <<- rcol
floodfill(row - 1, col , tcol, rcol)
floodfill(row + 1, col ... | 1,094Bitmap/Flood fill | 13r | ugfvx |
function createRow(i, point, heading) {
var tr = document.createElement('tr'),
td;
td = document.createElement('td');
td.appendChild(document.createTextNode(i));
tr.appendChild(td);
td = document.createElement('td');
point = point.substr(0, 1).toUpperCase() + point.substr(1);
td.ap... | 1,096Box the compass | 10javascript | 25olr |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.