You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
lensfrex 63280146bd
cap5 works 1~7
3 months ago
.vscode cap5 works 1~7 3 months ago
cap3 format code 4 months ago
cap4 cap4 examples 4 months ago
cap5 cap4 examples 4 months ago
common feat: 第一次作业 5 months ago
python cap5 works 1~7 3 months ago
.gitignore format code 4 months ago
README.md format code 4 months ago
go.mod feat: 第一次作业 5 months ago
main.go feat: 第一次作业 5 months ago
package.sh feat: ex20 ~ ex32 5 months ago

README.md

Lavos

算法设计与分析例题/作业代码合集,使用go编写实现

目录结构

包代码目录格式为,cap{x},对应的是第x章的例题和作业代码,其中每个例题/作业代码文件均命名为ex{x}.go以及work{x}.go

如第三章例6,位于cap3/ex6.go中,第四章作业5,位于cap4/ex5.go中。

运行/测试

要运行测试,需要go开发环境。Go installation instructions: https://go.dev/doc/install

完成后,运行

go test lavos/cap3

即可运行该章节下所有的例题和作业的test用例,例题和作业的test代码位于example_test.gowork_test.go中。

如果需要单独测试某一个题目,运行

go test lavos/cap3 -v '-test.run' 'Ex6$'
go test lavos/cap3 -v '-test.run' 'Work1$'

即可运行对应的题目,如示例中将会运行第三章例题6的test和作业1

其他细节

由于习惯原因,我并不是很喜欢在算法代码中进行具体的输出操作,或者直接将输出输入放置于算法代码中,而是使用了类似于leetcode中的核心代码模式,因此ex{x}.gowork{x}.go中的代码模式均为核心代码,不负责输出输入, 如有需要输出的算法,通过callback实现,传入能够实现输出的callback函数,在核心中调用callback来实现输出,核心代码不关心也不区负责输出输入,输出输入由test负责实现。