Skip to main content
Ayb4btu algo
Source Link
aloisdg
  • 2.1k
  • 17
  • 26

F# (.NET Core), 117 115 114 111111 108 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 111 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter((=)a)|>Seq.length=1)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

6 byte won thanks to prefix notation!

108 bytes

let f a b=Set.intersect(set a)(set b)|>Seq.filter(fun x->a@b|>Seq.filter(fun y->y=x)|>Seq.length<3)|>Seq.max

@ is the concat function! Thank you @Ayb4btu for this algorithm.

Try it online!

F# (.NET Core), 117 115 114 111 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 111 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter((=)a)|>Seq.length=1)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

6 byte won thanks to prefix notation!

F# (.NET Core), 117 115 114 111 108 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 111 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter((=)a)|>Seq.length=1)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

6 byte won thanks to prefix notation!

108 bytes

let f a b=Set.intersect(set a)(set b)|>Seq.filter(fun x->a@b|>Seq.filter(fun y->y=x)|>Seq.length<3)|>Seq.max

@ is the concat function! Thank you @Ayb4btu for this algorithm.

Try it online!

added 56 characters in body
Source Link
aloisdg
  • 2.1k
  • 17
  • 26

F# (.NET Core), 117 115 114114 111 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117117 111 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter(fun b->b=a(=)a)|>Seq.length<2length=1)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

6 byte won thanks to prefix notation!

F# (.NET Core), 117 115 114 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter(fun b->b=a)|>Seq.length<2)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

F# (.NET Core), 117 115 114 111 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 111 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter((=)a)|>Seq.length=1)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

6 byte won thanks to prefix notation!

space
Source Link
aloisdg
  • 2.1k
  • 17
  • 26

F# (.NET Core), 117117 115 114 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter(fun b->b=a)|>Seq.length<2)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

F# (.NET Core), 117 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter(fun b->b=a)|>Seq.length<2)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

F# (.NET Core), 117 115 114 bytes

115 114 bytes

Another solution with countBy this time:

let u x=x|>Seq.countBy id|>Seq.filter(fun a->snd a=1)|>Seq.map fst|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

117 bytes

let u x=x|>Seq.filter(fun a->x|>Seq.filter(fun b->b=a)|>Seq.length<2)|>set
let f x y=Set.intersect(u x)(u y)|>Seq.max

Try it online!

100% F#! Any help is welcome!

Source Link
aloisdg
  • 2.1k
  • 17
  • 26
Loading