Skip to content

Commit

Permalink
add method factorial with tree
Browse files Browse the repository at this point in the history
Signed-off-by: deemak <[email protected]>
  • Loading branch information
deemakuzovkin committed Jun 16, 2021
1 parent eca5c00 commit b6b76c3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
43 changes: 26 additions & 17 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/utils/slice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package utils

/*SliceToChunk [][]int*/
func SliceToChunk(data []int, chunkSize int) [][]int {
if len(data) == 0 {
return nil
}
divided := make([][]int, (len(data)+chunkSize-1)/chunkSize)
prev := 0
i := 0
till := len(data) - chunkSize
for prev < till {
next := prev + chunkSize
divided[i] = data[prev:next]
prev = next
i++
}
divided[i] = data[prev:]
return divided
}

0 comments on commit b6b76c3

Please sign in to comment.