Skip to content

Instantly share code, notes, and snippets.

View chuongmep's full-sized avatar
👋
Loading...

Chuong Ho chuongmep

👋
Loading...
View GitHub Profile
// create a list of fruits
List<string> fruits = new List<string> { "apple", "banana", "cherry", "banana", "apple", "cherry", "apple" };
// get unique values of fruits
List<string> uniqueFruits = fruits.Distinct().ToList();
// create a dictionary to hold one-hot encoded values
Dictionary<string, List<int>> oneHotEncoded = new Dictionary<string, List<int>>();
// loop over each unique fruit
using System;
void Main()
{
BellmanFord bf = new BellmanFord(5, 8);
bf.AddEdge(0, 1, 6);
bf.AddEdge(0, 3, 7);
bf.AddEdge(1, 2, 5);
bf.AddEdge(1, 3, 8);
bf.AddEdge(1, 4, -4);
bf.AddEdge(2, 1, -2);
public static Autodesk.DesignScript.Geometry.Point GaussianTrianglePick(Autodesk.DesignScript.Geometry.Point v1,
Autodesk.DesignScript.Geometry.Point v2, Autodesk.DesignScript.Geometry.Point v3, double sigma)
{
// Calculate the areas of the three sub-triangles
double a1 = 0.5 * v2.DistanceTo(v3);
double a2 = 0.5 * v3.DistanceTo(v1);
double a3 = 0.5 * v1.DistanceTo(v2);
// Calculate the total area of the triangle
double totalArea = a1 + a2 + a3;
{
"Uuid": "f5aaaa57-5af0-4afc-8e7d-f31488266d8e",
"IsCustomNode": false,
"Description": "",
"Name": "PipeAngleAxis",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
{
"Uuid": "566461d1-cf9f-46bf-ad39-972c2548937d",
"IsCustomNode": false,
"Description": "",
"Name": "VectorAngleAxisChangedVector2",
"ElementResolver": {
"ResolutionMap": {
"Math": {
"Key": "DSCore.Math",
"Value": "DSCoreNodes.dll"
{
"Uuid": "ae6cce42-a991-401d-8914-6b4734887fe2",
"IsCustomNode": false,
"Description": "",
"Name": "VectorAngleAxis",
"ElementResolver": {
"ResolutionMap": {
"Math": {
"Key": "DSCore.Math",
"Value": "DSCoreNodes.dll"
using System;
void Main()
{
// define the cost matrix
int[,] costMatrix = {{17, 10, 21},
{15, 12, 19},
{13, 10, 17}};
int numRows = costMatrix.GetLength(0);
int numCols = costMatrix.GetLength(1);
void Main()
{
// Example cost matrix
int[,] matrix = {{7, 0, 8},
{15, 2, 7},
{5, 3, 5}};
int n = matrix.GetLength(0);
int[] permutation = new int[n];
for (int i = 0; i < n; i++)
void Main()
{
double x1 = 10;
double y1 = 10;
double z1 = 10;
double x2 = 10;
double y2 = 10;
double z2 = 10;
var point1 = new ComparePoint(x1,y1,z1);
A = ["element1","Alement 5", "Clement3", "Blement 4", "element 2"]
# regex sort string by alphabet last number increase
A = sorted(A, key=lambda x: (re.findall(r'\D+', x)[-1], int(re.findall(r'\d+', x)[-1])))
OUT = A