This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathodd-even-jump_test.go
executable file
·62 lines (49 loc) · 7.42 KB
/
odd-even-jump_test.go
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
package problem0975
import (
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
A []int
ans int
}{
{
[]int{2, 3, 1, 1, 4, 2, 3, 1, 1, 4},
5,
},
{
[]int{1, 2, 3, 2, 1, 4, 4, 5},
6,
},
{
[]int{58614, 72008, 68132, 35335, 91636, 89945, 33065, 74739, 909, 81635, 56486, 95230, 36319, 62571, 32300, 78278, 60070, 98747, 101, 14075, 4360, 12584, 92938, 94860, 48041, 94668, 81838, 77861, 74728, 18765, 54887, 42387, 94978, 17383, 16985, 65886, 15740, 11005, 50392, 79666, 60504, 75475, 26575, 28496, 42870, 99084, 71791, 94625, 53787, 55455, 99009, 18998, 78259, 79151, 84474, 75005, 15533, 66112, 92370, 56328, 36094, 94952, 56159, 41163, 61413, 80412, 22830, 1569, 52909, 94135, 68025, 63090, 62781, 49698, 73091, 24919, 89175, 27447, 94494, 92649, 7792, 44817, 74403, 44965, 50889, 80682, 70499, 95800, 16448, 92355, 92798, 63474, 94039, 25268, 88178, 77347, 60968, 9062, 3013, 1096, 25055, 76235, 38662, 77544, 62564, 38926, 88014, 3841, 46531, 82985, 12681, 71048, 32811, 2430, 47372, 52169, 4158, 56591, 34743, 449, 19077, 11081, 54062, 4312, 92813, 84506, 94529, 31480, 90526, 98431, 76473, 27508, 67088, 59566, 40420, 30609, 5984, 12538, 13395, 48089, 64189, 76406, 4671, 82375, 4347, 55494, 74414, 63122, 94967, 34469, 58588, 8279, 55979, 81329, 20160, 26096, 70040, 25388, 25924, 93551, 99854, 15519, 90016, 55272, 3860, 58550, 64154, 3379, 75769, 81780, 7164, 64839, 45654, 23872, 45867, 15938, 33366, 65520, 47648, 55592, 54344, 82059, 34338, 81296, 7998, 42773, 35232, 45158, 83350, 51239, 98724, 86146, 11884, 31689, 2272, 73375, 1920, 88593, 19334, 41383, 6203, 31125, 38951, 5223, 76755, 71134, 35788, 83519, 7742, 5400, 35498, 90184, 75646, 67231, 56273, 80376, 41222, 3068, 80240, 19049, 38765, 35760, 12336, 35078, 17708, 61601, 65343, 1364, 45647, 55405, 87166, 49603, 8045, 5172, 86210, 79072, 85844, 26224, 64799, 9571, 82657, 33361, 95514, 47138, 3306, 90905, 62553, 28708, 3680, 37668, 15686, 54828, 14688, 17461, 92086, 64012, 24258, 87889, 62471, 94559, 48291, 88790, 67844, 4416, 24029, 28157, 17001, 23818, 22604, 87834, 46289, 87651, 13799, 56491, 1346, 93030, 563, 38990, 80158, 99988, 1950, 82408, 51008, 3818, 77711, 11190, 61147, 77832, 67359, 37987, 2644, 43626, 91369, 33292, 24795, 13783, 51025, 53334, 7304, 40775, 65868, 96605, 43154, 43603, 47113, 22503, 39483, 64526, 39705, 58137, 83558, 99796, 88503, 37179, 2172, 61160, 47455, 23701, 4030, 32157, 79807, 96411, 10666, 87763, 4871, 71347, 2679, 42104, 87023, 39310, 92456, 71319, 60418, 16137, 34049, 41109, 59020, 99603, 28370, 50356, 93344, 34542, 62860, 76613, 63026, 75343, 19569, 95733, 17689, 58368, 29604, 63442, 29111, 43121, 68222, 26906, 72787, 34687, 13215, 61312, 16575, 43057, 39839, 7616, 71076, 68082, 77779, 54491, 55391, 16923, 20746, 22824, 52530, 81898, 35697, 88187, 73587, 71644, 33517, 11847, 96279, 85461, 40886, 86321, 89921, 34247, 50156, 33178, 69515, 91216, 98454, 74377, 30524, 88049, 99261, 34652, 94871, 51154, 96463, 99585, 81294, 68343, 15401, 491, 59547, 70445, 93553, 51711, 69684, 64735, 20492, 64430, 98172, 11118, 68854, 61430, 37585, 79334, 1048, 89241, 81736, 48070, 10813, 45262, 58425, 25388, 48653, 77572, 92273, 56164, 82724, 7793, 85636, 92081, 16800, 82748, 84956, 87865, 51713, 60825, 20808, 70813, 40501, 2116, 13426, 38821, 88517, 56494, 91625, 92948, 8679, 58821, 33452, 50679, 45552, 47994, 10180, 83316, 49027, 64498, 47267, 18101, 54100, 15953, 85217, 83160, 14363, 6884, 6849, 39324, 95304, 55614, 26552, 22964, 11087, 14107, 81186, 13863, 86406, 82299, 13680, 55872, 705, 86203, 55827, 75534, 49034, 69042, 93123, 55954, 87470, 34304, 9753, 514, 22665, 83858, 31149, 22461, 49563, 94690, 50897, 34087, 7750, 57366, 22625, 36749, 38116, 75818, 23162, 93589, 74238, 48111, 88047, 35916, 38433, 12936, 77855, 40119, 50025, 47096, 65618, 37393, 91586, 43192, 35921, 40087, 76629, 99305, 86651, 47972, 29135, 44598, 34401, 24353, 18694, 95587, 49930, 10997, 38390, 38871, 51353, 98004, 97663, 56589, 61809, 67562, 50222, 48667, 31452, 68392, 9189, 31714, 89097, 22737, 96758, 98416, 57538, 4043, 9347, 20030, 32681, 11310, 79721, 36415, 23373, 4369, 38267, 450, 11649, 60464, 93494, 19936, 74106, 19770, 149, 89653, 84610, 6677, 17713, 23430, 92832, 38192, 80738, 43581, 38124, 76534, 61576, 26931, 58281, 70385, 82707, 67717, 64074, 59590, 9205, 94518, 71484, 27287, 69235, 62081, 65885, 37890, 57317, 66002, 20165, 50801, 12034, 10553, 91106, 12454, 89326, 46979, 45490, 33981, 41621, 37723, 56498, 33559, 82197, 23356, 24847, 48055, 93508, 2391, 72341, 600, 40486, 76420, 44607, 42948, 25321, 47509, 22825, 28352, 65329, 59944, 92954, 96886, 52238, 8755, 29990, 51780, 67316, 94619, 15510, 3668, 87003, 80516, 76574, 46860, 67778, 41146, 19205, 39089, 78704, 80185, 96113, 88766, 68208, 52091, 72392, 18320, 92308, 71257, 59448, 43404, 63354, 61767, 89885, 57073, 21337, 44137, 24296, 90495, 84352, 55581, 19639, 4354, 13416, 44321, 67420, 22399, 68452, 86194, 75724, 42552, 64572, 98836, 88541, 33814, 68544, 16321, 55736, 35653, 43814, 43889, 66323, 84599, 46857, 14658, 75415, 75164, 95384, 39405, 46387, 54059, 89212, 70421, 2127, 20732, 85389, 58547, 87390, 41139, 21046, 414, 99605, 13638, 64296, 48970, 38014, 53720, 7828, 97003, 49273, 1528, 41934, 75720, 31208, 74502, 76736, 23912, 96797, 2788, 86360, 51264, 15337, 25839, 59351, 27845, 83842, 21952, 38406, 50681, 33977, 82414, 26388, 8897, 15478, 62694, 56356, 6329, 99304, 47944, 31943, 72916, 2429, 43424, 66441, 96213, 76163, 88515, 11890, 42977, 3179, 27199, 38429, 34382, 37374, 80308, 18954, 82449, 54192, 33874, 55223, 16142, 49545, 2195, 86297, 33158, 34404, 99515, 61345, 41765, 79065, 6766, 57050, 52070, 86122, 58620, 48527, 52022, 78189, 34732, 55778, 70739, 99555, 69368, 96187, 39903, 60878, 74529, 34841, 26917, 97283, 34853, 99990, 85227, 21606, 82821, 98362, 27682, 66445, 76958, 8328, 81933, 30836, 70638, 95013, 3510, 61171, 29240, 11465, 71185, 97904, 51271, 34634, 44908, 41461, 53190, 40917, 8037, 97942, 99670, 17413, 24103, 43695, 69873, 3134, 83549, 63843, 26929, 87086, 66120, 31692, 54784, 97923, 4843, 70846, 84941, 69231, 14001, 59714, 78595, 41859, 58242, 25346, 31274, 80857, 48949, 44881, 12288, 37447, 52072, 23101, 80793, 38370, 23848, 30829, 82446, 90414, 96029, 1519, 75389, 52548, 12456, 24653, 28169, 40421, 47072, 93678, 5835, 70916, 85410, 35729, 24921, 22130, 30083, 14529, 55167, 25039, 2725, 23263, 82063, 41737, 88353, 94361, 24334, 55997, 88106, 58142, 16800, 24795, 98762, 29938, 86770, 79501, 74198, 72194, 78998, 84740, 6236, 16780, 50552, 21248, 53321, 49318, 12677, 8596, 1165, 82503, 8174, 96156, 98383, 74569, 45038, 27578, 41245, 34529, 39629, 72619, 89252, 15771, 24267, 20989, 4534, 85420, 51127, 6703, 44625, 45061, 77795, 76139, 13448, 62687, 50968, 1349, 14773, 66684, 36702, 96368, 50175, 68828, 13361, 47944, 73412, 83348, 19960, 39690, 47352, 44037, 47544, 29590, 80872, 91307, 34900, 63786, 38070, 57875, 69553, 50151, 67458, 75714, 84329, 18880, 21638, 51437, 50965, 80772, 51738, 90005, 77760, 50631, 82632, 47585, 34171, 43342, 45620, 65053, 5215, 72950, 96823, 45881, 6877, 20125, 10321, 25635, 79390, 104, 87357},
965,
},
{
[]int{10, 13, 12, 14, 15},
2,
},
{
[]int{2, 3, 1, 1, 4},
3,
},
{
[]int{5, 1, 3, 4, 2},
3,
},
// 可以有多个 testcase
}
func Test_oddEvenJumps(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
ast.Equal(tc.ans, oddEvenJumps(tc.A), "输入:%v", tc)
}
}
func Benchmark_oddEvenJumps(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, tc := range tcs {
oddEvenJumps(tc.A)
}
}
}