Last active
December 18, 2015 20:07
-
-
Save kunjee17/6965af56a3821ad2d850 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#r @"..\packages\FSharp.Charting.0.90.13\lib\net40\FSharp.Charting.dll" | |
#load "..\packages\FSharp.Charting.0.90.13\FSharp.Charting.fsx" | |
open System | |
open FSharp.Charting | |
open System.Windows.Forms | |
open System.Drawing | |
let posNum = seq {1..101} | |
let cube x = x * x * x | |
let cubeposNum = | |
posNum | |
|> Seq.map (fun x -> (x, cube x)) | |
let totalCombination = | |
cubeposNum | |
|> Seq.map (fun (a,b) -> cubeposNum |> Seq.map (fun (x,y) -> (a,x,b+y))) | |
|> Seq.concat | |
let finalResult = | |
totalCombination | |
|> Seq.countBy (fun (x,y,z) -> z) | |
|> Seq.filter (fun (x,y) -> y >= 4) | |
|> Seq.map (fun (x,y) -> x) | |
let dirtyHack (inputSeq)= | |
let a = inputSeq |> Seq.item 0 | |
let b = inputSeq |> Seq.item 1 | |
let c = inputSeq |> Seq.item 2 | |
(a, b, c) | |
let pairValues = | |
finalResult | |
|> Seq.map (fun x -> totalCombination |> Seq.filter (fun (a,b,c) -> c = x )) | |
|> Seq.map (fun a -> a |> Seq.map (fun (x,y,z) -> seq[x;y;z] |> Seq.sort |> dirtyHack)) | |
|> Seq.map (fun x -> x |> Seq.distinct) | |
//form crazyness - a copy paste from 2010 code :P | |
let form = new Form(Visible = true, Text = "A Simple F# Form", | |
TopMost = true, Size = Size(600,600)) | |
let data = new DataGridView(Dock = DockStyle.Fill, Text = "Hardy–Ramanujan number", | |
Font = new Font("Lucida Console",12.0f), | |
ForeColor = Color.DarkBlue | |
) | |
form.Controls.Add(data) | |
data.DataSource <- (pairValues |> Seq.concat |> Seq.sortBy (fun (x,y,z) -> z) |> Seq.toArray) | |
data.Columns.[0].Width <- 200 | |
data.Columns.[1].Width <- 200 | |
data.Columns.[2].Width <- 200 | |
data.Columns.[0].HeaderText <- "a" | |
data.Columns.[1].HeaderText <- "b" | |
data.Columns.[2].HeaderText <- "(a^3 + b^3)" | |
//Charting | |
let taxicabnumbers = pairValues | |
|> Seq.concat | |
|> Seq.sortBy (fun (x,y,z) -> z) | |
|> Seq.map (fun (x,y,z) -> z) | |
|> Seq.distinct | |
Chart.Point (taxicabnumbers,"TaxiCabNumbers","TaxiCab Number") | |
let taxicabnumbersX = pairValues | |
|> Seq.concat | |
|> Seq.sortBy (fun (x,y,z) -> z) | |
|> Seq.map (fun (x,y,z) -> (x,z)) | |
Chart.Point (taxicabnumbersX,"TaxiCabNumbersX","TaxiCab Number in ref to X") | |
let taxicabnumbersY = pairValues | |
|> Seq.concat | |
|> Seq.sortBy (fun (x,y,z) -> z) | |
|> Seq.map (fun (x,y,z) -> (y,z)) | |
Chart.Point (taxicabnumbersY,"TaxiCabNumbersY","TaxiCab Number in ref to Y") | |
Chart.Combine[ | |
Chart.Point(taxicabnumbersX, "TaxiCabNumbersX") | |
Chart.Point(taxicabnumbersY, "TaxiCabNumbersY") | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couldn't fit it in a tweet, so far I have