code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
null
606Magic squares of odd order
2perl
drbnw
package main import ( "fmt" "gonum.org/v1/gonum/mat" ) func main() { m := mat.NewDense(2, 3, []float64{ 1, 2, 3, 4, 5, 6, }) fmt.Println(mat.Formatted(m)) fmt.Println() fmt.Println(mat.Formatted(m.T())) }
605Matrix transposition
0go
ngbi1
package main import ( "fmt" "gonum.org/v1/gonum/mat" ) func main() { a := mat.NewDense(2, 4, []float64{ 1, 2, 3, 4, 5, 6, 7, 8, }) b := mat.NewDense(4, 3, []float64{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, }) var m mat.Dense m.Mul(a, b) ...
604Matrix multiplication
0go
bzlkh
import sys sys.setrecursionlimit(1025) def a(in_k, x1, x2, x3, x4, x5): k = [in_k] def b(): k[0] -= 1 return a(k[0], b, x1, x2, x3, x4) return x4() + x5() if k[0] <= 0 else b() x = lambda i: lambda: i print(a(10, x(1), x(-1), x(-1), x(1), x(0)))
599Man or boy test
3python
usyvd
def matrix = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ] matrix.each { println it } println() def transpose = matrix.transpose() transpose.each { println it }
605Matrix transposition
7groovy
s2rq1
>>> def maprange( a, b, s): (a1, a2), (b1, b2) = a, b return b1 + ((s - a1) * (b2 - b1) / (a2 - a1)) >>> for s in range(11): print(% (s, maprange( (0, 10), (-1, 0), s))) 0 maps to -1 1 maps to -0.9 2 maps to -0.8 3 maps to -0.7 4 maps to -0.6 5 maps to -0.5 6 maps to -0.4 7 maps to -0.3 8 maps to -0.2 ...
602Map range
3python
jdc7p
def assertConformable = { a, b -> assert a instanceof List assert b instanceof List assert a.every { it instanceof List && it.size() == b.size() } assert b.every { it instanceof List && it.size() == b[0].size() } } def matmulWOIL = { a, b -> assertConformable(a, b) def bt = b.transpose() a...
604Matrix multiplication
7groovy
ri6gh
n <- function(x) function()x A <- function(k, x1, x2, x3, x4, x5) { B <- function() A(k <<- k-1, B, x1, x2, x3, x4) if (k <= 0) x4() + x5() else B() } A(10, n(1), n(-1), n(-1), n(1), n(0))
599Man or boy test
13r
cet95
*Main> transpose [[1,2],[3,4],[5,6]] [[1,3,5],[2,4,6]]
605Matrix transposition
8haskell
usdv2
tRange <- function(aRange, bRange, s) { stopifnot(length(aRange) == 2, length(bRange) == 2, is.numeric(aRange), is.numeric(bRange), is.numeric(s), s >= aRange[1], s <= aRange[2]) bRange[1] + ((s - aRange[1]) * (bRange[2] - bRange[1])) / (aRange[2] - aRange[1]) } data.frame(s = 0:10, t = s...
602Map range
13r
4865y
import Data.List mmult :: Num a => [[a]] -> [[a]] -> [[a]] mmult a b = [ [ sum $ zipWith (*) ar bc | bc <- (transpose b) ] | ar <- a ] test = [[1, 2], [3, 4]] `mmult` [[-3, -8, 3], [-2, 1, 4]]
604Matrix multiplication
8haskell
dr1n4
use Digest::MD5 qw(md5_hex); print md5_hex("The quick brown fox jumped over the lazy dog's back"), "\n";
590MD5
2perl
gij4e
>>> def magic(n): for row in range(1, n + 1): print(' '.join('%*i'% (len(str(n**2)), cell) for cell in (n * ((row + col - 1 + n ((row + 2 * col - 2)% n) + 1 for col in range(1, n + 1)))) print('\nAll sum to magic number%i'% ((n * n + ...
606Magic squares of odd order
3python
f7pde
def a(k, x1, x2, x3, x4, x5) b = lambda { k -= 1; a(k, b, x1, x2, x3, x4) } k <= 0? x4[] + x5[]: b[] end puts a(10, lambda {1}, lambda {-1}, lambda {-1}, lambda {1}, lambda {0})
599Man or boy test
14ruby
4895p
> magic(5) [,1] [,2] [,3] [,4] [,5] [1,] 17 24 1 8 15 [2,] 23 5 7 14 16 [3,] 4 6 13 20 22 [4,] 10 12 19 21 3 [5,] 11 18 25 2 9
606Magic squares of odd order
13r
o5j84
use std::cell::Cell; trait Arg { fn run(&self) -> i32; } impl Arg for i32 { fn run(&self) -> i32 { *self } } struct B<'a> { k: &'a Cell<i32>, x1: &'a Arg, x2: &'a Arg, x3: &'a Arg, x4: &'a Arg, } impl<'a> Arg for B<'a> { fn run(&self) -> i32 { self.k.set(self.k.get() - 1); ...
599Man or boy test
15rust
goc4o
def A(in_k: Int, x1: =>Int, x2: =>Int, x3: =>Int, x4: =>Int, x5: =>Int): Int = { var k = in_k def B: Int = { k = k-1 A(k, B, x1, x2, x3, x4) } if (k<=0) x4+x5 else B } println(A(10, 1, -1, -1, 1, 0))
599Man or boy test
16scala
jdv7i
def map_range(a, b, s) af, al, bf, bl = a.first, a.last, b.first, b.last bf + (s - af)*(bl - bf).quo(al - af) end (0..10).each{|s| puts % [s, map_range(0..10, -1..0, s)]}
602Map range
14ruby
kt2hg
$string = ; echo md5( $string );
590MD5
12php
nrtig
from random import shuffle, randrange def make_maze(w = 16, h = 8): vis = [[0] * w + [1] for _ in range(h)] + [[1] * (w + 1)] ver = [[] * w + ['|'] for _ in range(h)] + [[]] hor = [[] * w + ['+'] for _ in range(h + 1)] def walk(x, y): vis[y][x] = 1 d = [(x - 1, y), (x, y + 1), (x + 1,...
597Maze generation
3python
zhitt
use std::ops::{Add, Sub, Mul, Div}; fn map_range<T: Copy>(from_range: (T, T), to_range: (T, T), s: T) -> T where T: Add<T, Output=T> + Sub<T, Output=T> + Mul<T, Output=T> + Div<T, Output=T> { to_range.0 + (s - from_range.0) * (to_range.1 - to_range.0) / (from_range.1 - f...
602Map range
15rust
bzvkx
def mapRange(a1:Double, a2:Double, b1:Double, b2:Double, x:Double):Double=b1+(x-a1)*(b2-b1)/(a2-a1) for(i <- 0 to 10) println("%2d in [0, 10] maps to%5.2f in [-1, 0]".format(i, mapRange(0,10, -1,0, i)))
602Map range
16scala
ay41n
def odd_magic_square(n) raise ArgumentError if n.even? || n <= 0 n.times.map{|i| n.times.map{|j| n*((i+j+1+n/2)%n) + ((i+2*j-5)%n) + 1} } end [3, 5, 9].each do |n| puts fmt = * n odd_magic_square(n).each{|row| puts fmt % row} end
606Magic squares of odd order
14ruby
zhatw
import Foundation func mapRanges(_ r1: ClosedRange<Double>, _ r2: ClosedRange<Double>, to: Double) -> Double { let num = (to - r1.lowerBound) * (r2.upperBound - r2.lowerBound) let denom = r1.upperBound - r1.lowerBound return r2.lowerBound + num / denom } for i in 0...10 { print(String(format: "%2d maps to%5....
602Map range
17swift
hflj0
fn main() { let n = 9; let mut square = vec![vec![0; n]; n]; for (i, row) in square.iter_mut().enumerate() { for (j, e) in row.iter_mut().enumerate() { *e = n * (((i + 1) + (j + 1) - 1 + (n >> 1))% n) + (((i + 1) + (2 * (j + 1)) - 2)% n) + 1; print!("{:3} ", e); } ...
606Magic squares of odd order
15rust
3kez8
def magicSquare( n:Int ) : Option[Array[Array[Int]]] = { require(n % 2 != 0, "n must be an odd number") val a = Array.ofDim[Int](n,n)
606Magic squares of odd order
16scala
m1qyc
public static double[][] mult(double a[][], double b[][]){
604Matrix multiplication
9java
s27q0
func A(_ k: Int, _ x1: @escaping () -> Int, _ x2: @escaping () -> Int, _ x3: @escaping () -> Int, _ x4: @escaping () -> Int, _ x5: @escaping () -> Int) -> Int { var k1 = k func B() -> In...
599Man or boy test
17swift
50mu8
null
604Matrix multiplication
10javascript
ngpiy
import java.util.Arrays; public class Transpose{ public static void main(String[] args){ double[][] m = {{1, 1, 1, 1}, {2, 4, 8, 16}, {3, 9, 27, 81}, {4, 16, 64, 256}, {5, 25...
605Matrix transposition
9java
m1sym
>>> import hashlib >>> >>> tests = ( (b, 'd41d8cd98f00b204e9800998ecf8427e'), (b, '0cc175b9c0f1b6a831c399e269772661'), (b, '900150983cd24fb0d6963f7d28e17f72'), (b, 'f96b697d7cb7938d525a2f31aaf161d0'), (b, 'c3fcd3d76192e4007dfb496cca67e13b'), (b, 'd174ab98d277d9f5a5611c2c9f419d9f'), (b, '57edf4a22be3c955a...
590MD5
3python
rnhgq
extension String: Error {} struct Point: CustomStringConvertible { var x: Int var y: Int init(_ _x: Int, _ _y: Int) { self.x = _x self.y = _y } var description: String { return "(\(x), \(y))\n" } } extension Point: Equatable,Comparable { static func == (l...
606Magic squares of odd order
17swift
tj1fl
function Matrix(ary) { this.mtx = ary this.height = ary.length; this.width = ary[0].length; } Matrix.prototype.toString = function() { var s = [] for (var i = 0; i < this.mtx.length; i++) s.push( this.mtx[i].join(",") ); return s.join("\n"); }
605Matrix transposition
10javascript
vqn25
library(digest) hexdigest <- digest("The quick brown fox jumped over the lazy dog's back", algo="md5", serialize=FALSE)
590MD5
13r
u0gvx
class Maze DIRECTIONS = [ [1, 0], [-1, 0], [0, 1], [0, -1] ] def initialize(width, height) @width = width @height = height @start_x = rand(width) @start_y = 0 @end_x = rand(width) @end_y = height - 1 @vertical_walls = Array.new(width) { Array.new(height, tr...
597Maze generation
14ruby
6bd3t
use rand::{thread_rng, Rng, rngs::ThreadRng}; const WIDTH: usize = 16; const HEIGHT: usize = 16; #[derive(Clone, Copy)] struct Cell { col: usize, row: usize, } impl Cell { fn from(col: usize, row: usize) -> Cell { Cell {col, row} } } struct Maze { cells: [[bool; HEIGHT]; WIDTH],
597Maze generation
15rust
ypf68
import scala.util.Random object MazeTypes { case class Direction(val dx: Int, val dy: Int) case class Loc(val x: Int, val y: Int) { def +(that: Direction): Loc = Loc(x + that.dx, y + that.dy) } case class Door(val from: Loc, to: Loc) val North = Direction(0,-1) val South = Direction(0,1) val West ...
597Maze generation
16scala
ce393
package main import "fmt" import "math/cmplx" func mandelbrot(a complex128) (z complex128) { for i := 0; i < 50; i++ { z = z*z + a } return } func main() { for y := 1.0; y >= -1.0; y -= 0.05 { for x := -2.0; x <= 0.5; x += 0.0315 { if cmplx.Abs(mandelbrot(complex(x, y))) <...
607Mandelbrot set
0go
vqo2m
null
604Matrix multiplication
11kotlin
ayu13
import Foundation extension Array { mutating func shuffle() { guard count > 1 else { return } for i in 0..<self.count - 1 { let j = Int(arc4random_uniform(UInt32(count - i))) + i guard i!= j else { continue } swap(&self[i], &self[j]) } } } enum Dire...
597Maze generation
17swift
3knz2
import Data.Bool import Data.Complex (Complex((:+)), magnitude) mandelbrot :: RealFloat a => Complex a -> Complex a mandelbrot a = iterate ((a +) . (^ 2)) 0 !! 50 main :: IO () main = mapM_ putStrLn [ [ bool ' ' '*' (2 > magnitude (mandelbrot (x:+ y))) | x <- [-2,-1.9685 .. 0.5] ] | y <- [1,0....
607Mandelbrot set
8haskell
em2ai
null
605Matrix transposition
11kotlin
tjaf0
require 'digest' Digest::MD5.hexdigest()
590MD5
14ruby
jfb7x
[dependencies] rust-crypto = "0.2"
590MD5
15rust
htpj2
function Transpose( m ) local res = {} for i = 1, #m[1] do res[i] = {} for j = 1, #m do res[i][j] = m[j][i] end end return res end
605Matrix transposition
1lua
zhety
function MatMul( m1, m2 ) if #m1[1] ~= #m2 then
604Matrix multiplication
1lua
em5ac
object RosettaMD5 extends App { def MD5(s: String): String = {
590MD5
16scala
p6ebj
import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.JFrame; public class Mandelbrot extends JFrame { private final int MAX_ITER = 570; private final double ZOOM = 150; private BufferedImage I; private double zx, zy, cX, cY, tmp; public Mandelbrot() { super("M...
607Mandelbrot set
9java
hf6jm
function mandelIter(cx, cy, maxIter) { var x = 0.0; var y = 0.0; var xx = 0; var yy = 0; var xy = 0; var i = maxIter; while (i-- && xx + yy <= 4) { xy = x * y; xx = x * x; yy = y * y; x = xx - yy + cx; y = xy + xy + cy; } return maxIter - i; } function mandelbrot(canvas, xmin, xm...
607Mandelbrot set
10javascript
ayl10
SELECT MD5('The quick brown fox jumped over the lazy dog\'s back')
590MD5
19sql
e9qau
null
607Mandelbrot set
11kotlin
48d57
use Math::Matrix; $m = Math::Matrix->new( [1, 1, 1, 1], [2, 4, 8, 16], [3, 9, 27, 81], [4, 16, 64, 256], [5, 25, 125, 625], ); $m->transpose->print;
605Matrix transposition
2perl
kt9hc
function transpose($m) { if (count($m) == 0) return array(); else if (count($m) == 1) return array_chunk($m[0], 1); array_unshift($m, NULL); return call_user_func_array('array_map', $m); }
605Matrix transposition
12php
3kwzq
local maxIterations = 250 local minX, maxX, minY, maxY = -2.5, 2.5, -2.5, 2.5 local miX, mxX, miY, mxY function remap( x, t1, t2, s1, s2 ) local f = ( x - t1 ) / ( t2 - t1 ) local g = f * ( s2 - s1 ) + s1 return g; end function drawMandelbrot() local pts, a, as, za, b, bs, zb, cnt, clr = {} for j = ...
607Mandelbrot set
1lua
gof4j
sub mmult { our @a; local *a = shift; our @b; local *b = shift; my @p = []; my $rows = @a; my $cols = @{ $b[0] }; my $n = @b - 1; for (my $r = 0 ; $r < $rows ; ++$r) { for (my $c = 0 ; $c < $cols ; ++$c) { $p[$r][$c] += $a[$r][$_] * $b[$_][$c] foreach 0 .. $n; ...
604Matrix multiplication
2perl
9a8mn
a=((1, 1, 1, 1), (2, 4, 8, 16), (3, 9, 27, 81), (4, 16, 64, 256)) b=(( 4 , -3 , 4/3., -1/4. ), (-13/3., 19/4., -7/3., 11/24.), ( 3/2., -2. , 7/6., -1/4. ), ( -1/6., 1/4., -1/6., 1/24.)) def MatrixMul( mtx_a, mtx_b): tpos_b = zip( *mtx_b) rtn = [[ sum( ea...
604Matrix multiplication
3python
ceo9q
m=((1, 1, 1, 1), (2, 4, 8, 16), (3, 9, 27, 81), (4, 16, 64, 256), (5, 25,125, 625)) print(zip(*m))
605Matrix transposition
3python
bzckr
a%*% b
604Matrix multiplication
13r
6bq3e
b <- 1:5 m <- matrix(c(b, b^2, b^3, b^4), 5, 4) print(m) tm <- t(m) print(tm)
605Matrix transposition
13r
7n6ry
struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *mem = (struct MemoryStruct *)userp; mem->memory = realloc(mem->memory, mem->size + realsize + 1); memcpy(&(m...
608MAC Vendor Lookup
5c
o5r80
require 'matrix' Matrix[[1, 2], [3, 4]] * Matrix[[-3, -8, 3], [-2, 1, 4]]
604Matrix multiplication
14ruby
2xnlw
m=[[1, 1, 1, 1], [2, 4, 8, 16], [3, 9, 27, 81], [4, 16, 64, 256], [5, 25,125, 625]] puts m.transpose
605Matrix transposition
14ruby
162pw
struct Matrix { dat: [[f32; 3]; 3] } impl Matrix { pub fn mult_m(a: Matrix, b: Matrix) -> Matrix { let mut out = Matrix { dat: [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.] ] }; for i in 0..3{ for j in 0..3 {...
604Matrix multiplication
15rust
vqd2t
use Math::Complex; sub mandelbrot { my ($z, $c) = @_[0,0]; for (1 .. 20) { $z = $z * $z + $c; return $_ if abs $z > 2; } } for (my $y = 1; $y >= -1; $y -= 0.05) { for (my $x = -2; $x <= 0.5; $x += 0.0315) {print mandelbrot($x + $y * i) ? ' ' : ' print "\n" }
607Mandelbrot set
2perl
i4jo3
struct Matrix { dat: [[i32; 3]; 3] } impl Matrix { pub fn transpose_m(a: Matrix) -> Matrix { let mut out = Matrix { dat: [[0, 0, 0], [0, 0, 0], [0, 0, 0] ] }; for i in 0..3{ for j in 0..3{ ...
605Matrix transposition
15rust
ayv14
def mult[A](a: Array[Array[A]], b: Array[Array[A]])(implicit n: Numeric[A]) = { import n._ for (row <- a) yield for(col <- b.transpose) yield row zip col map Function.tupled(_*_) reduceLeft (_+_) }
604Matrix multiplication
16scala
48z50
scala> Array.tabulate(4)(i => Array.tabulate(4)(j => i*4 + j)) res12: Array[Array[Int]] = Array(Array(0, 1, 2, 3), Array(4, 5, 6, 7), Array(8, 9, 10, 11), Array(12, 13, 14, 15)) scala> res12.transpose res13: Array[Array[Int]] = Array(Array(0, 4, 8, 12), Array(1, 5, 9, 13), Array(2, 6, 10, 14), Array(3, 7, 11, 15)) sc...
605Matrix transposition
16scala
xc4wg
package main import ( "net/http" "fmt" "io/ioutil" ) func macLookUp(mac string) (res string){ resp, _ := http.Get("http:
608MAC Vendor Lookup
0go
48n52
#!/usr/bin/env stack import Control.Exception (try) import Control.Monad (forM_) import qualified Data.ByteString.Lazy.Char8 as L8 (ByteString, unpack) import Network.HTTP.Client (Manager, parseRequest, httpLbs, responseStatus, responseBody, newManager, defaultManagerSettings, Response, HttpException) import N...
608MAC Vendor Lookup
8haskell
qlux9
$min_x=-2; $max_x=1; $min_y=-1; $max_y=1; $dim_x=400; $dim_y=300; $im = @imagecreate($dim_x, $dim_y) or die(); header(); $black_color = imagecolorallocate($im, 0, 0, 0); $white_color = imagecolorallocate($im, 255, 255, 255); for($y=0;$y<=$dim_y;$y++) { for($x=0;$x<=$dim_x;$x++) { $c1=$min_x+($max_x-$min_x)/$...
607Mandelbrot set
12php
ritge
package com.jamesdonnell.MACVendor; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Lookup { private static final String baseURL = "http:
608MAC Vendor Lookup
9java
p3mb3
var mac = "88:53:2E:67:07:BE"; function findmac(){ window.open("http:
608MAC Vendor Lookup
10javascript
xcvw9
null
608MAC Vendor Lookup
11kotlin
7ntr4
int test (int a, int b) { char code[] = {0x8B, 0x44, 0x24, 0x4, 0x3, 0x44, 0x24, 0x8, 0xC3}; void *buf; int c; buf = mmap (0,sizeof(code),PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON,-1,0); memcpy (buf, code, sizeof(code)); c = ((int (*) (int, int))buf)(a, b); munmap (buf...
609Machine code
5c
16mpj
null
608MAC Vendor Lookup
1lua
jdz71
@inlinable public func matrixTranspose<T>(_ matrix: [[T]]) -> [[T]] { guard!matrix.isEmpty else { return [] } var ret = Array(repeating: [T](), count: matrix[0].count) for row in matrix { for j in 0..<row.count { ret[j].append(row[j]) } } return ret } @inlinable public func printMatrix...
605Matrix transposition
17swift
p3lbl
use 5.018_002; use warnings; use LWP; our $VERSION = 1.000_000; my $ua = LWP::UserAgent->new; my @macs = ( 'FC-A1-3EFC:FB:FB:01:FA:21', '00,0d,4b', 'Rhubarb', '00-14-22-01-23-45', '10:dd:b1', 'D4:F4:6F:C9:EF:8D', 'FC-A1-3E', '88:53:2E:67:07:BE', ...
608MAC Vendor Lookup
2perl
f7kd7
CREATE TABLE a (x INTEGER, y INTEGER, e REAL); CREATE TABLE b (x INTEGER, y INTEGER, e REAL); -- test data -- A is a 2x2 matrix INSERT INTO a VALUES(0,0,1); INSERT INTO a VALUES(1,0,2); INSERT INTO a VALUES(0,1,3); INSERT INTO a VALUES(1,1,4); -- B is a 2x3 matrix INSERT INTO b VALUES(0,0,-3); INSERT INTO b VALUES(1,...
604Matrix multiplication
19sql
7nyrt
import requests for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67']: vendor = requests.get('http: print(addr, vendor)
608MAC Vendor Lookup
3python
tjbfw
package main import "fmt" import "C" func main() { code := []byte{ 0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d, 0xfc, 0x89, 0x75, 0xf8, 0x8b, 0x75, 0xfc, 0x03, 0x75, 0xf8, 0x89, 0x75, 0xf4, 0x8b, 0x45, 0xf4, 0x5d, 0xc3, } le := len(code) buf := C.mmap(nil, C.size_t(le), C.PROT...
609Machine code
0go
ypa64
try: from functools import reduce except: pass def mandelbrot(a): return reduce(lambda z, _: z * z + a, range(50), 0) def step(start, step, iterations): return (start + (i * step) for i in range(iterations)) rows = (( if abs(mandelbrot(complex(x, y))) < 2 else for x in step(-2.0, .0315, 80)...
607Mandelbrot set
3python
nghiz
int main() { char *question = NULL; size_t len = 0; ssize_t read; const char* answers[20] = { , , , , , , , , , , , , , , , , , , , }; srand(time(NULL)); printf(); while (1) { printf(); read = getline(&quest...
610Magic 8-ball
5c
tjhf4
null
609Machine code
11kotlin
cex98
iterate.until.escape <- function(z, c, trans, cond, max=50, response=dwell) { active <- seq_along(z) dwell <- z dwell[] <- 0 for (i in 1:max) { z[active] <- trans(z[active], c[active]); survived <- cond(z[active]) dwell[active[!survived]] <- i active <- active[survived] if (length(acti...
607Mandelbrot set
13r
0vgsg
@inlinable public func matrixMult<T: Numeric>(_ m1: [[T]], _ m2: [[T]]) -> [[T]] { let n = m1[0].count let m = m1.count let p = m2[0].count guard m!= 0 else { return [] } precondition(n == m2.count) var ret = Array(repeating: Array(repeating: T.zero, count: p), count: m) for i in 0..<m { for...
604Matrix multiplication
17swift
lwic2
require 'net/http' arr = ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67'] arr.each do |addr| vendor = Net::HTTP.get('api.macvendors.com', ) rescue nil puts end
608MAC Vendor Lookup
14ruby
3k1z7
extern crate reqwest; use std::{thread, time}; fn get_vendor(mac: &str) -> Option<String> { let mut url = String::from("http:
608MAC Vendor Lookup
15rust
6ba3l
object LookUp extends App { val macs = Seq("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D") def lookupVendor(mac: String) = scala.io.Source.fromURL("""http:
608MAC Vendor Lookup
16scala
9axm5
(def responses ["It is certain" "It is decidedly so" "Without a doubt" "Yes, definitely" "You may rely on it" "As I see it, yes" "Most likely" "Outlook good" "Signs point to yes" "Yes" "Reply hazy, try again" "Ask again later" "Better not tell you now" "Cannot predict now" "Concentrate and ask again" "Don'...
610Magic 8-ball
6clojure
m1ayq
require 'complex' def mandelbrot(a) Array.new(50).inject(0) { |z,c| z*z + a } end (1.0).step(-1,-0.05) do |y| (-2.0).step(0.5,0.0315) do |x| print mandelbrot(Complex(x,y)).abs < 2? '*': ' ' end puts end
607Mandelbrot set
14ruby
f7bdr
import ctypes import os from ctypes import c_ubyte, c_int code = bytes([0x8b, 0x44, 0x24, 0x04, 0x03, 0x44, 0x24, 0x08, 0xc3]) code_size = len(code) if (os.name == 'posix'): import mmap executable_map = mmap.mmap(-1, code_size, mmap.MAP_PRIVATE | mmap.MAP_ANON, mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EX...
609Machine code
3python
qlvxi
extern crate image; extern crate num_complex; use std::fs::File; use num_complex::Complex; fn main() { let max_iterations = 256u16; let img_side = 800u32; let cxmin = -2f32; let cxmax = 1f32; let cymin = -1.5f32; let cymax = 1.5f32; let scalex = (cxmax - cxmin) / img_side as f32; let s...
607Mandelbrot set
15rust
tjpfd
extern crate libc; #[cfg(all( target_os = "linux", any(target_pointer_width = "32", target_pointer_width = "64") ))] fn main() { use std::mem; use std::ptr; let page_size: usize = 4096; let (bytes, size): (Vec<u8>, usize) = if cfg!(target_pointer_width = "32") { ( vec![0x8b...
609Machine code
15rust
8u407
import org.rosettacode.ArithmeticComplex._ import java.awt.Color object Mandelbrot { def generate(width:Int =600, height:Int =400)={ val bm=new RgbBitmap(width, height) val maxIter=1000 val xMin = -2.0 val xMax = 1.0 val yMin = -1.0 val yMax = 1.0 val cx=(xMax-xMin)/wid...
607Mandelbrot set
16scala
6be31
package main import ( "bufio" "bytes" "fmt" "log" "math/rand" "os" "time" ) func main() { rand.Seed(time.Now().UnixNano()) answers := [...]string{ "It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Signs...
610Magic 8-ball
0go
hftjq
!ExternalBytes class methods! mapExecutableBytes:size %{ # include <sys/mman.h> void *mem; OBJ retVal; int nBytes = __intVal(size); mem = mmap(nil, nBytes, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); if (mem!= MAP_FAILED) { RETURN( __MKEXTERNALBYTES_N(mem, nBytes)); ...
609Machine code
16scala
ng7ic
import Foundation typealias TwoIntsOneInt = @convention(c) (Int, Int) -> Int let code = [ 144,
609Machine code
17swift
s2uqt
import System.Random (getStdRandom, randomR) import Control.Monad (forever) answers :: [String] answers = [ "It is certain" , "It is decidedly so" , "Without a doubt" , "Yes, definitely" , "You may rely on it" , "As I see it, yes" , "Most likely" , "Outlook good" , "Signs point to...
610Magic 8-ball
8haskell
i4gor
import java.util.Random; import java.util.Scanner; public class MagicEightBall { public static void main(String[] args) { new MagicEightBall().run(); } private static String[] ANSWERS = new String[] {"It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "Yo...
610Magic 8-ball
9java
xclwy
null
610Magic 8-ball
10javascript
o5486