WeixiangYan/CodeTransOcean huggingface dataset:
Task: Four sides of square


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto fourSides = [](int x, int y, int size)
  {
    return x == 0 || (y == 0) || (x == size - 1) || (y == size - 1);
  };

  PrintMatrix(fourSides, 8);
  PrintMatrix(fourSides, 9);
}



Go: package main

import "fmt"

func hollowMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if i == 0 || i == n-1 || j == 0 || j == n-1 {
                fmt.Printf("%d ", 1)
            } else {
                fmt.Printf("%d ", 0)
            }
        }
        fmt.Println()
    }
}

func main() {
    hollowMatrix(8)
    fmt.Println()
    hollowMatrix(9)
}
Task: Four sides of square


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto fourSides = [](int x, int y, int size)
  {
    return x == 0 || (y == 0) || (x == size - 1) || (y == size - 1);
  };

  PrintMatrix(fourSides, 8);
  PrintMatrix(fourSides, 9);
}




Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if(i==0||i==9||j==0||j==9){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}
Task: Four sides of square


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto fourSides = [](int x, int y, int size)
  {
    return x == 0 || (y == 0) || (x == size - 1) || (y == size - 1);
  };

  PrintMatrix(fourSides, 8);
  PrintMatrix(fourSides, 9);
}






Python: size = 9
for row in range(size):
    for col in range(size):
        if row == 0 or row == size-1 or col == 0 or col == size-1:
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Four sides of square




Go: package main

import "fmt"

func hollowMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if i == 0 || i == n-1 || j == 0 || j == n-1 {
                fmt.Printf("%d ", 1)
            } else {
                fmt.Printf("%d ", 0)
            }
        }
        fmt.Println()
    }
}

func main() {
    hollowMatrix(8)
    fmt.Println()
    hollowMatrix(9)
}


Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if(i==0||i==9||j==0||j==9){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}
Task: Four sides of square





Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if(i==0||i==9||j==0||j==9){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}



Python: size = 9
for row in range(size):
    for col in range(size):
        if row == 0 or row == size-1 or col == 0 or col == size-1:
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Four sides of square

C: #include <stdio.h>

void hollowMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if (i == 0 || i == n - 1 || j == 0 || j == n - 1) {
                printf("%d ", 1);
            } else {
                printf("%d ", 0);
            }
        }
        printf("\n");
    }
}

int main() {
    hollowMatrix(10);
    printf("\n");
    hollowMatrix(11);
    return 0;
}


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto fourSides = [](int x, int y, int size)
  {
    return x == 0 || (y == 0) || (x == size - 1) || (y == size - 1);
  };

  PrintMatrix(fourSides, 8);
  PrintMatrix(fourSides, 9);
}
Task: Four sides of square




Go: package main

import "fmt"

func hollowMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if i == 0 || i == n-1 || j == 0 || j == n-1 {
                fmt.Printf("%d ", 1)
            } else {
                fmt.Printf("%d ", 0)
            }
        }
        fmt.Println()
    }
}

func main() {
    hollowMatrix(8)
    fmt.Println()
    hollowMatrix(9)
}




Python: size = 9
for row in range(size):
    for col in range(size):
        if row == 0 or row == size-1 or col == 0 or col == size-1:
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Draw a clock

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
 
#define PI 3.14159265
const char * shades = " .:-*ca&#%@";
 

double dist(double x, double y, double x0, double y0) {
	double l = (x * x0 + y * y0) / (x0 * x0 + y0 * y0);
 
	if (l > 1) {
		x -= x0;
		y -= y0;
	} else if (l >= 0) {
		x -= l * x0;
		y -= l * y0;
	}
	return sqrt(x * x + y * y);
}
 
enum { sec = 0, min, hur }; 
 
void draw(int size)
{
#	define for_i for(int i = 0; i < size; i++)
#	define for_j for(int j = 0; j < size * 2; j++)
 
	double angle, cx = size / 2.;
	double sx[3], sy[3], sw[3];
	double fade[] = { 1, .35, .35 }; 
	struct timeval tv;
	struct tm *t;
 
	
	sw[sec] = size * .02;
	sw[min] = size * .03;
	sw[hur] = size * .05;
 
every_second:
	gettimeofday(&tv, 0);
	t = localtime(&tv.tv_sec);
 
	angle = t->tm_sec * PI / 30;
	sy[sec] = -cx * cos(angle);
	sx[sec] =  cx * sin(angle);
 
	angle = (t->tm_min + t->tm_sec / 60.) / 30 * PI;
	sy[min] = -cx * cos(angle) * .8;
	sx[min] =  cx * sin(angle) * .8;
 
	angle = (t->tm_hour + t->tm_min / 60.) / 6 * PI;
	sy[hur] = -cx * cos(angle) * .6;
	sx[hur] =  cx * sin(angle) * .6;
 
	printf("\033[s"); 
	for_i {
		printf("\033[%d;0H", i);  
		double y = i - cx;
		for_j {
			double x = (j - 2 * cx) / 2;
 
			int pix = 0;
			
			for (int k = hur; k >= sec; k--) {
				double d = dist(x, y, sx[k], sy[k]);
				if (d < sw[k] - .5)
					pix = 10 * fade[k];
				else if (d < sw[k] + .5)
					pix = (5 + (sw[k] - d) * 10) * fade[k];
			}
			putchar(shades[pix]);
		}
	}
	printf("\033[u"); 
 
	fflush(stdout);
	sleep(1); 
	goto every_second;
}
 
int main(int argc, char *argv[])
{
	int s;
	if (argc <= 1 || (s = atoi(argv[1])) <= 0) s = 20;
	draw(s);
	return 0;
}







Python: last_sec = second()

def draw():
    global last_sec
    if last_sec != second():
        draw_clock()
        last_sec = second()

def draw_clock():
    background(192)
    translate(width / 2, height / 2)
    s = second() * TWO_PI / 60.0
    m = minute() * TWO_PI / 60.0
    h = hour() * TWO_PI / 12.0
    rotate(s)
    strokeWeight(1)
    line(0, 0, 0, -width * 0.5)
    rotate(-s + m)
    strokeWeight(2)
    line(0, 0, 0, -width * 0.4)
    rotate(-m + h)
    strokeWeight(4)
    line(0, 0, 0, -width * 0.2)
Task: Draw a clock

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
 
#define PI 3.14159265
const char * shades = " .:-*ca&#%@";
 

double dist(double x, double y, double x0, double y0) {
	double l = (x * x0 + y * y0) / (x0 * x0 + y0 * y0);
 
	if (l > 1) {
		x -= x0;
		y -= y0;
	} else if (l >= 0) {
		x -= l * x0;
		y -= l * y0;
	}
	return sqrt(x * x + y * y);
}
 
enum { sec = 0, min, hur }; 
 
void draw(int size)
{
#	define for_i for(int i = 0; i < size; i++)
#	define for_j for(int j = 0; j < size * 2; j++)
 
	double angle, cx = size / 2.;
	double sx[3], sy[3], sw[3];
	double fade[] = { 1, .35, .35 }; 
	struct timeval tv;
	struct tm *t;
 
	
	sw[sec] = size * .02;
	sw[min] = size * .03;
	sw[hur] = size * .05;
 
every_second:
	gettimeofday(&tv, 0);
	t = localtime(&tv.tv_sec);
 
	angle = t->tm_sec * PI / 30;
	sy[sec] = -cx * cos(angle);
	sx[sec] =  cx * sin(angle);
 
	angle = (t->tm_min + t->tm_sec / 60.) / 30 * PI;
	sy[min] = -cx * cos(angle) * .8;
	sx[min] =  cx * sin(angle) * .8;
 
	angle = (t->tm_hour + t->tm_min / 60.) / 6 * PI;
	sy[hur] = -cx * cos(angle) * .6;
	sx[hur] =  cx * sin(angle) * .6;
 
	printf("\033[s"); 
	for_i {
		printf("\033[%d;0H", i);  
		double y = i - cx;
		for_j {
			double x = (j - 2 * cx) / 2;
 
			int pix = 0;
			
			for (int k = hur; k >= sec; k--) {
				double d = dist(x, y, sx[k], sy[k]);
				if (d < sw[k] - .5)
					pix = 10 * fade[k];
				else if (d < sw[k] + .5)
					pix = (5 + (sw[k] - d) * 10) * fade[k];
			}
			putchar(shades[pix]);
		}
	}
	printf("\033[u"); 
 
	fflush(stdout);
	sleep(1); 
	goto every_second;
}
 
int main(int argc, char *argv[])
{
	int s;
	if (argc <= 1 || (s = atoi(argv[1])) <= 0) s = 20;
	draw(s);
	return 0;
}








VB: 


ans0=chr(27)&"["
sub cls()  wscript.StdOut.Write ans0 &"2J"&ans0 &"?25l":end sub
sub torc(r,c,s)  wscript.StdOut.Write ans0 & r & ";" & c & "f"  & s :end sub


Sub draw_line(r1,c1, r2,c2,c)
  Dim x,y,xf,yf,dx,dy,sx,sy,err,err2
  x =r1    : y =c1
  xf=r2    : yf=c2
  dx=Abs(xf-x) : dy=Abs(yf-y)
  If x<xf Then sx=+1: Else sx=-1
  If y<yf Then sy=+1: Else sy=-1
  err=dx-dy
  Do
    torc x,y,c
    If x=xf And y=yf Then Exit Do
    err2=err+err
    If err2>-dy Then err=err-dy: x=x+sx
    If err2< dx Then err=err+dx: y=y+sy
  Loop
End Sub 

const pi180=0.017453292519943

const r0=13
const c0=26


nangi=-30*pi180
aangi=-6*pi180
ang0=90*pi180


lh=7
lm=9
ls=9
ln=12


while 1
     cls

    
    angn=ang0+nangi
    for i=1 to 12
      torc r0-cint(ln*sin(angn)),cint(c0+2*ln*cos(angn)),i
      angn=angn+nangi 
    next 

    
    t=now()
    torc 1,1, hour(t) &":"& minute(t) &":"& second(t) 
    
    
    angh=ang0+hour(t) *nangi
    angm=ang0+minute(t) *aangi
    angS=ang0+second(t) *aangi

    
    draw_line r0,c0,cint(r0-ls*sin(angs)),cint(c0+2*ls*cos(angs)),"."
    draw_line r0,c0,cint(r0-lm*sin(angm)),cint(c0+2*lm*cos(angm)),"*"
    draw_line r0,c0,cint(r0-lh*sin(angh)),cint(c0+2*lh*cos(angh)),"W"
    torc r0,c0,"O"
    
    
    wscript.sleep(1000)
wend
Task: Draw a clock



C#: using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

public class Clock : Form
{
    static readonly float degrees06 = (float)Math.PI / 30;
    static readonly float degrees30 = degrees06 * 5;
    static readonly float degrees90 = degrees30 * 3;

    readonly int margin = 20;

    private Point p0;

    public Clock()
    {
        Size = new Size(500, 500);
        StartPosition = FormStartPosition.CenterScreen;
        Resize += (sender, args) => ResetSize();
        ResetSize();
        var timer = new Timer() { Interval = 1000, Enabled = true };
        timer.Tick += (sender, e) => Refresh();
        DoubleBuffered = true;
    }

    private void ResetSize()
    {
        p0 = new Point(ClientRectangle.Width / 2, ClientRectangle.Height / 2);
        Refresh();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

        drawFace(e.Graphics);

        var time = DateTime.Now;
        int second = time.Second;
        int minute = time.Minute;
        int hour = time.Hour;

        float angle = degrees90 - (degrees06 * second);
        DrawHand(e.Graphics, Pens.Red, angle, 0.95);

        float minsecs = (minute + second / 60.0F);
        angle = degrees90 - (degrees06 * minsecs);
        DrawHand(e.Graphics, Pens.Black, angle, 0.9);

        float hourmins = (hour + minsecs / 60.0F);
        angle = degrees90 - (degrees30 * hourmins);
        DrawHand(e.Graphics, Pens.Black, angle, 0.6);
    }

    private void drawFace(Graphics g)
    {
        int radius = Math.Min(p0.X, p0.Y) - margin;
        g.FillEllipse(Brushes.White, p0.X - radius, p0.Y - radius, radius * 2, radius * 2);

        for (int h = 0; h < 12; h++)
            DrawHand(g, Pens.LightGray, h * degrees30, -0.05);

        for (int m = 0; m < 60; m++)
            DrawHand(g, Pens.LightGray, m * degrees06, -0.025);
    }

    private void DrawHand(Graphics g, Pen pen, float angle, double size)
    {
        int radius = Math.Min(p0.X, p0.Y) - margin;

        int x0 = p0.X + (size > 0 ? 0 : Convert.ToInt32(radius * (1 + size) * Math.Cos(angle)));
        int y0 = p0.Y + (size > 0 ? 0 : Convert.ToInt32(radius * (1 + size) * Math.Sin(-angle)));

        int x1 = p0.X + Convert.ToInt32(radius * (size > 0 ? size : 1) * Math.Cos(angle));
        int y1 = p0.Y + Convert.ToInt32(radius * (size > 0 ? size : 1) * Math.Sin(-angle));

        g.DrawLine(pen, x0, y0, x1, y1);
    }

    [STAThread]
    static void Main()
    {
        Application.Run(new Clock());
    }
}





Python: last_sec = second()

def draw():
    global last_sec
    if last_sec != second():
        draw_clock()
        last_sec = second()

def draw_clock():
    background(192)
    translate(width / 2, height / 2)
    s = second() * TWO_PI / 60.0
    m = minute() * TWO_PI / 60.0
    h = hour() * TWO_PI / 12.0
    rotate(s)
    strokeWeight(1)
    line(0, 0, 0, -width * 0.5)
    rotate(-s + m)
    strokeWeight(2)
    line(0, 0, 0, -width * 0.4)
    rotate(-m + h)
    strokeWeight(4)
    line(0, 0, 0, -width * 0.2)
Task: Draw a clock





Java: import java.awt.*;
import java.awt.event.*;
import static java.lang.Math.*;
import java.time.LocalTime;
import javax.swing.*;

class Clock extends JPanel {

    final float degrees06 = (float) (PI / 30);
    final float degrees30 = degrees06 * 5;
    final float degrees90 = degrees30 * 3;

    final int size = 590;
    final int spacing = 40;
    final int diameter = size - 2 * spacing;
    final int cx = diameter / 2 + spacing;
    final int cy = diameter / 2 + spacing;

    public Clock() {
        setPreferredSize(new Dimension(size, size));
        setBackground(Color.white);

        new Timer(1000, (ActionEvent e) -> {
            repaint();
        }).start();
    }

    @Override
    public void paintComponent(Graphics gg) {
        super.paintComponent(gg);
        Graphics2D g = (Graphics2D) gg;
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        drawFace(g);

        final LocalTime time  = LocalTime.now();
        int hour = time.getHour();
        int minute = time.getMinute();
        int second = time.getSecond();

        float angle = degrees90 - (degrees06 * second);
        drawHand(g, angle, diameter / 2 - 30, Color.red);

        float minsecs = (minute + second / 60.0F);
        angle = degrees90 - (degrees06 * minsecs);
        drawHand(g, angle, diameter / 3 + 10, Color.black);

        float hourmins = (hour + minsecs / 60.0F);
        angle = degrees90 - (degrees30 * hourmins);
        drawHand(g, angle, diameter / 4 + 10, Color.black);
    }

    private void drawFace(Graphics2D g) {
        g.setStroke(new BasicStroke(2));
        g.setColor(Color.white);
        g.fillOval(spacing, spacing, diameter, diameter);
        g.setColor(Color.black);
        g.drawOval(spacing, spacing, diameter, diameter);
    }

    private void drawHand(Graphics2D g, float angle, int radius, Color color) {
        int x = cx + (int) (radius * cos(angle));
        int y = cy - (int) (radius * sin(angle));
        g.setColor(color);
        g.drawLine(cx, cy, x, y);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setTitle("Clock");
            f.setResizable(false);
            f.add(new Clock(), BorderLayout.CENTER);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        });
    }
}



Python: last_sec = second()

def draw():
    global last_sec
    if last_sec != second():
        draw_clock()
        last_sec = second()

def draw_clock():
    background(192)
    translate(width / 2, height / 2)
    s = second() * TWO_PI / 60.0
    m = minute() * TWO_PI / 60.0
    h = hour() * TWO_PI / 12.0
    rotate(s)
    strokeWeight(1)
    line(0, 0, 0, -width * 0.5)
    rotate(-s + m)
    strokeWeight(2)
    line(0, 0, 0, -width * 0.4)
    rotate(-m + h)
    strokeWeight(4)
    line(0, 0, 0, -width * 0.2)
Task: Draw a clock




Go: package main

import (
	"golang.org/x/net/websocket"
	"flag"
	"fmt"
	"html/template"
	"io"
	"math"
	"net/http"
	"time"
)

var (
	Portnum  string
	Hostsite string
)

type PageSettings struct {
	Host string
	Port string
}

const (
	Canvaswidth  = 512
	Canvasheight = 512
	
	HourColor   = "#ff7373" 
	MinuteColor = "#00b7e4" 
	SecondColor = "#b58900" 
)

func main() {
	flag.StringVar(&Portnum, "Port", "1234", "Port to host server.")
	flag.StringVar(&Hostsite, "Site", "localhost", "Site hosting server")
	flag.Parse()
	http.HandleFunc("/", webhandler)
	http.Handle("/ws", websocket.Handler(wshandle))
	err := http.ListenAndServe(Hostsite+":"+Portnum, nil)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("server running")
}

func webhandler(w http.ResponseWriter, r *http.Request) {
	wsurl := PageSettings{Host: Hostsite, Port: Portnum}
	template, _ := template.ParseFiles("clock.html")
	template.Execute(w, wsurl)
}



func wshandle(ws *websocket.Conn) {
	for {
		hour, min, sec := time.Now().Clock()
		hourx, houry := HourCords(hour, Canvasheight/2)
		minx, miny := MinSecCords(min, Canvasheight/2)
		secx, secy := MinSecCords(sec, Canvasheight/2)
		msg := "CLEAR\n"
		msg += fmt.Sprintf("HOUR %d %d %s\n", hourx, houry, HourColor)
		msg += fmt.Sprintf("MIN %d %d %s\n", minx, miny, MinuteColor)
		msg += fmt.Sprintf("SEC %d %d %s", secx, secy, SecondColor)
		io.WriteString(ws, msg)
		time.Sleep(time.Second / 60.0)
	}
}



func MinSecCords(ctime int, radius int) (int, int) {
	

	theta := ((float64(ctime)*6 - 90) * (math.Pi / 180))
	x := float64(radius) * math.Cos(theta)
	y := float64(radius) * math.Sin(theta)
	return int(x) + 256, int(y) + 256
}



func HourCords(ctime int, radius int) (int, int) {
	
	theta := ((float64(ctime)*30 - 90) * (math.Pi / 180))
	x := float64(radius) * math.Cos(theta)
	y := float64(radius) * math.Sin(theta)
	return int(x) + 256, int(y) + 256
}




Python: last_sec = second()

def draw():
    global last_sec
    if last_sec != second():
        draw_clock()
        last_sec = second()

def draw_clock():
    background(192)
    translate(width / 2, height / 2)
    s = second() * TWO_PI / 60.0
    m = minute() * TWO_PI / 60.0
    h = hour() * TWO_PI / 12.0
    rotate(s)
    strokeWeight(1)
    line(0, 0, 0, -width * 0.5)
    rotate(-s + m)
    strokeWeight(2)
    line(0, 0, 0, -width * 0.4)
    rotate(-m + h)
    strokeWeight(4)
    line(0, 0, 0, -width * 0.2)
Task: Draw a clock




Go: package main

import (
	"golang.org/x/net/websocket"
	"flag"
	"fmt"
	"html/template"
	"io"
	"math"
	"net/http"
	"time"
)

var (
	Portnum  string
	Hostsite string
)

type PageSettings struct {
	Host string
	Port string
}

const (
	Canvaswidth  = 512
	Canvasheight = 512
	
	HourColor   = "#ff7373" 
	MinuteColor = "#00b7e4" 
	SecondColor = "#b58900" 
)

func main() {
	flag.StringVar(&Portnum, "Port", "1234", "Port to host server.")
	flag.StringVar(&Hostsite, "Site", "localhost", "Site hosting server")
	flag.Parse()
	http.HandleFunc("/", webhandler)
	http.Handle("/ws", websocket.Handler(wshandle))
	err := http.ListenAndServe(Hostsite+":"+Portnum, nil)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("server running")
}

func webhandler(w http.ResponseWriter, r *http.Request) {
	wsurl := PageSettings{Host: Hostsite, Port: Portnum}
	template, _ := template.ParseFiles("clock.html")
	template.Execute(w, wsurl)
}



func wshandle(ws *websocket.Conn) {
	for {
		hour, min, sec := time.Now().Clock()
		hourx, houry := HourCords(hour, Canvasheight/2)
		minx, miny := MinSecCords(min, Canvasheight/2)
		secx, secy := MinSecCords(sec, Canvasheight/2)
		msg := "CLEAR\n"
		msg += fmt.Sprintf("HOUR %d %d %s\n", hourx, houry, HourColor)
		msg += fmt.Sprintf("MIN %d %d %s\n", minx, miny, MinuteColor)
		msg += fmt.Sprintf("SEC %d %d %s", secx, secy, SecondColor)
		io.WriteString(ws, msg)
		time.Sleep(time.Second / 60.0)
	}
}



func MinSecCords(ctime int, radius int) (int, int) {
	

	theta := ((float64(ctime)*6 - 90) * (math.Pi / 180))
	x := float64(radius) * math.Cos(theta)
	y := float64(radius) * math.Sin(theta)
	return int(x) + 256, int(y) + 256
}



func HourCords(ctime int, radius int) (int, int) {
	
	theta := ((float64(ctime)*30 - 90) * (math.Pi / 180))
	x := float64(radius) * math.Cos(theta)
	y := float64(radius) * math.Sin(theta)
	return int(x) + 256, int(y) + 256
}





VB: 


ans0=chr(27)&"["
sub cls()  wscript.StdOut.Write ans0 &"2J"&ans0 &"?25l":end sub
sub torc(r,c,s)  wscript.StdOut.Write ans0 & r & ";" & c & "f"  & s :end sub


Sub draw_line(r1,c1, r2,c2,c)
  Dim x,y,xf,yf,dx,dy,sx,sy,err,err2
  x =r1    : y =c1
  xf=r2    : yf=c2
  dx=Abs(xf-x) : dy=Abs(yf-y)
  If x<xf Then sx=+1: Else sx=-1
  If y<yf Then sy=+1: Else sy=-1
  err=dx-dy
  Do
    torc x,y,c
    If x=xf And y=yf Then Exit Do
    err2=err+err
    If err2>-dy Then err=err-dy: x=x+sx
    If err2< dx Then err=err+dx: y=y+sy
  Loop
End Sub 

const pi180=0.017453292519943

const r0=13
const c0=26


nangi=-30*pi180
aangi=-6*pi180
ang0=90*pi180


lh=7
lm=9
ls=9
ln=12


while 1
     cls

    
    angn=ang0+nangi
    for i=1 to 12
      torc r0-cint(ln*sin(angn)),cint(c0+2*ln*cos(angn)),i
      angn=angn+nangi 
    next 

    
    t=now()
    torc 1,1, hour(t) &":"& minute(t) &":"& second(t) 
    
    
    angh=ang0+hour(t) *nangi
    angm=ang0+minute(t) *aangi
    angS=ang0+second(t) *aangi

    
    draw_line r0,c0,cint(r0-ls*sin(angs)),cint(c0+2*ls*cos(angs)),"."
    draw_line r0,c0,cint(r0-lm*sin(angm)),cint(c0+2*lm*cos(angm)),"*"
    draw_line r0,c0,cint(r0-lh*sin(angh)),cint(c0+2*lh*cos(angh)),"W"
    torc r0,c0,"O"
    
    
    wscript.sleep(1000)
wend
Task: Draw a clock







Python: last_sec = second()

def draw():
    global last_sec
    if last_sec != second():
        draw_clock()
        last_sec = second()

def draw_clock():
    background(192)
    translate(width / 2, height / 2)
    s = second() * TWO_PI / 60.0
    m = minute() * TWO_PI / 60.0
    h = hour() * TWO_PI / 12.0
    rotate(s)
    strokeWeight(1)
    line(0, 0, 0, -width * 0.5)
    rotate(-s + m)
    strokeWeight(2)
    line(0, 0, 0, -width * 0.4)
    rotate(-m + h)
    strokeWeight(4)
    line(0, 0, 0, -width * 0.2)


VB: 


ans0=chr(27)&"["
sub cls()  wscript.StdOut.Write ans0 &"2J"&ans0 &"?25l":end sub
sub torc(r,c,s)  wscript.StdOut.Write ans0 & r & ";" & c & "f"  & s :end sub


Sub draw_line(r1,c1, r2,c2,c)
  Dim x,y,xf,yf,dx,dy,sx,sy,err,err2
  x =r1    : y =c1
  xf=r2    : yf=c2
  dx=Abs(xf-x) : dy=Abs(yf-y)
  If x<xf Then sx=+1: Else sx=-1
  If y<yf Then sy=+1: Else sy=-1
  err=dx-dy
  Do
    torc x,y,c
    If x=xf And y=yf Then Exit Do
    err2=err+err
    If err2>-dy Then err=err-dy: x=x+sx
    If err2< dx Then err=err+dx: y=y+sy
  Loop
End Sub 

const pi180=0.017453292519943

const r0=13
const c0=26


nangi=-30*pi180
aangi=-6*pi180
ang0=90*pi180


lh=7
lm=9
ls=9
ln=12


while 1
     cls

    
    angn=ang0+nangi
    for i=1 to 12
      torc r0-cint(ln*sin(angn)),cint(c0+2*ln*cos(angn)),i
      angn=angn+nangi 
    next 

    
    t=now()
    torc 1,1, hour(t) &":"& minute(t) &":"& second(t) 
    
    
    angh=ang0+hour(t) *nangi
    angm=ang0+minute(t) *aangi
    angS=ang0+second(t) *aangi

    
    draw_line r0,c0,cint(r0-ls*sin(angs)),cint(c0+2*ls*cos(angs)),"."
    draw_line r0,c0,cint(r0-lm*sin(angm)),cint(c0+2*lm*cos(angm)),"*"
    draw_line r0,c0,cint(r0-lh*sin(angh)),cint(c0+2*lh*cos(angh)),"W"
    torc r0,c0,"O"
    
    
    wscript.sleep(1000)
wend