Created
September 4, 2019 15:11
-
-
Save moul/042c69fef1d303da00c8a13611b0c0d2 to your computer and use it in GitHub Desktop.
same age
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" | |
| func isrev(a, b int) bool { | |
| astr := fmt.Sprintf("%d", a) | |
| bstr := fmt.Sprintf("%d", b) | |
| arev := astr[1:2] + astr[0:1] | |
| brev := bstr[1:2] + bstr[0:1] | |
| return a != b && (astr == brev || bstr == arev) | |
| } | |
| func main() { | |
| for a := 11; a < 100; a++ { | |
| for b := 11; b < 100; b++ { | |
| if isrev(a, b) { | |
| fmt.Println(a, b) | |
| for i := 1; a+i < 100 && b+i < 100; i++ { | |
| if isrev(a+i, b+i) { | |
| fmt.Println(" ", a+i, b+i) | |
| } | |
| if isrev(a+i+1, b+i) { | |
| fmt.Println(" ", a+i+1, b+i) | |
| } | |
| if isrev(a+i, b+i+1) { | |
| fmt.Println(" ", a+i, b+i+1) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Author
moul
commented
Sep 4, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment