#!/usr/bin/perl

print "Calculating...\n";

$c = 0;			# Counter
$t = 10000;		# Number of Trials

for($d = 0; $d < $t; $d++){
  $x = rand;
  $y = $x + rand(1 - $x);
  if($x < 0.5 and $y > 0.5 and ($y - $x) < 0.5){
    $c++
    }
  }
$p = ($c / $t) * 100;	# Percentage of tries

print "Result: $p%\n";
