Created
April 9, 2025 13:41
-
-
Save lkarlslund/c50b9bba9784d567d35252f7aa1e8eaf to your computer and use it in GitHub Desktop.
FE påske challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func easter(year int) time.Time { | |
| a := year % 19 | |
| b := year / 100 | |
| c := year % 100 | |
| d := b / 4 | |
| e := b % 4 | |
| f := (b + 8) / 25 | |
| g := (b - f + 1) / 3 | |
| h := (19*a + b - d - g + 15) % 30 | |
| i := c / 4 | |
| k := c % 4 | |
| if year > 4099 { | |
| h-- | |
| } | |
| l := (32 + 2*e + 2*i - h - k) % 7 | |
| m := (a + 11*h + 22*l) / 451 | |
| month := (h + l - 7*m + 114) / 31 | |
| day := ((h + l - 7*m + 114) % 31) + 1 | |
| return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC) | |
| } | |
| func main() { | |
| alphabet := "abcdefghijklmnopqrstuvwxyz" | |
| years_hints := [][]int{ | |
| {1956, 1998, 1953, 1983, 0, 1998, 1953, 1956, 1952, 1956, 1981}, | |
| {1956, 1998, 1985, 1979, 1954, 1950, 2003, 1952, 1953, 0, 1981, 1979, 1952, 0, 1985, 1954, 1957, 1963, 1999, 1998, 1956, 1985, 0, 1998, 1950, 1985, 1985, 1953, 1954}, | |
| {1981, 1953, 1998, 1962, 0, 1952, 1956, 2003, 1953, 1952, 1956, 2003, 1950, 1971, 1953, 1954, 1963, 1953, 1981, 0, 1971, 1979, 1963, 1985, 1953}, | |
| {1971, 1956, 1963, 0, 1958, 1953, 1955, 1998, 1953}, | |
| {4200, 4227, 4285, 4247, 4200, 4271, 4244, 0, 4232, 4285, 4247, 4242, 4255, 4285, 4242, 4241, 0, 4265, 4227, 4271, 4211, 4251, 0, 4242, 4255, 4288, 4224, 4268, 4271, 4285, 0, 4241, 4268, 4227, 4241, 4241, 4285, 4211, 4251, 4227, 4268, 4232, 0, 4200, 4271, 4247, 4211, 4288, 4251, 4241, 4227, 4200, 0, 4288, 4268, 4285, 4211, 4285}, | |
| } | |
| for _, years := range years_hints { | |
| for _, year := range years { | |
| if year == 0 { | |
| fmt.Print(" ") | |
| continue | |
| } | |
| etime := easter(year) | |
| fmt.Print(string(alphabet[etime.Day()-1])) | |
| } | |
| fmt.Println() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment