From 6af599c268ec85567d35e509766cf81748c2db4d Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Sep 2019 14:20:26 +0800 Subject: [PATCH 1/2] Update: PackageName --- internal/leetcode/question_data.go | 7 +------ .../1_bit_and_2_bit_characters.go | 2 +- .../1_bit_and_2_bit_characters_test.go | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/leetcode/question_data.go b/internal/leetcode/question_data.go index c43d7cfce..ba4930da2 100644 --- a/internal/leetcode/question_data.go +++ b/internal/leetcode/question_data.go @@ -9,7 +9,6 @@ import ( "regexp" "strconv" "strings" - "unicode" ) func QuestionData(titleSlug string, isForce bool, graphQL ...string) (qd questionDataType) { @@ -199,11 +198,7 @@ func (question *questionType) TitleSnake() string { } func (question *questionType) PackageName() string { - snake := question.TitleSnake() - if snake != "" && unicode.IsNumber(rune(snake[0])) { - snake = "p_" + snake - } - return snake + return "problem_" + question.QuestionFrontendId } func (question *questionType) SaveCodeSnippet() { diff --git a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go index 94bba434d..70d1c06a0 100644 --- a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go +++ b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go @@ -1,4 +1,4 @@ -package p_1_bit_and_2_bit_characters +package problem_717 func isOneBitCharacter(bits []int) bool { l := len(bits) - 1 diff --git a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go index ba04e34fe..636963c45 100644 --- a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go +++ b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go @@ -1,4 +1,4 @@ -package p_1_bit_and_2_bit_characters +package problem_717 import "testing" From c5ee633de216af779b7bd5ffc6ec52daa945f299 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Sep 2019 14:50:28 +0800 Subject: [PATCH 2/2] Update: PackageName --- problems/01-matrix/01_matrix.go | 2 +- problems/01-matrix/01_matrix_test.go | 2 +- .../1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go | 3 +-- problems/132-pattern/132_pattern.go | 2 +- problems/132-pattern/132_pattern_test.go | 2 +- problems/2-keys-keyboard/2_keys_keyboard.go | 2 +- problems/2-keys-keyboard/2_keys_keyboard_test.go | 2 +- problems/24-game/24_game.go | 2 +- problems/24-game/24_game_test.go | 2 +- problems/3sum-closest/3sum_closest.go | 2 +- problems/3sum-closest/3sum_closest_test.go | 2 +- problems/3sum-smaller/3sum_smaller.go | 2 +- problems/3sum-smaller/3sum_smaller_test.go | 2 +- problems/3sum-with-multiplicity/3sum_with_multiplicity.go | 2 +- problems/3sum-with-multiplicity/3sum_with_multiplicity_test.go | 2 +- problems/3sum/3sum.go | 2 +- problems/3sum/3sum_test.go | 2 +- problems/4-keys-keyboard/4_keys_keyboard.go | 2 +- problems/4-keys-keyboard/4_keys_keyboard_test.go | 2 +- problems/4sum-ii/4sum_ii.go | 2 +- problems/4sum-ii/4sum_ii_test.go | 2 +- problems/4sum/4sum.go | 2 +- problems/4sum/4sum_test.go | 2 +- 23 files changed, 23 insertions(+), 24 deletions(-) diff --git a/problems/01-matrix/01_matrix.go b/problems/01-matrix/01_matrix.go index 5c3b532a7..cbe6348af 100644 --- a/problems/01-matrix/01_matrix.go +++ b/problems/01-matrix/01_matrix.go @@ -1,4 +1,4 @@ -package p_01_matrix +package problem_542 func updateMatrix(matrix [][]int) [][]int { m, n := len(matrix), len(matrix[0]) diff --git a/problems/01-matrix/01_matrix_test.go b/problems/01-matrix/01_matrix_test.go index 229ca9b8b..db4265f1c 100644 --- a/problems/01-matrix/01_matrix_test.go +++ b/problems/01-matrix/01_matrix_test.go @@ -1,4 +1,4 @@ -package p_01_matrix +package problem_542 import ( "reflect" diff --git a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go index 70d1c06a0..3f002ca4a 100644 --- a/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go +++ b/problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go @@ -1,8 +1,7 @@ package problem_717 func isOneBitCharacter(bits []int) bool { - l := len(bits) - 1 - i := 0 + i, l := 0, len(bits)-1 for i < l { i += bits[i] + 1 } diff --git a/problems/132-pattern/132_pattern.go b/problems/132-pattern/132_pattern.go index 8589452e7..7a91dc935 100644 --- a/problems/132-pattern/132_pattern.go +++ b/problems/132-pattern/132_pattern.go @@ -1,4 +1,4 @@ -package p_132_pattern +package problem_456 func find132pattern(nums []int) bool { ak, ajStack := -1<<31, make([]int, 0, len(nums)) diff --git a/problems/132-pattern/132_pattern_test.go b/problems/132-pattern/132_pattern_test.go index 4571095cc..86c1d1601 100644 --- a/problems/132-pattern/132_pattern_test.go +++ b/problems/132-pattern/132_pattern_test.go @@ -1,4 +1,4 @@ -package p_132_pattern +package problem_456 import "testing" diff --git a/problems/2-keys-keyboard/2_keys_keyboard.go b/problems/2-keys-keyboard/2_keys_keyboard.go index d19b4b08a..35dff5031 100644 --- a/problems/2-keys-keyboard/2_keys_keyboard.go +++ b/problems/2-keys-keyboard/2_keys_keyboard.go @@ -1,4 +1,4 @@ -package p_2_keys_keyboard +package problem_650 func minSteps(n int) int { if n == 1 { diff --git a/problems/2-keys-keyboard/2_keys_keyboard_test.go b/problems/2-keys-keyboard/2_keys_keyboard_test.go index 983ca874c..556bd70e0 100644 --- a/problems/2-keys-keyboard/2_keys_keyboard_test.go +++ b/problems/2-keys-keyboard/2_keys_keyboard_test.go @@ -1,4 +1,4 @@ -package p_2_keys_keyboard +package problem_650 import "testing" diff --git a/problems/24-game/24_game.go b/problems/24-game/24_game.go index 8159746af..64e24aeb9 100644 --- a/problems/24-game/24_game.go +++ b/problems/24-game/24_game.go @@ -1,4 +1,4 @@ -package p_24_game +package problem_679 import "sort" diff --git a/problems/24-game/24_game_test.go b/problems/24-game/24_game_test.go index 6a9b2ee00..69064ef6f 100644 --- a/problems/24-game/24_game_test.go +++ b/problems/24-game/24_game_test.go @@ -1,4 +1,4 @@ -package p_24_game +package problem_679 import "testing" diff --git a/problems/3sum-closest/3sum_closest.go b/problems/3sum-closest/3sum_closest.go index 1dfd50bb6..576a6c782 100644 --- a/problems/3sum-closest/3sum_closest.go +++ b/problems/3sum-closest/3sum_closest.go @@ -1,4 +1,4 @@ -package p_3sum_closest +package problem_16 import ( "math" diff --git a/problems/3sum-closest/3sum_closest_test.go b/problems/3sum-closest/3sum_closest_test.go index 8c43a52b5..27a0cebab 100644 --- a/problems/3sum-closest/3sum_closest_test.go +++ b/problems/3sum-closest/3sum_closest_test.go @@ -1,4 +1,4 @@ -package p_3sum_closest +package problem_16 import "testing" diff --git a/problems/3sum-smaller/3sum_smaller.go b/problems/3sum-smaller/3sum_smaller.go index fbb5ac27c..58e8c0362 100644 --- a/problems/3sum-smaller/3sum_smaller.go +++ b/problems/3sum-smaller/3sum_smaller.go @@ -1 +1 @@ -package p_3sum_smaller +package problem_258 diff --git a/problems/3sum-smaller/3sum_smaller_test.go b/problems/3sum-smaller/3sum_smaller_test.go index fbb5ac27c..58e8c0362 100644 --- a/problems/3sum-smaller/3sum_smaller_test.go +++ b/problems/3sum-smaller/3sum_smaller_test.go @@ -1 +1 @@ -package p_3sum_smaller +package problem_258 diff --git a/problems/3sum-with-multiplicity/3sum_with_multiplicity.go b/problems/3sum-with-multiplicity/3sum_with_multiplicity.go index f528bcf78..8128b1149 100644 --- a/problems/3sum-with-multiplicity/3sum_with_multiplicity.go +++ b/problems/3sum-with-multiplicity/3sum_with_multiplicity.go @@ -1 +1 @@ -package p_3sum_with_multiplicity +package problem_923 diff --git a/problems/3sum-with-multiplicity/3sum_with_multiplicity_test.go b/problems/3sum-with-multiplicity/3sum_with_multiplicity_test.go index f528bcf78..8128b1149 100644 --- a/problems/3sum-with-multiplicity/3sum_with_multiplicity_test.go +++ b/problems/3sum-with-multiplicity/3sum_with_multiplicity_test.go @@ -1 +1 @@ -package p_3sum_with_multiplicity +package problem_923 diff --git a/problems/3sum/3sum.go b/problems/3sum/3sum.go index bdd2f1f0b..97cf222b4 100644 --- a/problems/3sum/3sum.go +++ b/problems/3sum/3sum.go @@ -1,4 +1,4 @@ -package p_3sum +package problem_15 import "sort" diff --git a/problems/3sum/3sum_test.go b/problems/3sum/3sum_test.go index 5ebb2ac31..1cb95d0f5 100644 --- a/problems/3sum/3sum_test.go +++ b/problems/3sum/3sum_test.go @@ -1,4 +1,4 @@ -package p_3sum +package problem_15 import ( "reflect" diff --git a/problems/4-keys-keyboard/4_keys_keyboard.go b/problems/4-keys-keyboard/4_keys_keyboard.go index beeeaedb5..bb66c3119 100644 --- a/problems/4-keys-keyboard/4_keys_keyboard.go +++ b/problems/4-keys-keyboard/4_keys_keyboard.go @@ -1 +1 @@ -package p_4_keys_keyboard +package problem_651 diff --git a/problems/4-keys-keyboard/4_keys_keyboard_test.go b/problems/4-keys-keyboard/4_keys_keyboard_test.go index beeeaedb5..bb66c3119 100644 --- a/problems/4-keys-keyboard/4_keys_keyboard_test.go +++ b/problems/4-keys-keyboard/4_keys_keyboard_test.go @@ -1 +1 @@ -package p_4_keys_keyboard +package problem_651 diff --git a/problems/4sum-ii/4sum_ii.go b/problems/4sum-ii/4sum_ii.go index 8ce3c4cf7..40f8ff2a8 100644 --- a/problems/4sum-ii/4sum_ii.go +++ b/problems/4sum-ii/4sum_ii.go @@ -1,4 +1,4 @@ -package p_4sum_ii +package problem_454 func fourSumCount(A []int, B []int, C []int, D []int) int { ans, n := 0, len(A) diff --git a/problems/4sum-ii/4sum_ii_test.go b/problems/4sum-ii/4sum_ii_test.go index 6585c9659..e1c4489e6 100644 --- a/problems/4sum-ii/4sum_ii_test.go +++ b/problems/4sum-ii/4sum_ii_test.go @@ -1,4 +1,4 @@ -package p_4sum_ii +package problem_454 import "testing" diff --git a/problems/4sum/4sum.go b/problems/4sum/4sum.go index 5bfd79a38..ba8bf3162 100644 --- a/problems/4sum/4sum.go +++ b/problems/4sum/4sum.go @@ -1,4 +1,4 @@ -package p_4sum +package problem_18 import "sort" diff --git a/problems/4sum/4sum_test.go b/problems/4sum/4sum_test.go index 3892427e8..a1f3d72f0 100644 --- a/problems/4sum/4sum_test.go +++ b/problems/4sum/4sum_test.go @@ -1,4 +1,4 @@ -package p_4sum +package problem_18 import ( "reflect"