kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Monty Hall problem
C#: using System;

class Program
{
    static void Main(string[] args)
    {
        int switchWins = 0;
        int stayWins = 0;

        Random gen = new Random();
		    
        for(int plays = 0; plays < 1000000; plays++ )
        {
            int[] doors = {0,0,0};

            var winner = gen.Next(3);
            doors[winner] = 1; 
                
	    int choice = gen.Next(3); 
	    int shown; 
	    do
            {
	        shown = gen.Next(3);
	    }
            while (doors[shown] == 1 || shown == choice); 
     
	    stayWins += doors[choice]; 
     
            
            switchWins += doors[3 - choice - shown];
        }

        Console.Out.WriteLine("Staying wins " + stayWins + " times.");
        Console.Out.WriteLine("Switching wins " + switchWins + " times.");
    }
}

PHP: <?php
function montyhall($iterations){
	$switch_win = 0;
	$stay_win = 0;
		
	foreach (range(1, $iterations) as $i){
		$doors = array(0, 0, 0);
		$doors[array_rand($doors)] = 1;
		$choice = array_rand($doors);
		do {
			$shown = array_rand($doors);
		} while($shown == $choice || $doors[$shown] == 1);
			
		$stay_win += $doors[$choice];
		$switch_win += $doors[3 - $choice - $shown];
	}
		
	$stay_percentages = ($stay_win/$iterations)*100;
	$switch_percentages = ($switch_win/$iterations)*100;
		
	echo "Iterations: {$iterations} - ";
	echo "Stayed wins: {$stay_win} ({$stay_percentages}%) - ";
	echo "Switched wins: {$switch_win} ({$switch_percentages}%)";
}
	
        montyhall(10000);
?>
Task: Monty Hall problem
C++: #include <iostream>
#include <cstdlib>
#include <ctime>
 
int randint(int n)
{
  return (1.0*n*std::rand())/(1.0+RAND_MAX);
}

int other(int doorA, int doorB)
{
  int doorC;
  if (doorA == doorB)
  {
    doorC = randint(2);
    if (doorC >= doorA)
      ++doorC;
  }
  else
  {
    for (doorC = 0; doorC == doorA || doorC == doorB; ++doorC)
    {
      
    }
  }
  return doorC;
}

int check(int games, bool change)
{
  int win_count = 0;
  for (int game = 0; game < games; ++game)
  {
    int const winning_door = randint(3);
    int const original_choice = randint(3);
    int open_door = other(original_choice, winning_door);

    int const selected_door = change?
                                other(open_door, original_choice)
                              : original_choice;

    if (selected_door == winning_door)
      ++win_count;
  }
 
  return win_count;
}
 
int main()
{
  std::srand(std::time(0));

  int games = 10000;
  int wins_stay = check(games, false);
  int wins_change = check(games, true);
  std::cout << "staying: " << 100.0*wins_stay/games << "%, changing: " << 100.0*wins_change/games << "%\n";
}

PHP: <?php
function montyhall($iterations){
	$switch_win = 0;
	$stay_win = 0;
		
	foreach (range(1, $iterations) as $i){
		$doors = array(0, 0, 0);
		$doors[array_rand($doors)] = 1;
		$choice = array_rand($doors);
		do {
			$shown = array_rand($doors);
		} while($shown == $choice || $doors[$shown] == 1);
			
		$stay_win += $doors[$choice];
		$switch_win += $doors[3 - $choice - $shown];
	}
		
	$stay_percentages = ($stay_win/$iterations)*100;
	$switch_percentages = ($switch_win/$iterations)*100;
		
	echo "Iterations: {$iterations} - ";
	echo "Stayed wins: {$stay_win} ({$stay_percentages}%) - ";
	echo "Switched wins: {$switch_win} ({$switch_percentages}%)";
}
	
        montyhall(10000);
?>
Task: Monty Hall problem
Go: package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	games := 100000
	r := rand.New(rand.NewSource(time.Now().UnixNano()))

	var switcherWins, keeperWins, shown int
	for i := 0; i < games; i++ {
		doors := []int{0, 0, 0}
		doors[r.Intn(3)] = 1 
		choice := r.Intn(3) 
		for shown = r.Intn(3); shown == choice || doors[shown] == 1; shown = r.Intn(3) {}
		switcherWins += doors[3 - choice - shown]
		keeperWins += doors[choice]
	}
	floatGames := float32(games)
	fmt.Printf("Switcher Wins: %d (%3.2f%%)\n",
		switcherWins, (float32(switcherWins) / floatGames * 100))
	fmt.Printf("Keeper Wins: %d (%3.2f%%)",
		keeperWins, (float32(keeperWins) / floatGames * 100))
}

PHP: <?php
function montyhall($iterations){
	$switch_win = 0;
	$stay_win = 0;
		
	foreach (range(1, $iterations) as $i){
		$doors = array(0, 0, 0);
		$doors[array_rand($doors)] = 1;
		$choice = array_rand($doors);
		do {
			$shown = array_rand($doors);
		} while($shown == $choice || $doors[$shown] == 1);
			
		$stay_win += $doors[$choice];
		$switch_win += $doors[3 - $choice - $shown];
	}
		
	$stay_percentages = ($stay_win/$iterations)*100;
	$switch_percentages = ($switch_win/$iterations)*100;
		
	echo "Iterations: {$iterations} - ";
	echo "Stayed wins: {$stay_win} ({$stay_percentages}%) - ";
	echo "Switched wins: {$switch_win} ({$switch_percentages}%)";
}
	
        montyhall(10000);
?>
Task: Monty Hall problem
Java: import java.util.Random;
public class Monty{
	public static void main(String[] args){
		int switchWins = 0;
		int stayWins = 0;
		Random gen = new Random();
		for(int plays = 0;plays < 32768;plays++ ){
			int[] doors = {0,0,0};
			doors[gen.nextInt(3)] = 1;
			int choice = gen.nextInt(3); 
			int shown; 
			do{
				shown = gen.nextInt(3);
			
			}while(doors[shown] == 1 || shown == choice);
			
			stayWins += doors[choice];
			
			
			switchWins += doors[3 - choice - shown];
		}
		System.out.println("Switching wins " + switchWins + " times.");
		System.out.println("Staying wins " + stayWins + " times.");
	}
}

PHP: <?php
function montyhall($iterations){
	$switch_win = 0;
	$stay_win = 0;
		
	foreach (range(1, $iterations) as $i){
		$doors = array(0, 0, 0);
		$doors[array_rand($doors)] = 1;
		$choice = array_rand($doors);
		do {
			$shown = array_rand($doors);
		} while($shown == $choice || $doors[$shown] == 1);
			
		$stay_win += $doors[$choice];
		$switch_win += $doors[3 - $choice - $shown];
	}
		
	$stay_percentages = ($stay_win/$iterations)*100;
	$switch_percentages = ($switch_win/$iterations)*100;
		
	echo "Iterations: {$iterations} - ";
	echo "Stayed wins: {$stay_win} ({$stay_percentages}%) - ";
	echo "Switched wins: {$switch_win} ({$switch_percentages}%)";
}
	
        montyhall(10000);
?>
Task: Monty Hall problem
Python: 
from random import randrange

doors, iterations = 3,100000  

def monty_hall(choice, switch=False, doorCount=doors):
  
  door = [False]*doorCount
  
  door[randrange(doorCount)] = True

  chosen = door[choice]

  unpicked = door
  del unpicked[choice]

  
  
  
  alternative = True in unpicked

  if switch:
    return alternative
  else:
    return chosen

print "\nMonty Hall problem simulation:"
print doors, "doors,", iterations, "iterations.\n"

print "Not switching allows you to win",
print sum(monty_hall(randrange(3), switch=False)
          for x in range(iterations)),
print "out of", iterations, "times."
print "Switching allows you to win",
print sum(monty_hall(randrange(3), switch=True)
          for x in range(iterations)),
print "out of", iterations, "times.\n"

PHP: <?php
function montyhall($iterations){
	$switch_win = 0;
	$stay_win = 0;
		
	foreach (range(1, $iterations) as $i){
		$doors = array(0, 0, 0);
		$doors[array_rand($doors)] = 1;
		$choice = array_rand($doors);
		do {
			$shown = array_rand($doors);
		} while($shown == $choice || $doors[$shown] == 1);
			
		$stay_win += $doors[$choice];
		$switch_win += $doors[3 - $choice - $shown];
	}
		
	$stay_percentages = ($stay_win/$iterations)*100;
	$switch_percentages = ($switch_win/$iterations)*100;
		
	echo "Iterations: {$iterations} - ";
	echo "Stayed wins: {$stay_win} ({$stay_percentages}%) - ";
	echo "Switched wins: {$switch_win} ({$switch_percentages}%)";
}
	
        montyhall(10000);
?>
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

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

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}

Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}
Task: Color of a screen pixel
C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}

Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}
Task: Color of a screen pixel
C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
C#: using System;
using System.Drawing;
using System.Windows.Forms;

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}

Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}
Task: Color of a screen pixel
C#: using System;
using System.Drawing;
using System.Windows.Forms;

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}

Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))
Task: Color of a screen pixel
Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}

Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))
Task: Color of a screen pixel
Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}

Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))
Task: Color of a screen pixel
Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
C#: using System;
using System.Drawing;
using System.Windows.Forms;

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}

Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}
Task: Color of a screen pixel
C#: using System;
using System.Drawing;
using System.Windows.Forms;

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}

Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}
Task: Color of a screen pixel
Java: public static Color getColorAt(int x, int y){
   return new Robot().getPixelColor(x, y);
}

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
Go: package main

import (
    "fmt"
    "github.com/go-vgo/robotgo"
)

func main() {
    
    x, y := robotgo.GetMousePos()

    
    color := robotgo.GetPixelColor(x, y)
    fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)   
}

VB:   Private Function GetPixelColor(ByVal Location As Point) As Color

    Dim b As New Bitmap(1, 1)
    Dim g As Graphics = Graphics.FromImage(b)

    g.CopyFromScreen(Location, Point.Empty, New Size(1, 1))

    Return b.GetPixel(0, 0)

  End Function
Task: Color of a screen pixel
C#: using System;
using System.Drawing;
using System.Windows.Forms;

class Program
{
    static Color GetPixel(Point position)
    {
        using (var bitmap = new Bitmap(1, 1))
        {
            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
            }
            return bitmap.GetPixel(0, 0);
        }
    }

    static void Main()
    {
        Console.WriteLine(GetPixel(Cursor.Position));
    }
}

C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}
Task: Color of a screen pixel
C++: using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main()
{
	Point^ MousePoint = gcnew Point();
	Control^ TempControl = gcnew Control();
	MousePoint = TempControl->MousePosition;
	Bitmap^ TempBitmap = gcnew Bitmap(1,1);
	Graphics^ g = Graphics::FromImage(TempBitmap);	
	g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1));
	Color color = TempBitmap->GetPixel(0,0);
	Console::WriteLine("R: "+color.R.ToString());
	Console::WriteLine("G: "+color.G.ToString());
	Console::WriteLine("B: "+color.B.ToString());
}

Python: def get_pixel_colour(i_x, i_y):
	import win32gui
	i_desktop_window_id = win32gui.GetDesktopWindow()
	i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
	long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
	i_colour = int(long_colour)
	win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
	return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)

print (get_pixel_colour(0, 0))
Task: Color of a screen pixel
C: #include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
  XImage *image;
  image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
  color->pixel = XGetPixel (image, 0, 0);
  XFree (image);
  XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color);
}


XColor c;
get_pixel_color (display, 30, 40, &c);
printf ("%d %d %d\n", c.red, c.green, c.blue);

PHP: $img = imagegrabscreen();
$color = imagecolorat($im, 10, 50);
imagedestroy($im);