func decryptDisplay(values []string) displayKey {
	key := displayKey{}

	known := make(map[int]string)
	for _, v := range values {
		if len(v) == 2 {
			known[1] = v
		}
		if len(v) == 3 {
			known[7] = v
		}
		if len(v) == 4 {
			known[4] = v
		}
		if len(v) == 7 {
			known[8] = v
		}
	}

	// top middle is easy, just the diff between 7 & 1
	for _, char := range strings.Split(known[7], "") {
		if strings.Contains(known[1], char) {
			continue
		}
		key.top = char
		break
	}

	// of the 3 values that have a len of 6, the number 6 is the only one
	// that doesn't have both '1' segments, ergo of the three numbers with
	// len 6, the one value missing that 1 includes is the top right
	for _, v := range values {
		if len(v) != 6 {
			continue
		}

		for _, char := range strings.Split(known[1], "") {
			if strings.Contains(v, char) {
				continue
			}
			key.topRight = char
			break
		}
	}

	// now bottom right is ezpz (the one from 1 that isn't topright
	for _, char := range strings.Split(known[1], "") {
		if char == key.topRight {
			continue
		}
		key.bottomRight = char
		break
	}

	// now we can do middle and bottom using "3", as it's the only len 5
	// display with topright, and bottomright. after determining the 2
	// candidates, we can use 4 to determine middle, then bottom, and topleft
	for _, v := range values {
		if len(v) != 5 {
			continue
		}
		if strings.Contains(v, key.topRight) && strings.Contains(v, key.bottomRight) {
			known[3] = v
			break
		}
	}

	// so middle is the one that both 3 and 4 has, that aren't topright or bottom right
	for _, char := range strings.Split(known[4], "") {
		if char == key.topRight || char == key.bottomRight || !strings.Contains(known[3], char) {
			continue
		}
		key.middle = char
		break
	}

	// now bottom is just the odd man out from 3
	for _, char := range strings.Split(known[3], "") {
		if char == key.topRight || char == key.top || char == key.middle || char == key.bottomRight {
			continue
		}
		key.bottom = char
		break
	}

	// we can go back to 4 for top left
	for _, char := range strings.Split(known[4], "") {
		if char == key.topRight || char == key.middle || char == key.bottomRight {
			continue
		}
		key.topLeft = char
		break
	}

	// finally, 8 for bottom left
	for _, char := range strings.Split(known[8], "") {
		if char == key.top || char == key.topRight || char == key.topLeft ||
			char == key.middle || char == key.bottomRight || char == key.bottom {
			continue
		}
		key.bottomLeft = char
		break
	}
	return key
}
// this is obviously not the ideal way, but it works :)
this is obviously not the ideal way, but it works :)
// this is obviously not the ideal way but it works : )
func decryptDisplay(values []string) displayKey {
	key := displayKey{}
	known := make(map[int]string)
	for _, v := range values {
		if len(v) == 2 {
			known[1] = v
		}
		if len(v) == 3 {
			known[7] = v
		}
		if len(v) == 4 {
			known[4] = v
		}
		if len(v) == 7 {
			known[8] = v
		}
	}
	for _, char := range strings.Split(known[7], "") {
		if strings.Contains(known[1], char) {
			continue
		}
		key.top = char
		break
	}
	for _, v := range values {
		if len(v) != 6 {
			continue
		}
		for _, char := range strings.Split(known[1], "") {
			if strings.Contains(v, char) {
				continue
			}
			key.topRight = char
			break
		}
	}
	for _, char := range strings.Split(known[1], "") {
		if char == key.topRight {
			continue
		}
		key.bottomRight = char
		break
	}
	for _, v := range values {
		if len(v) != 5 {
			continue
		}
		if strings.Contains(v, key.topRight) && strings.Contains(v, key.bottomRight) {
			known[3] = v
			break
		}
	}
	for _, char := range strings.Split(known[4], "") {
		if char == key.topRight || char == key.bottomRight || !strings.Contains(known[3], char) {
			continue
		}
		key.middle = char
		break
	}
	for _, char := range strings.Split(known[3], "") {
		if char == key.topRight || char == key.top || char == key.middle || char == key.bottomRight {
			continue
		}
		key.bottom = char
		break
	}
	for _, char := range strings.Split(known[4], "") {
		if char == key.topRight || char == key.middle || char == key.bottomRight {
			continue
		}
		key.topLeft = char
		break
	}
	for _, char := range strings.Split(known[8], "") {
		if char == key.top || char == key.topRight || char == key.topLeft ||
			char == key.middle || char == key.bottomRight || char == key.bottom {
			continue
		}
		key.bottomLeft = char
		break
	}
	return key
}
func decryptDisplay ( values [ ] string ) displayKey { key := displayKey { } known := make ( map [ int ] string ) for _ , v := range values { if len ( v ) == 2 { known [ 1 ] = v } if len ( v ) == 3 { known [ 7 ] = v } if len ( v ) == 4 { known [ 4 ] = v } if len ( v ) == 7 { known [ 8 ] = v } } for _ , char := range strings . Split ( known [ 7 ] , " " ) { if strings . Contains ( known [ 1 ] , char ) { continue } key . top = char break } for _ , v := range values { if len ( v ) != 6 { continue } for _ , char := range strings . Split ( known [ 1 ] , " " ) { if strings . Contains ( v , char ) { continue } key . topRight = char break } } for _ , char := range strings . Split ( known [ 1 ] , " " ) { if char == key . topRight { continue } key . bottomRight = char break } for _ , v := range values { if len ( v ) != 5 { continue } if strings . Contains ( v , key . topRight ) && strings . Contains ( v , key . bottomRight ) { known [ 3 ] = v break } } for _ , char := range strings . Split ( known [ 4 ] , " " ) { if char == key . topRight || char == key . bottomRight || ! strings . Contains ( known [ 3 ] , char ) { continue } key . middle = char break } for _ , char := range strings . Split ( known [ 3 ] , " " ) { if char == key . topRight || char == key . top || char == key . middle || char == key . bottomRight { continue } key . bottom = char break } for _ , char := range strings . Split ( known [ 4 ] , " " ) { if char == key . topRight || char == key . middle || char == key . bottomRight { continue } key . topLeft = char break } for _ , char := range strings . Split ( known [ 8 ] , " " ) { if char == key . top || char == key . topRight || char == key . topLeft || char == key . middle || char == key . bottomRight || char == key . bottom { continue } key . bottomLeft = char break } return key }
this is obviously not the ideal way, but it works :)
this is obviously not the ideal way but it works : )
// top middle is easy, just the diff between 7 & 1 // of the 3 values that have a len of 6, the number 6 is the only one // that doesn't have both '1' segments, ergo of the three numbers with // len 6, the one value missing that 1 includes is the top right // now bottom right is ezpz (the one from 1 that isn't topright // now we can do middle and bottom using "3", as it's the only len 5 // display with topright, and bottomright. after determining the 2 // candidates, we can use 4 to determine middle, then bottom, and topleft // so middle is the one that both 3 and 4 has, that aren't topright or bottom right // now bottom is just the odd man out from 3 // we can go back to 4 for top left // finally, 8 for bottom left