Sha256: bffa629a6c8c0620bd36130fe43f214c533bead4b4dd064e0f25f2066410f41d

Contents?: true

Size: 1.4 KB

Versions: 117

Compression:

Stored size: 1.4 KB

Contents

package change

// Source: exercism/x-common
// Commit: 3d8b5b3 change: Fix canonical-data.json formatting
// x-common version: 1.0.0

var testCases = []struct {
	description    string
	coins          []int
	target         int
	valid          bool  // true => no error, false => error expected
	expectedChange []int // when .valid == true, the expected change coins
}{
	{
		"single coin change",
		[]int{1, 5, 10, 25, 100},
		25,
		true,
		[]int{25},
	},
	{
		"multiple coin change",
		[]int{1, 5, 10, 25, 100},
		15,
		true,
		[]int{5, 10},
	},
	{
		"change with Lilliputian Coins",
		[]int{1, 4, 15, 20, 50},
		23,
		true,
		[]int{4, 4, 15},
	},
	{
		"change with Lower Elbonia Coins",
		[]int{1, 5, 10, 21, 25},
		63,
		true,
		[]int{21, 21, 21},
	},
	{
		"large target values",
		[]int{1, 2, 5, 10, 20, 50, 100},
		999,
		true,
		[]int{2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100},
	},
	{
		"possible change without unit coins available",
		[]int{2, 5, 10, 20, 50},
		21,
		true,
		[]int{2, 2, 2, 5, 10},
	},
	{
		"no coins make 0 change",
		[]int{1, 5, 10, 21, 25},
		0,
		true,
		[]int{},
	},
	{
		"error testing for change smaller than the smallest of coins",
		[]int{5, 10},
		3,
		false,
		[]int(nil),
	},
	{
		"error if no combination can add up to target",
		[]int{5, 10},
		94,
		false,
		[]int(nil),
	},
	{
		"cannot find negative change values",
		[]int{1, 2, 5},
		-5,
		false,
		[]int(nil),
	},
}

Version data entries

117 entries across 117 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.55 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.54 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.53 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.52 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.51 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.50 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.49 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.48 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.47 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.46 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.45 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.44 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.43 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.42 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.41 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.40 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.39 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.38 tracks/go/exercises/change/cases_test.go
trackler-2.2.1.37 tracks/go/exercises/change/cases_test.go