-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15.go
More file actions
68 lines (57 loc) · 1.53 KB
/
15.go
File metadata and controls
68 lines (57 loc) · 1.53 KB
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
package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
"strconv"
)
func main(){
// get to know the lib
REF := "2006-01-02"
todo := "1986-07-11"
date, _ := time.Parse(REF, todo)
fmt.Println("date/", date)
fmt.Println("wkdt/", date.Weekday())
// find leapyear
mid := 0
end := 100
leaps := []int{}
for mid < end {
nn := mid * 10 + 1006
if nn % 4 == 0 {
leaps = append(leaps, nn)
}
mid++
}
fmt.Println("\nleaps", leaps)
// find the year where jan 26 is a monday
monyears := []int{}
for _, year := range leaps {
todo = strconv.Itoa(year) + "-01-26"
date, _ = time.Parse(REF, todo)
wkdt := date.Weekday()
if wkdt == time.Monday/*"Monday"*/ {
monyears = append(monyears, year)
fmt.Println("date/", date, "wkdt/", wkdt, "- Found!")
}
}
fmt.Println("\nmonyears/", monyears, "len/", len(monyears))
// 2nd youngest
res := monyears[len(monyears) - 2]
fmt.Println("2nd/", res)
fmt.Println("\nfind out yourself what to do next")
}
//
func init(){
URL := "http://www.pythonchallenge.com/pc/return/uzi.html"
ups, mid := "hugefile", 4
conn := & http.Client{}
req, err := http.NewRequest("GET", URL, nil)
if err != nil {fmt.Println("err/", err)}
req.SetBasicAuth(ups[:mid], ups[mid:])
resp, _ := conn.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body), "\nbody ends/\n\n")
}