Skip to content

Instantly share code, notes, and snippets.

View IltaySaeedi's full-sized avatar

Iltay Saeedi IltaySaeedi

View GitHub Profile
@IltaySaeedi
IltaySaeedi / Resistor.fs
Created May 6, 2023 15:19
Finding resistor value
namespace Resistor
type ResistorColors =
| Black
| Brown
| Red
| Orange
| Yellow
| Green
| Blue
@IltaySaeedi
IltaySaeedi / crc32b.fsx
Created December 5, 2021 09:02
computes CRC32B of list of bytes using Table lookUp
/// <summary>
/// A four-byte CRC (Cyclic Redundancy Code)
/// calculated on the preceding bytes in the chunk,
/// including the chunk type field and chunk data fields,
/// but not including the length field.
///
/// The CRC can be used to check for corruption of the data.
/// The CRC is always present, even for chunks containing no data.
/// </summary>
module CRC32B =
#r "nuget: ply"
open System
open FSharp.Control.Tasks
open System.Threading.Tasks
let bigEndianUInt32 (data : Span<byte>) =
let mutable total = 0u
if data.Length = 4 then
for i = 0 to 3 do
let value = data.[i]
@IltaySaeedi
IltaySaeedi / ItemsAndBucket.fsx
Last active July 25, 2021 06:51
Adding Items to bucket
type Item =
{ Name : string
Quantity : uint }
type Items = Item list
type Bucket =
| Items of Items
| Empty
| InvalidItemName
@IltaySaeedi
IltaySaeedi / TransportationProblem.fsx
Created May 6, 2021 14:08
This is my first exprience with Linear Programming, I tried to solve a transportation problem by using Flips package.
#r "nuget: Flips, 2.4.5"
open Flips
open Flips.Types
// مساله حمل و نقل
// مساله: 2 کارخانه با ظرفیت های تولید کالای معین به 3 انبار کالاهای
// خود را ارسال می کنند تا تقاضای انبارها تامین شود نه بیشتر نه کمتر
// با توجه به هزینه هایی که رفت آمد در پی دارد بیابید که
// هر کارخانه به چه مقدار و به کدام انبار اجناس خود را ارسال کند
// تا کمترین هزینه ی رفت و آمد را داشته باشیم