### 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{}``
{"ft_lang_label":"__label__en","ft_lang_prob":0.6159896,"math_prob":0.98038304,"size":1244,"snap":"2022-40-2023-06","text_gpt3_token_len":412,"char_repetition_ratio":0.15564516,"word_repetition_ratio":0.0,"special_character_ratio":0.35369775,"punctuation_ratio":0.23357664,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9959023,"pos_list":[0,1,2],"im_url_duplicate_count":[null,6,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-28T22:40:29Z\",\"WARC-Record-ID\":\"<urn:uuid:f5b94ce4-cdce-4c4d-8c9c-017d53fad795>\",\"Content-Length\":\"24198\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eb648408-0872-4782-b12f-c77e8e6a5ad1>\",\"WARC-Concurrent-To\":\"<urn:uuid:8fc1b1c3-9875-4f11-9e5b-c7915233b5bf>\",\"WARC-IP-Address\":\"104.21.15.59\",\"WARC-Target-URI\":\"https://nest.pijul.org/voroskoi/aoc2021/changes/IYFLF64GJANEA4PEGDP76SJ7JAPV4SOR5GWGDCDY2QUK3FMHLN6AC\",\"WARC-Payload-Digest\":\"sha1:SW2UOATWF6PYWUR2F6GVF7S7YFKPKILO\",\"WARC-Block-Digest\":\"sha1:EX62JXFPXM4VQYK4OBVZVFBYDCJXM4KY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335286.15_warc_CC-MAIN-20220928212030-20220929002030-00168.warc.gz\"}"}