File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 402402 }
403403 ]
404404 },
405+ {
406+ "cell_type" : " code" ,
407+ "execution_count" : 1 ,
408+ "metadata" : {},
409+ "source" : [
410+ " #!fsharp\n " ,
411+ " #load \" day06.fsx\"\n " ,
412+ " open Day06\n " ,
413+ " \n " ,
414+ " let testData06 = [\n " ,
415+ " \" abc\"\n " ,
416+ " \"\"\n " ,
417+ " \" a\"\n " ,
418+ " \" b\"\n " ,
419+ " \" c\"\n " ,
420+ " \"\"\n " ,
421+ " \" ab\"\n " ,
422+ " \" ac\"\n " ,
423+ " \"\"\n " ,
424+ " \" a\"\n " ,
425+ " \" a\"\n " ,
426+ " \" a\"\n " ,
427+ " \" a\"\n " ,
428+ " \"\"\n " ,
429+ " \" b\"\n " ,
430+ " ]\n " ,
431+ " \n " ,
432+ " // testData06\n " ,
433+ " readLines \" 06\"\n " ,
434+ " |> day06\n " ,
435+ " |> printf \" %A\" "
436+ ],
437+ "outputs" : [
438+ {
439+ "output_type" : " execute_result" ,
440+ "data" : {
441+ "text/plain" : " 6504"
442+ },
443+ "execution_count" : 1 ,
444+ "metadata" : {}
445+ }
446+ ]
447+ },
405448 {
406449 "cell_type" : " code" ,
407450 "execution_count" : 1 ,
Original file line number Diff line number Diff line change 1+ let day06 ( arr : seq < string >) =
2+ seq {
3+ let mutable cSet = Set.empty< char>
4+ for x in arr do
5+ match x.Length with
6+ | 0 ->
7+ yield cSet
8+ cSet <- Set.empty< char>
9+ | _ -> cSet <- x.ToCharArray() |> Set.ofArray |> ( Set.union cSet)
10+ yield cSet
11+ }
12+ |> Seq.map Set.count
13+ |> Seq.sum
14+
15+
16+
You can’t perform that action at this time.
0 commit comments