### Add solution for 22/2

Created by  voroskoi  on January 1, 2022
`IYFLF64GJANEA4PEGDP76SJ7JAPV4SOR5GWGDCDY2QUK3FMHLN6AC`
##### In channels main
##### Change contents
• ###### Replacement in 22/main.go at line 12 [2.47]
B:BD[2.128] → [2.128:169]
``const (``	rangeMin = -50``	rangeMax = 50``)``
[2.128]
[2.169]
``type cuboid struct {``	state      string``	xmin, xmax int``	ymin, ymax int``	zmin, zmax int``}``
• ###### Insertion in 22/main.go at line 32 [2.47]
[2.366]
[2.366]
``	log.Println(solveSecond(cbs))``
• ###### Replacement in 22/main.go at line 41 [2.47]
B:BD[2.418] → [2.418:453]
``func solveFirst(cbs cuboids) int {``
[2.418]
[2.453]
``func solveFirst(cbs []cuboid) int {``	const (``		rangeMin = -50``		rangeMax = 50``	)``
• ###### Insertion in 22/main.go at line 67 [2.47]
[2.975]
[2.975]
``type subcubes map[cuboid]int``func solveSecond(cbs []cuboid) int {``	m := subcubes{}``	for _, cube := range cbs {``		subMap := subcubes{}``		for orig := range m {``			ovrlp := overlap(cube, orig)``			if ovrlp.state == "noop" {``				continue``			}``			// do not count repeatedly the overlapping part``			// m[orig] can be 0, -1 and 1.``			// 0 means it was an "off" state``			// if it was 1, now we change it to -1, so adding a new cube with``			// state = "on" will change it to 0.``			subMap[ovrlp] -= m[orig]``		}``		if cube.state == "on" {``			subMap[cube] += 1``		}``		for c := range subMap {``			m[c] += subMap[c]``		}``	}``	var sum int``	for cube, v := range m {``		sum += cube.size() * v``	}``	return sum``}``func (c cuboid) size() int {``	return (c.xmax - c.xmin + 1) * (c.ymax - c.ymin + 1) * (c.zmax - c.zmin + 1)``}``func overlap(first, second cuboid) cuboid {``	// return none, if there is no overlap in one of the dimensions``	if first.xmax < second.xmin || second.xmax < first.xmin ||``		first.ymax < second.ymin || second.ymax < first.ymin ||``		first.zmax < second.zmin || second.zmax < first.zmin {``		return cuboid{state: "noop"}``	}``	return cuboid{"",``		max(first.xmin, second.xmin), min(first.xmax, second.xmax),``		max(first.ymin, second.ymin), min(first.ymax, second.ymax),``		max(first.zmin, second.zmin), min(first.zmax, second.zmax),``	}``}``
• ###### Replacement in 22/main.go at line 136 [2.47]
B:BD[2.1103] → [2.1103:1287]
``type cuboid struct {``	state      string``	xmin, xmax int``	ymin, ymax int``	zmin, zmax int``}``type cuboids []cuboid``func parseInput(fileName string) (cuboids, error) {``	ret := cuboids{}``
[2.1103]
[2.1287]
``func parseInput(fileName string) ([]cuboid, error) {``	ret := []cuboid{}``