This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void PackRectanglesModify(List<PackedRectangle> rectangles) | |
{ | |
rectangles.Sort | |
( | |
Comparing.CreateComparer<PackedRectangle, double> | |
( | |
rect => rect.Rectangle.Size.X * rect.Rectangle.Size.Y | |
) | |
); | |
rectangles.Reverse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type IRectangle = | |
abstract member X : double with get, set | |
abstract member Y : double with get, set | |
abstract member Width : double | |
abstract member Height : double | |
abstract member Id : int | |
type internal Spot(x: double, y: double, width: double, height: double) = | |
member this.x = x | |
member this.y = y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var rand = new Random(); | |
int success = 0; | |
for (int i = 0; i < 100000; ++i) | |
{ | |
var arr = Shuffle(new List<int> { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }); | |
int sum = 0; | |
for (int j = 0; j < 3; ++j) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Vector4 HSVToRGB(float hue, float saturation, float value, float alpha) | |
{ | |
Func<float, float> helper = (x) => | |
{ | |
float lowerBound = value * (1 - saturation); | |
float delta = value - lowerBound; | |
while (x < 0) x += 360; | |
x = x % 360; | |
return lowerBound + (float)((Math.Floor(x / 180) * value) + Math.Floor(((Math.Floor(x / 60) % 3) / 2)) * (x % 60) * (delta / 60F) * Math.Pow(-1, Math.Floor(x / 180))); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
#include <string.h> | |
#define DEBUG | |
#ifdef DEBUG | |
#define PRINT(...) printf(__VA_ARGS__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Visibility where | |
import Data.List (sortBy, minimumBy) | |
import Data.Ord | |
import Data.Maybe (mapMaybe) | |
import Diagrams (Diagram, P2, (#), Located) | |
import qualified Diagrams as Diag | |
import Diagrams.Backend.Rasterific (Rasterific) | |
import qualified Diagrams.Backend.Rasterific as Rast | |
import Data.Colour (Colour) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Node = Value Int | List [Node] | Sequence [Node] | |
steps :: Node -> [[Int]] | |
steps (Value x) = [[x]] | |
steps (List ns) = case substeps of | |
[] -> [] | |
(x : xs) -> x ++ concat (zipWith prepend lastStates xs) | |
where substeps = map steps ns | |
lastStates = scanl1 (++) $ map last substeps | |
prepend pref ss = map (pref ++) ss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box :: Bool -> Angle Double -> Diagram SVG | |
box on angle = ((square (sqrt 2) `clipTo` rotate angle pattern) <> base) # lwO 1.5 | |
where base = square (sqrt 2) # fc (if on then peachpuff else turquoise) | |
chromosome :: [Bool] -> Angle Double -> Diagram SVG | |
chromosome list angle = hcat $ map (pad 1.1 . (`box` angle)) list | |
first :: Diagram SVG | |
first = chromosome [True, False, True] (1/8 @@ turn) | |
||| padX 1.3 (chromosome [True, False] (1/8 @@ turn)) |