add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
12
solutions/13/q1304/solution.go
Normal file
12
solutions/13/q1304/solution.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package q1304
|
||||
|
||||
func sumZero(n int) []int {
|
||||
ret := make([]int, n)
|
||||
for i := range n / 2 {
|
||||
ret[i*2] = i + 1
|
||||
ret[i*2+1] = -i - 1
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
var _ = sumZero
|
||||
25
solutions/13/q1317/solution.go
Normal file
25
solutions/13/q1317/solution.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package q1317
|
||||
|
||||
func noZero(n int) bool {
|
||||
for ; n > 0; n /= 10 {
|
||||
if n%10 == 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getNoZeroIntegers(n int) []int {
|
||||
for i := 1; i <= n/2; i++ {
|
||||
if !noZero(i) {
|
||||
continue
|
||||
}
|
||||
j := n - i
|
||||
if noZero(j) {
|
||||
return []int{i, j}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ = getNoZeroIntegers
|
||||
Loading…
Add table
Add a link
Reference in a new issue