-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathtwo-bucket.rs
More file actions
101 lines (92 loc) · 2.64 KB
/
two-bucket.rs
File metadata and controls
101 lines (92 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use two_bucket::{Bucket, BucketStats};
#[test]
fn measure_using_bucket_one_of_size_3_and_bucket_two_of_size_5_start_with_bucket_one() {
let output = two_bucket::solve(3, 5, 1, &Bucket::One);
let expected = Some(BucketStats {
moves: 4,
goal_bucket: Bucket::One,
other_bucket: 5,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn measure_using_bucket_one_of_size_3_and_bucket_two_of_size_5_start_with_bucket_two() {
let output = two_bucket::solve(3, 5, 1, &Bucket::Two);
let expected = Some(BucketStats {
moves: 8,
goal_bucket: Bucket::Two,
other_bucket: 3,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn measure_using_bucket_one_of_size_7_and_bucket_two_of_size_11_start_with_bucket_one() {
let output = two_bucket::solve(7, 11, 2, &Bucket::One);
let expected = Some(BucketStats {
moves: 14,
goal_bucket: Bucket::One,
other_bucket: 11,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn measure_using_bucket_one_of_size_7_and_bucket_two_of_size_11_start_with_bucket_two() {
let output = two_bucket::solve(7, 11, 2, &Bucket::Two);
let expected = Some(BucketStats {
moves: 18,
goal_bucket: Bucket::Two,
other_bucket: 7,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn measure_one_step_using_bucket_one_of_size_1_and_bucket_two_of_size_3_start_with_bucket_two() {
let output = two_bucket::solve(1, 3, 3, &Bucket::Two);
let expected = Some(BucketStats {
moves: 1,
goal_bucket: Bucket::Two,
other_bucket: 0,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn measure_using_bucket_one_of_size_2_and_bucket_two_of_size_3_start_with_bucket_one_and_end_with_bucket_two(
) {
let output = two_bucket::solve(2, 3, 3, &Bucket::One);
let expected = Some(BucketStats {
moves: 2,
goal_bucket: Bucket::Two,
other_bucket: 2,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn not_possible_to_reach_the_goal() {
let output = two_bucket::solve(6, 15, 5, &Bucket::One);
let expected = None;
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn with_the_same_buckets_but_a_different_goal_then_it_is_possible() {
let output = two_bucket::solve(6, 15, 9, &Bucket::One);
let expected = Some(BucketStats {
moves: 10,
goal_bucket: Bucket::Two,
other_bucket: 0,
});
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn goal_larger_than_both_buckets_is_impossible() {
let output = two_bucket::solve(5, 7, 8, &Bucket::One);
let expected = None;
assert_eq!(output, expected);
}