Skip to content

Instantly share code, notes, and snippets.

View vba's full-sized avatar

Victor Mikhaïlovitch Bartel vba

View GitHub Profile
let fusionNeighbours (accumulator: int Set list) (neighbour: int Set) =
match accumulator with
| [] -> [neighbour]
| head :: tail ->
let intersect = neighbour |> Set.intersect
match (head |> intersect).Count with
| 2 -> (head |> (Set.union neighbour)) :: tail
| _ -> neighbour :: accumulator
let collection = [

Technical exercise explanation

First of all I would like to apologize for the delay. It took me ~3 hours instead of 2, because I was interrupted several times, first time by unexpected call of a head hunter, just when I've started and then by my kids.

I chose TypeScript because I was a bit mistaken in the first place, for your initial google form says that we can choose any language of our choice and a second one precises that it should be Scala if possible. It was too late to change when I've started. I expected to have an exercise with a web based editor, kind of codility.com. If you ever tried their Scala editor you will understand why people choosing javascript for solving their tasks.

If you have any doubt about my ability to write Scala, you can check one of my earlier topics.

Reeking code

type Wheat = {wheat:string}
type Flour = {flour:string}
type Dough = {dough:string}
type Bread = {bread:string}
module SimpleComposition =
let grind (w:Wheat) =
printfn "make the flour"
object SimpleComposition {
case class Wheat()
case class Flour()
case class Dough()
case class Bread()
def grind: (Wheat => Flour) = w => {
println("make the flour"); Flour()
}