-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
158 lines (131 loc) · 8.62 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package main
import (
"container/ring"
"fmt"
"strconv"
)
func main() {
//starone()
//startwo()
//starthree()
starfour()
}
func starone() {
captcha := []byte("9384274494683632359351641411374573466273164687337536769779487433749179185568461296233353611992672753778126935276769885424719553291616136172298883156626254151278852582397949697874462178536295341822137377563322815527592267791213115418635363174876132196234374887626324931371241841242873783493835919238421879116421481543826222278152238576762132577763214642569545298668935216911493462229629786978273548147171384321525952959196377728493632872618291183256888417779495124837828187298244786175872713299271766246696631257484453347125176233373232245382158656142179687576388951175953419286858673221138553912229576523123114871637487978775855777483921896568333282333137175739746234262744256254149233843517254613981476355147487975859685936527161737644929119345127273149762325158784595946931447738173246311763677997888425452294562823751136515271874725143582623717324394587398371298523368386595426714148717735345237657249712685895921433468949182235146698174393928288313985355769799485511749423552935992391624424575278333625476148888355716967628454862834463357834291788479677576561681171516128495737923155533438413156639155128831349894646317546536886319328573512622325789672115171618195548534941184939233914166432349321992879287349932819135919518955561456615989137221875483561599493342981595678961836562435436285673764213941758954489582656271121429555455368545289416981624961261963953364918377483776322142975937971552271642224933926326665557787586927667898255947116988278131974381388514274833852552695679713424836536348449273149415872522111522749448188993159814183411853994579147867385867619467777654943169814287928966652552129439822741856512265955664872454951159255617513136142717471774698224566543617595742753244142364438589729356939483387466363477224283477843889679221229344974441624448489853764111425798141258155246636844914711222931548722647298953744242682551562166463942694715631497895981643174194294826868561578586851326262619731272665397711381459745281218196515155917877694663186732599688912878149242688741584822831861748845817871681621697944472377688658368145698614861456518138376989688166921187224726942589996534179549171859786241718727295379")
var prev int
var matchers []int
for i, s := range captcha {
if i == 0 {
prev, _ = strconv.Atoi(string(s))
} else {
v, _ := strconv.Atoi(string(s))
if prev == v {
matchers = append(matchers, v)
}
prev = v
}
}
sum := 0
for i := range matchers {
sum += matchers[i]
}
sum = sum + 9
fmt.Println(sum)
}
func startwo() {
captcha := []byte("9384274494683632359351641411374573466273164687337536769779487433749179185568461296233353611992672753778126935276769885424719553291616136172298883156626254151278852582397949697874462178536295341822137377563322815527592267791213115418635363174876132196234374887626324931371241841242873783493835919238421879116421481543826222278152238576762132577763214642569545298668935216911493462229629786978273548147171384321525952959196377728493632872618291183256888417779495124837828187298244786175872713299271766246696631257484453347125176233373232245382158656142179687576388951175953419286858673221138553912229576523123114871637487978775855777483921896568333282333137175739746234262744256254149233843517254613981476355147487975859685936527161737644929119345127273149762325158784595946931447738173246311763677997888425452294562823751136515271874725143582623717324394587398371298523368386595426714148717735345237657249712685895921433468949182235146698174393928288313985355769799485511749423552935992391624424575278333625476148888355716967628454862834463357834291788479677576561681171516128495737923155533438413156639155128831349894646317546536886319328573512622325789672115171618195548534941184939233914166432349321992879287349932819135919518955561456615989137221875483561599493342981595678961836562435436285673764213941758954489582656271121429555455368545289416981624961261963953364918377483776322142975937971552271642224933926326665557787586927667898255947116988278131974381388514274833852552695679713424836536348449273149415872522111522749448188993159814183411853994579147867385867619467777654943169814287928966652552129439822741856512265955664872454951159255617513136142717471774698224566543617595742753244142364438589729356939483387466363477224283477843889679221229344974441624448489853764111425798141258155246636844914711222931548722647298953744242682551562166463942694715631497895981643174194294826868561578586851326262619731272665397711381459745281218196515155917877694663186732599688912878149242688741584822831861748845817871681621697944472377688658368145698614861456518138376989688166921187224726942589996534179549171859786241718727295379")
var matchers []int
j := len(captcha) / 2
for _, s := range captcha {
r := ring.New(len(captcha))
for i := 0; i < r.Len(); i++ {
r.Value, _ = strconv.Atoi(string(captcha[i]))
r = r.Next()
}
v, _ := strconv.Atoi(string(s))
r = r.Move(j)
j = j + 1
if r.Value == v {
// fmt.Printf("We have a match %v == %v\n", r.Value, v)
matchers = append(matchers, v)
}
}
sum := 0
for i := range matchers {
sum += matchers[i]
}
fmt.Println(sum)
}
func starthree() {
type minMaxStore struct {
min int
max int
}
input := map[int][]int{
1: {409, 194, 207, 470, 178, 454, 235, 333, 511, 103, 474, 293, 525, 372, 408, 428},
2: {4321, 2786, 6683, 3921, 265, 262, 6206, 2207, 5712, 214, 6750, 2742, 777, 5297, 3764, 167},
3: {3536, 2675, 1298, 1069, 175, 145, 706, 2614, 4067, 4377, 146, 134, 1930, 3850, 213, 4151},
4: {2169, 1050, 3705, 2424, 614, 3253, 222, 3287, 3340, 2637, 61, 216, 2894, 247, 3905, 214},
5: {99, 797, 80, 683, 789, 92, 736, 318, 103, 153, 749, 631, 626, 367, 110, 805},
6: {2922, 1764, 178, 3420, 3246, 3456, 73, 2668, 3518, 1524, 273, 2237, 228, 1826, 182, 2312},
7: {2304, 2058, 286, 2258, 1607, 2492, 2479, 164, 171, 663, 62, 144, 1195, 116, 2172, 1839},
8: {114, 170, 82, 50, 158, 111, 165, 164, 106, 70, 178, 87, 182, 101, 86, 168},
9: {121, 110, 51, 122, 92, 146, 13, 53, 34, 112, 44, 160, 56, 93, 82, 98},
10: {4682, 642, 397, 5208, 136, 4766, 180, 1673, 1263, 4757, 4680, 141, 4430, 1098, 188, 1451},
11: {158, 712, 1382, 170, 550, 913, 191, 163, 459, 1197, 1488, 1337, 900, 1182, 1018, 337},
12: {4232, 236, 3835, 3847, 3881, 4180, 4204, 4030, 220, 1268, 251, 4739, 246, 3798, 1885, 3244},
13: {169, 1928, 3305, 167, 194, 3080, 2164, 192, 3073, 1848, 426, 2270, 3572, 3456, 217, 3269},
14: {140, 1005, 2063, 3048, 3742, 3361, 117, 93, 2695, 1529, 120, 3480, 3061, 150, 3383, 190},
15: {489, 732, 57, 75, 61, 797, 266, 593, 324, 475, 733, 737, 113, 68, 267, 141},
16: {3858, 202, 1141, 3458, 2507, 239, 199, 4400, 3713, 3980, 4170, 227, 3968, 1688, 4352, 4168},
}
store := []minMaxStore{}
for i, _ := range input {
max := 0
min := 0
for i, v := range input[i] {
if i == 0 {
min = v
}
if v < min {
min = v
} else if v > max {
max = v
}
}
tempStore := minMaxStore{
min: min,
max: max,
}
store = append(store, tempStore)
}
fmt.Println(store)
sum := 0
for _, v := range store {
tSum := v.max - v.min
sum = tSum + sum
}
fmt.Println(sum)
}
func starfour() {
input := [][]int{
{409, 194, 207, 470, 178, 454, 235, 333, 511, 103, 474, 293, 525, 372, 408, 428},
{4321, 2786, 6683, 3921, 265, 262, 6206, 2207, 5712, 214, 6750, 2742, 777, 5297, 3764, 167},
{3536, 2675, 1298, 1069, 175, 145, 706, 2614, 4067, 4377, 146, 134, 1930, 3850, 213, 4151},
{2169, 1050, 3705, 2424, 614, 3253, 222, 3287, 3340, 2637, 61, 216, 2894, 247, 3905, 214},
{99, 797, 80, 683, 789, 92, 736, 318, 103, 153, 749, 631, 626, 367, 110, 805},
{2922, 1764, 178, 3420, 3246, 3456, 73, 2668, 3518, 1524, 273, 2237, 228, 1826, 182, 2312},
{2304, 2058, 286, 2258, 1607, 2492, 2479, 164, 171, 663, 62, 144, 1195, 116, 2172, 1839},
{114, 170, 82, 50, 158, 111, 165, 164, 106, 70, 178, 87, 182, 101, 86, 168},
{121, 110, 51, 122, 92, 146, 13, 53, 34, 112, 44, 160, 56, 93, 82, 98},
{4682, 642, 397, 5208, 136, 4766, 180, 1673, 1263, 4757, 4680, 141, 4430, 1098, 188, 1451},
{158, 712, 1382, 170, 550, 913, 191, 163, 459, 1197, 1488, 1337, 900, 1182, 1018, 337},
{4232, 236, 3835, 3847, 3881, 4180, 4204, 4030, 220, 1268, 251, 4739, 246, 3798, 1885, 3244},
{169, 1928, 3305, 167, 194, 3080, 2164, 192, 3073, 1848, 426, 2270, 3572, 3456, 217, 3269},
{140, 1005, 2063, 3048, 3742, 3361, 117, 93, 2695, 1529, 120, 3480, 3061, 150, 3383, 190},
{489, 732, 57, 75, 61, 797, 266, 593, 324, 475, 733, 737, 113, 68, 267, 141},
{3858, 202, 1141, 3458, 2507, 239, 199, 4400, 3713, 3980, 4170, 227, 3968, 1688, 4352, 4168},
}
for _, l := range input {
}
}