Initial import
[?]
Dec 30, 2020, 12:18 PM
NJFOEVJ3LLRZY42V3Z4L7BIOSAHIDP4GOEHGZ4UDAAIBJRZYCDTACDependencies
- [2]
44BSZW7Bcodingame.com: solve bank-robbers - [3]
KGSQ3OPPAdd yaml-unmarshal examples - [4]
2DRAL6A2Refactoring evaluate_test - [5]
R6MPEEL2Refactoring minimax tests - [6]
HSJSKGY7Refactoring evaluate functions - [7]
UWVAMBIJFix couple of tests, add more - [8]
G5KXCVILtictactoe: initial import - [9]
ZAZCOSBXEnhance test readability by renaming couple variables - [10]
TYELLGSARename checkDiag to checkDiagLR and add checkDiagRL. Add more tests
Change contents
- replacement in snippets/tictactoe/minimax_test.go at line 8
"github.com/stretchr/testify/assert""github.com/matryer/is" - edit in snippets/tictactoe/minimax_test.go at line 12
is := is.NewRelaxed(t) - replacement in snippets/tictactoe/minimax_test.go at line 26
assert.Equal(t, tc.expected, tictactoe.Minimax(0, 0, true, tc.scores, int(height)))is.Equal(tc.expected, tictactoe.Minimax(0, 0, true, tc.scores, int(height))) - replacement in snippets/tictactoe/go.mod at line 6
github.com/stretchr/testify v1.6.1github.com/matryer/is v1.4.0 - replacement in snippets/tictactoe/evaluate_test.go at line 7
"github.com/stretchr/testify/assert""github.com/matryer/is" - edit in snippets/tictactoe/evaluate_test.go at line 11
is := is.NewRelaxed(t) - replacement in snippets/tictactoe/evaluate_test.go at line 50
assert.Equal(t, tc.expected, tc.board.Evaluate())is.Equal(tc.expected, tc.board.Evaluate()) - file addition: next-growing-number[2.16]
- file addition: ngn_test.go[0.283]
package ngn_testimport ("ngn""testing""github.com/matryer/is")func TestGrowing(t *testing.T) {var cases = []struct {input stringexpected string}{{"19", "22"},{"99", "111"},{"2533", "2555"},{"123456879", "123456888"},{"11123159995399999", "11123333333333333"},{"123456788", "123456789"},{"1234999", "1235555"},}for _, tc := range cases {is := is.New(t)t.Run("Growing"+tc.input, func(t *testing.T) {is.Equal(tc.expected, ngn.Growing(tc.input, ngn.Tipping(tc.input)))})}} - file addition: ngn.go[0.283]
package ngnimport ("strconv")func Tipping(n string) (tipping int) {for i := 0; i < len(n)-1; i++ {if n[i] > n[i+1] {return i}}return tipping}func Growing(n string, tipping int) (ret string) {//log.Printf("num: %s, tipping: %d", n, tipping)if tipping != 0 {return tipgrow(n, tipping)}// there is no tipping poing, input is already a growing numberfor i := len(n) - 1; i >= 0; i-- {curr := n[i]//log.Printf("curr: %c\t%v, i: %d\n", curr, curr, i)if curr != 57 && i == len(n)-1 {// its not 9 and it is the last so we do not have to bump the place valuecurr++ret = n[:len(n)-1] + string(curr)return ret}if curr == 57 && i == 0 {// it is all 9, eg: 99// we have to prepend 1 to itn = strconv.Itoa(1) + nreturn tipgrow(n, 0)}if curr != 57 {curr++//log.Printf("pre: %s, curr: %s, post: %s", n[:i], string(curr), n[i+1:])n = n[:i] + string(curr) + n[i+1:]return tipgrow(n, i)}}return ret}func tipgrow(n string, tipping int) (ret string) {for i := 0; i < len(n); i++ {if i < tipping {ret += string(n[i])} else {new := n[tipping]ret += string(new)}}return ret}