code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
package main
import "time"
import "fmt"
func main() {
fmt.Print("Enter number of seconds to sleep: ")
var sec float64
fmt.Scanf("%f", &sec)
fmt.Print("Sleeping")
time.Sleep(time.Duration(sec * float64(time.Second)))
fmt.Println("\nAwake!")
} | 271Sleep | 0go | fx9d0 |
def sleepTest = {
println("Sleeping...")
sleep(it)
println("Awake!")
} | 271Sleep | 7groovy | 8pz0b |
package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | 269Singly-linked list/Traversal | 2perl | 4y15d |
def chain_insert(lst, at, item):
while lst is not None:
if lst[0] == at:
lst[1] = [item, lst[1]]
return
else:
lst = lst[1]
raise ValueError(str(at) + )
chain = ['A', ['B', None]]
chain_insert(chain, 'A', 'C')
print chain | 270Singly-linked list/Element insertion | 3python | 30vzc |
import Control.Concurrent
main = do seconds <- readLn
putStrLn "Sleeping..."
threadDelay $ round $ seconds * 1000000
putStrLn "Awake!" | 271Sleep | 8haskell | 4yb5s |
for node in lst:
print node.value | 269Singly-linked list/Traversal | 3python | gma4h |
class ListNode
def insert_after(search_value, new_value)
if search_value == value
self.succ = self.class.new(new_value, succ)
elsif self.succ.nil?
raise StandardError,
else
self.succ.insert_after(search_value, new_value)
end
end
end
list = ListNode.new(:a, ListNode.new(:b))
list.... | 270Singly-linked list/Element insertion | 14ruby | yo56n |
impl<T> List<T> {
pub fn new() -> Self {
List { head: None }
}
pub fn push(&mut self, elem: T) {
let new_node = Box::new(Node {
elem: elem,
next: self.head.take(),
});
self.head = Some(new_node);
} | 270Singly-linked list/Element insertion | 15rust | mi4ya |
import java.util.InputMismatchException;
import java.util.Scanner;
public class Sleep {
public static void main(final String[] args) throws InterruptedException {
try {
int ms = new Scanner(System.in).nextInt(); | 271Sleep | 9java | cdg9h |
<script>
setTimeout(function () {
document.write('Awake!')
}, prompt("Number of milliseconds to sleep"));
document.write('Sleeping... ');
</script> | 271Sleep | 10javascript | 56kur |
object List {
def add[A](as: List[A], a: A): List[A] = Cons(a, as)
} | 270Singly-linked list/Element insertion | 16scala | lf7cq |
package main
import (
"github.com/fogleman/gg"
"github.com/trubitsyn/go-lindenmayer"
"log"
"math"
)
const twoPi = 2 * math.Pi
var (
width = 770.0
height = 770.0
dc = gg.NewContext(int(width), int(height))
)
var cx, cy, h, theta float64
func main() {
dc.SetRGB(0, 0, 1) | 273Sierpinski square curve | 0go | gmk4n |
null | 271Sleep | 11kotlin | 302z5 |
import java.io.*;
public class SierpinskiSquareCurve {
public static void main(final String[] args) {
try (Writer writer = new BufferedWriter(new FileWriter("sierpinski_square.svg"))) {
SierpinskiSquareCurve s = new SierpinskiSquareCurve(writer);
int size = 635, length = 5;
... | 273Sierpinski square curve | 9java | 14qp2 |
head = ListNode.new(, ListNode.new(, ListNode.new()))
head.insertAfter(, )
head.each {|node| print node.value, }
puts
current = head
begin
print current.value,
end while current = current.succ
puts | 269Singly-linked list/Traversal | 14ruby | 7cwri |
package main
import (
"fmt"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Click me")
label := gtk.NewLabel("There have been no clicks yet")
var clicks int
button := gtk.NewButtonWithLabel("click me")
button... | 272Simple windowed application | 0go | miuyi |
null | 269Singly-linked list/Traversal | 15rust | jlx72 |
def traverse[A](as: List[A]): Unit = as match {
case Nil => print("End")
case Cons(h, t) => {
print(h + " ")
traverse(t)
}
} | 269Singly-linked list/Traversal | 16scala | bu0k6 |
use strict;
use warnings;
use SVG;
use List::Util qw(max min);
use constant pi => 2 * atan2(1, 0);
my $rule = 'XF-F+F-XF+F+XF-F+F-X';
my $S = 'F+F+XF+F+XF';
$S =~ s/X/$rule/g for 1..5;
my (@X, @Y);
my ($x, $y) = (0, 0);
my $theta = pi/4;
my $r = 6;
for (split //, $S) {
if (/F/) {
push @X, sprintf... | 273Sierpinski square curve | 2perl | tqmfg |
import groovy.swing.SwingBuilder
count = 0
new SwingBuilder().edt {
frame(title:'Click frame', pack: true, show: true) {
vbox {
countLabel = label("There have been no clicks yet.")
button('Click Me', actionPerformed: {count++; countLabel.text = "Clicked ${count} time(s)."})
}
}
} | 272Simple windowed application | 7groovy | tq9fh |
import Graphics.UI.Gtk
import Data.IORef
main :: IO ()
main = do
initGUI
window <- windowNew
window `onDestroy` mainQuit
windowSetTitle window "Simple Windowed App"
set window [ containerBorderWidth:= 10 ]
hbox <- hBoxNew True 5
set window [ containerChild:= hbox ]
lab <- labelNew (Just "There have ... | 272Simple windowed application | 8haskell | kvwh0 |
local socket = require("socket")
io.write("Input a number of seconds to sleep: ")
local input = io.read("*number")
print("Sleeping")
socket.sleep(input)
print("Awake!") | 271Sleep | 1lua | 68v39 |
import matplotlib.pyplot as plt
import math
def nextPoint(x, y, angle):
a = math.pi * angle / 180
x2 = (int)(round(x + (1 * math.cos(a))))
y2 = (int)(round(y + (1 * math.sin(a))))
return x2, y2
def expand(axiom, rules, level):
for l in range(0, level):
a2 =
for c in axiom:
... | 273Sierpinski square curve | 3python | zs9tt |
null | 273Sierpinski square curve | 15rust | yo268 |
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class Clicks extends JFrame{
private long clicks = 0;
public Cl... | 272Simple windowed application | 9java | 4yk58 |
<html>
<head>
<title>Simple Window Application</title>
</head>
<body>
<br>        
<script type="text/javascript">
var box = document.createElement('input')
box.style.position = 'absolute'; | 272Simple windowed application | 10javascript | h2ejh |
null | 272Simple windowed application | 11kotlin | lfgcp |
require"iuplua"
l = iup.label{title="There have been no clicks yet."}
b = iup.button{title="Click me!"}
clicks = 0
function b:button_cb()
clicks = clicks + 1
l.title = "There have been " .. clicks/2 .. " clicks so far." | 272Simple windowed application | 1lua | 2trl3 |
typedef struct cursor_tag {
double x;
double y;
int angle;
} cursor_t;
void turn(cursor_t* cursor, int angle) {
cursor->angle = (cursor->angle + angle) % 360;
}
void draw_line(FILE* out, cursor_t* cursor, double length) {
double theta = (M_PI * cursor->angle)/180.0;
cursor->x += length * cos(t... | 274Sierpinski arrowhead curve | 5c | vzg2o |
$seconds = <>;
print "Sleeping...\n";
sleep $seconds;
print "Awake!\n"; | 271Sleep | 2perl | p5sb0 |
$seconds = 42;
echo ;
sleep($seconds);
echo ; | 271Sleep | 12php | you61 |
package main
import (
"github.com/fogleman/gg"
"math"
)
var (
width = 770.0
height = 770.0
dc = gg.NewContext(int(width), int(height))
iy = 1.0
theta = 0
)
var cx, cy, h float64
func arrowhead(order int, length float64) { | 274Sierpinski arrowhead curve | 0go | skiqa |
import time
seconds = float(raw_input())
print
time.sleep(seconds)
print | 271Sleep | 3python | 140pc |
sleep <- function(time=1)
{
message("Sleeping...")
flush.console()
Sys.sleep(time)
message("Awake!")
}
sleep() | 271Sleep | 13r | h2wjj |
use strict;
use warnings;
use SVG;
use List::Util qw(max min);
use constant pi => 2 * atan2(1, 0);
my %rules = (
X => 'YF+XF+Y',
Y => 'XF-YF-X'
);
my $S = 'Y';
$S =~ s/([XY])/$rules{$1}/eg for 1..7;
my (@X, @Y);
my ($x, $y) = (0, 0);
my $theta = 0;
my $r = 6;
for (split //, $S) {
if (/F/) {
... | 274Sierpinski arrowhead curve | 2perl | gmh4e |
use Tk;
$main = MainWindow->new;
$l = $main->Label('-text' => 'There have been no clicks yet.')->pack;
$count = 0;
$main->Button(
-text => ' Click Me ',
-command => sub { $l->configure(-text => 'Number of clicks: '.(++$count).'.'); },
)->pack;
MainLoop(); | 272Simple windowed application | 2perl | qhnx6 |
import matplotlib.pyplot as plt
import math
def nextPoint(x, y, angle):
a = math.pi * angle / 180
x2 = (int)(round(x + (1 * math.cos(a))))
y2 = (int)(round(y + (1 * math.sin(a))))
return x2, y2
def expand(axiom, rules, level):
for l in range(0, level):
a2 =
for c in axiom:
... | 274Sierpinski arrowhead curve | 3python | r9kgq |
seconds = gets.to_f
puts
sleep(seconds)
puts | 271Sleep | 14ruby | eroax |
use std::{io, time, thread};
fn main() {
println!("How long should we sleep in milliseconds?");
let mut sleep_string = String::new();
io::stdin().read_line(&mut sleep_string)
.expect("Failed to read line");
let sleep_timer: u64 = sleep_string.trim()
... | 271Sleep | 15rust | w7ie4 |
object Sleeper extends App {
print("Enter sleep time in milli sec: ")
val ms = scala.io.StdIn.readInt()
println("Sleeping...")
val sleepStarted = scala.compat.Platform.currentTime
Thread.sleep(ms)
println(s"Awaked after [${scala.compat.Platform.currentTime - sleepStarted} ms]1")
} | 271Sleep | 16scala | skfqo |
long long x, y, dx, dy, scale, clen, cscale;
typedef struct { double r, g, b; } rgb;
rgb ** pix;
void sc_up()
{
scale *= 2; x *= 2; y *= 2;
cscale *= 3;
}
void h_rgb(long long x, long long y)
{
rgb *p = &pix[y][x];
double h = 6.0 * clen / cscale;
double VAL = 1;
double c = SAT * VAL;
double X = c * (1 - fabs... | 275Sierpinski triangle/Graphical | 5c | 9n2m1 |
load_libraries :grammar
attr_reader :points
def setup
sketch_title 'Sierpinski Arrowhead'
sierpinski = SierpinskiArrowhead.new(Vec2D.new(width * 0.15, height * 0.7))
production = sierpinski.generate 6
@points = sierpinski.translate_rules(production)
no_loop
end
def draw
background(0)
render points
end
... | 274Sierpinski arrowhead curve | 14ruby | jlp7x |
null | 274Sierpinski arrowhead curve | 15rust | h21j2 |
from functools import partial
import tkinter as tk
def on_click(label: tk.Label,
counter: tk.IntVar) -> None:
counter.set(counter.get() + 1)
label[] = f
def main():
window = tk.Tk()
window.geometry()
label = tk.Label(master=window,
text=)
label.pack()
coun... | 272Simple windowed application | 3python | skdq9 |
int main(){
time_t t;
double side, **vertices,seedX,seedY,windowSide = 500,sumX=0,sumY=0;
int i,iter,choice,numSides;
printf();
scanf(,&numSides);
printf();
scanf(,&side);
printf();
scanf(,&iter);
initwindow(windowSide,windowSide,);
vertices = (double**)malloc(numSides*sizeof(double*));
for(i=0;i<num... | 276Sierpinski pentagon | 5c | micys |
import Foundation
println("Enter number of seconds to sleep")
let input = NSFileHandle.fileHandleWithStandardInput()
var amount = NSString(data:input.availableData, encoding: NSUTF8StringEncoding)?.intValue
var interval = NSTimeInterval(amount!)
println("Sleeping...")
NSThread.sleepForTimeInterval(interval)
println("... | 271Sleep | 17swift | ag81i |
library(gWidgets)
library(gWidgetstcltk)
win <- gwindow()
lab <- glabel("There have been no clicks yet", container=win)
btn <- gbutton("click me", container=win, handle=function(h, ...)
{
val <- as.numeric(svalue(lab))
svalue(lab) <- ifelse(is.na(val) ,"1", as.character(val + 1))
}
) | 272Simple windowed application | 13r | er8ad |
package main
import (
"github.com/fogleman/gg"
"image/color"
"math"
)
var (
red = color.RGBA{255, 0, 0, 255}
green = color.RGBA{0, 255, 0, 255}
blue = color.RGBA{0, 0, 255, 255}
magenta = color.RGBA{255, 0, 255, 255}
cyan = color.RGBA{0, 255, 255, 255}
)
var (
w, h ... | 276Sierpinski pentagon | 0go | agw1f |
package main
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"os"
)
func main() {
const order = 8
const width = 1 << order
const margin = 10
bounds := image.Rect(-margin, -margin, width+2*margin, width+2*margin)
im := image.NewGray(bounds)
gBlack := color.... | 275Sierpinski triangle/Graphical | 0go | erqa6 |
import Graphics.Gloss
pentaflake :: Int -> Picture
pentaflake order = iterate transformation pentagon !! order
where
transformation = Scale s s . foldMap copy [0,72..288]
copy a = Rotate a . Translate 0 x
pentagon = Polygon [ (sin a, cos a) | a <- [0,2*pi/5..2*pi] ]
x = 2*cos(pi/5)
s = 1/(1+x)
... | 276Sierpinski pentagon | 8haskell | zs6t0 |
import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
triangle = eqTriangle # fc black # lw 0
reduce t = t
===
(t ||| t)
sierpinski = iterate reduce triangle
main = defaultMain $ sierpinski !! 7 | 275Sierpinski triangle/Graphical | 8haskell | 30mzj |
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.geom.Path2D;
import static java.lang.Math.*;
import java.util.Random;
import javax.swing.*;
public class SierpinskiPentagon extends JPanel { | 276Sierpinski pentagon | 9java | o1n8d |
require 'tk'
str = TkVariable.new()
count = 0
root = TkRoot.new
TkLabel.new(root, => str).pack
TkButton.new(root) do
text
command {str.value = count += 1}
pack
end
Tk.mainloop | 272Simple windowed application | 14ruby | 8pt01 |
<html>
<head>
<script type="application/x-javascript"> | 276Sierpinski pentagon | 10javascript | tq3fm |
import javax.swing.*;
import java.awt.*;
class SierpinskyTriangle {
public static void main(String[] args) {
int i = 3; | 275Sierpinski triangle/Graphical | 9java | iafos |
use iced::{ | 272Simple windowed application | 15rust | o1z83 |
import scala.swing.{ BorderPanel, Button, Label, MainFrame, SimpleSwingApplication }
import scala.swing.event.ButtonClicked
object SimpleApp extends SimpleSwingApplication {
def top = new MainFrame {
contents = new BorderPanel {
var nClicks = 0
val (button, label) = (new Button { text = "click me" }... | 272Simple windowed application | 16scala | dwyng |
null | 276Sierpinski pentagon | 11kotlin | xjsws |
<!-- SierpinskiTriangle.html -->
<html>
<head><title>Sierpinski Triangle Fractal</title>
<script> | 275Sierpinski triangle/Graphical | 10javascript | zsyt2 |
Bitmap.chaosgame = function(self, n, r, niters)
local w, h, vertices = self.width, self.height, {}
for i = 1, n do
vertices[i] = {
x = w/2 + w/2 * math.cos(math.pi/2+(i-1)*math.pi*2/n),
y = h/2 - h/2 * math.sin(math.pi/2+(i-1)*math.pi*2/n)
}
end
local x, y = w/2, h/2
for i = 1, niters do
... | 276Sierpinski pentagon | 1lua | qh0x0 |
import java.awt.*
import javax.swing.JFrame
import javax.swing.JPanel
fun main(args: Array<String>) {
var i = 8 | 275Sierpinski triangle/Graphical | 11kotlin | qh8x1 |
int main() {
time_t t = 0;
printf(, asctime(gmtime(&t)));
return 0;
} | 277Show the epoch | 5c | 4yg5t |
int main()
{
int x, y, i;
for (y = SIZE - 1; y >= 0; y--, putchar('\n')) {
for (i = 0; i < y; i++) putchar(' ');
for (x = 0; x + y < SIZE; x++)
printf((x & y) ? : );
}
return 0;
} | 278Sierpinski triangle | 5c | 565uk |
null | 275Sierpinski triangle/Graphical | 1lua | skoq8 |
use ntheory qw(todigits);
use Math::Complex;
$sides = 5;
$order = 5;
$dim = 250;
$scale = ( 3 - 5**.5 ) / 2;
push @orders, ((1 - $scale) * $dim) * $scale ** $_ for 0..$order-1;
open $fh, '>', 'sierpinski_pentagon.svg';
print $fh qq|<svg height="@{[$dim*2]}" width="@{[$dim*2]}" style="fill:blue" version="1.1" xmlns=... | 276Sierpinski pentagon | 2perl | 2tulf |
(println (java.util.Date. 0)) | 277Show the epoch | 6clojure | h2kjr |
(ns example
(:require [clojure.contrib.math:as math]))
(defmulti #^{:private true} integer-length class)
(defmethod integer-length java.lang.Integer [n]
(count (Integer/toBinaryString n)))
(defmethod integer-length java.lang.Long [n]
(count (Long/toBinaryString n)))
(defmethod integer-length java.math.BigInte... | 278Sierpinski triangle | 6clojure | jlj7m |
main() {
print(new Date.fromEpoch(0,new TimeZone.utc()));
} | 277Show the epoch | 18dart | cdl9e |
from turtle import *
import math
speed(0)
hideturtle()
part_ratio = 2 * math.cos(math.radians(72))
side_ratio = 1 / (part_ratio + 2)
hide_turtles = True
path_color =
fill_color =
def pentagon(t, s):
t.color(path_color, fill_color)
t.pendown()
t.right(36)
t.begin_fill()
for i in range(5):
... | 276Sierpinski pentagon | 3python | vz529 |
my $levels = 6;
my $side = 512;
my $height = get_height($side);
sub get_height { my($side) = @_; $side * sqrt(3) / 2 }
sub triangle {
my($x1, $y1, $x2, $y2, $x3, $y3, $fill, $animate) = @_;
my $svg;
$svg .= qq{<polygon points="$x1,$y1 $x2,$y2 $x3,$y3"};
$svg .= qq{ style="fill: $fill; stroke-width: ... | 275Sierpinski triangle/Graphical | 2perl | vz420 |
,,,,
,,,,
,,,,
,,,,
,,,, | 279Simple database | 5c | qjwxc |
typedef struct link link_t;
struct link {
int len;
char letter;
link_t *next;
};
int scs(char *x, char *y, char *out)
{
int lx = strlen(x), ly = strlen(y);
link_t lnk[ly + 1][lx + 1];
for (int i = 0; i < ly; i++)
lnk[i][lx] = (link_t) {ly - i, y[i], &lnk[i + 1][lx]};
for (int j = 0; j < lx; j++)
lnk[ly][... | 280Shortest common supersequence | 5c | 3sfza |
package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
} | 277Show the epoch | 0go | o1i8q |
def date = new Date(0)
def format = new java.text.SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ')
format.timeZone = TimeZone.getTimeZone('UTC')
println (format.format(date)) | 277Show the epoch | 7groovy | xjqwl |
import System.Time
main = putStrLn $ calendarTimeToString $ toUTCTime $ TOD 0 0 | 277Show the epoch | 8haskell | 2tvll |
THETA = Math::PI * 2 / 5
SCALE_FACTOR = (3 - Math.sqrt(5)) / 2
MARGIN = 20
attr_reader :pentagons, :renderer
def settings
size(400, 400)
end
def setup
sketch_title 'Pentaflake'
radius = width / 2 - 2 * MARGIN
center = Vec2D.new(radius - 2 * MARGIN, 3 * MARGIN)
pentaflake = Pentaflake.new(center, radius, 5)
... | 276Sierpinski pentagon | 14ruby | 56guj |
package main
import (
"fmt"
"strings"
)
func lcs(x, y string) string {
xl, yl := len(x), len(y)
if xl == 0 || yl == 0 {
return ""
}
x1, y1 := x[:xl-1], y[:yl-1]
if x[xl-1] == y[yl-1] {
return fmt.Sprintf("%s%c", lcs(x1, y1), x[xl-1])
}
x2, y2 := lcs(x, y1), lcs(x1, ... | 280Shortest common supersequence | 0go | bvjkh |
import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.p... | 277Show the epoch | 9java | 68y3z |
null | 276Sierpinski pentagon | 15rust | 4yr5u |
import java.awt._
import java.awt.event.ActionEvent
import java.awt.geom.Path2D
import javax.swing._
import scala.annotation.tailrec
import scala.math.{Pi, cos, sin, sqrt}
object SierpinskiPentagon extends App {
SwingUtilities.invokeLater(() => {
class SierpinskiPentagon extends JPanel {
privat... | 276Sierpinski pentagon | 16scala | 7chr9 |
import turtle as t
def sier(n,length):
if n == 0:
return
for i in range(3):
sier(n - 1, length / 2)
t.fd(length)
t.rt(120) | 275Sierpinski triangle/Graphical | 3python | u3gvd |
scs :: Eq a => [a] -> [a] -> [a]
scs [] ys = ys
scs xs [] = xs
scs xss@(x:xs) yss@(y:ys)
| x == y = x: scs xs ys
| otherwise = ws
where
us = scs xs yss
vs = scs xss ys
ws | length us < length vs = x: us
| otherwise = y: vs
main = putStrLn $ scs "abcbdab" "bdcaba" | 280Shortest common supersequence | 8haskell | deon4 |
public class ShortestCommonSuperSequence {
private static boolean isEmpty(String s) {
return null == s || s.isEmpty();
}
private static String scs(String x, String y) {
if (isEmpty(x)) {
return y;
}
if (isEmpty(y)) {
return x;
}
if (x... | 280Shortest common supersequence | 9java | shwq0 |
document.write(new Date(0).toUTCString()); | 277Show the epoch | 10javascript | lf2cf |
pSierpinskiT <- function(ord, fn="", ttl="", clr="navy") {
m=640; abbr="STR"; dftt="Sierpinski triangle";
n=2^ord; M <- matrix(c(0), ncol=n, nrow=n, byrow=TRUE);
cat(" *** START", abbr, date(), "\n");
if(fn=="") {pf=paste0(abbr,"o", ord)} else {pf=paste0(fn, ".png")};
if(ttl!="") {dftt=ttl}; ttl=paste0(dftt,"... | 275Sierpinski triangle/Graphical | 13r | cdv95 |
null | 280Shortest common supersequence | 11kotlin | a4b13 |
null | 277Show the epoch | 11kotlin | dwfnz |
sub lcs {
my( $u, $v ) = @_;
return '' unless length($u) and length($v);
my $longest = '';
for my $first ( 0..length($u)-1 ) {
my $char = substr $u, $first, 1;
my $i = index( $v, $char );
next if -1==$i;
my $next = $char;
$next .= lcs( substr( $u, $first+1), subs... | 280Shortest common supersequence | 2perl | 9i6mn |
Shoes.app(:height=>540,:width=>540, :title=>) do
def triangle(slot, tri, color)
x, y, len = tri
slot.append do
fill color
shape do
move_to(x,y)
dx = len * Math::cos(Math::PI/3)
dy = len * Math::sin(Math::PI/3)
line_to(x-dx, y+dy)
line_to(x+dx, y+dy)
... | 275Sierpinski triangle/Graphical | 14ruby | 4y75p |
package main
import (
"encoding/json"
"fmt"
"io"
"os"
"sort"
"strings"
"time"
"unicode"
) | 279Simple database | 0go | 2fcl7 |
print(os.date("%c", 0)) | 277Show the epoch | 1lua | fxtdp |
null | 275Sierpinski triangle/Graphical | 15rust | gmj4o |
import Control.Monad.State
import Data.List (sortBy, nub)
import System.Environment (getArgs, getProgName)
import System.Directory (doesFileExist)
import System.IO (openFile, hGetContents, hClose, IOMode(..),
Handle, hPutStrLn)
data Date = Date Integer Int Int deriving (Show, Read, Eq, Ord)
data Item = Item ... | 279Simple database | 8haskell | a4p1g |
def shortest_common_supersequence(a, b):
lcs = longest_common_subsequence(a, b)
scs =
while len(lcs) > 0:
if a[0]==lcs[0] and b[0]==lcs[0]:
scs += lcs[0]
lcs = lcs[1:]
a = a[1:]
b = b[1:]
elif a[0]==lcs[0]:
scs += b[0... | 280Shortest common supersequence | 3python | cny9q |
require 'lcs'
def scs(u, v)
lcs = lcs(u, v)
u, v = u.dup, v.dup
scs =
until lcs.empty?
if u[0]==lcs[0] and v[0]==lcs[0]
scs << lcs.slice!(0)
u.slice!(0)
v.slice!(0)
elsif u[0]==lcs[0]
scs << v.slice!(0)
else
scs << u.slice!(0)
end
end
... | 280Shortest common supersequence | 14ruby | 2f9lw |
typedef struct{
double x,y;
}point;
double shoelace(char* inputFile){
int i,numPoints;
double leftSum = 0,rightSum = 0;
point* pointSet;
FILE* fp = fopen(inputFile,);
fscanf(fp,,&numPoints);
pointSet = (point*)malloc((numPoints + 1)*sizeof(point));
for(i=0;i<numPoints;i++){
fscanf(fp,,&pointSet[i].x,&poi... | 281Shoelace formula for polygonal area | 5c | rmug7 |
import java.io.*;
import java.text.*;
import java.util.*;
public class SimpleDatabase {
final static String filename = "simdb.csv";
public static void main(String[] args) {
if (args.length < 1 || args.length > 3) {
printUsage();
return;
}
switch (args[0].toLow... | 279Simple database | 9java | jcr7c |
null | 279Simple database | 11kotlin | 53vua |
print scalar gmtime 0, "\n"; | 277Show the epoch | 2perl | jlh7f |
<?php
echo gmdate('r', 0), ;
?> | 277Show the epoch | 12php | tqzf1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.