Here is a loop based solution, I'm sure there is a formula for finding it but I don't have time right now to figure it out or Go find it.
cubes.go
packagecube// Cubes will determine the count of cubes necessary as n to construct a pile of volume m// If no amount can equal m, 0 is returnedfuncCubes(mint)int{varn,totalintfortotal<m{n++total+=(n*n*n)}iftotal==m{returnn}return0}
cubes_test.go
packagecubeimport("testing")vartestCases=[]struct{descriptionstringinputintexpectedint}{{"challenge example 1",1071225,45,},{"challenge example 2",91716553919377,0,},}funcTestCubes(t*testing.T){for_,test:=rangetestCases{ifresult:=Cubes(test.input);result!=test.expected{t.Fatalf("FAIL: %s - Cubes(%d): %d, expected %d",test.description,test.input,result,test.expected)}t.Logf("PASS: %s",test.description)}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is a loop based solution, I'm sure there is a formula for finding it but I don't have time right now to figure it out or Go find it.
cubes.go
cubes_test.go