Skip to content

Commit 9ed6da5

Browse files
committed
zigzag準備
1 parent d0d4c8c commit 9ed6da5

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod longuest_palindromic;
33
mod longuest_sub;
44
mod palindrome;
55
mod two_sum;
6-
6+
mod zigzag;
77
fn main() {
88
// let result = two_sum::Solution::two_sum(nums, target);
99
// let result = palindrome::Solution::is_palindrome(121);
@@ -12,7 +12,11 @@ fn main() {
1212
// let target = "pwwkew".to_string();
1313
// let result = longuest_sub::Solution::length_of_longest_substring(target);
1414

15-
let target = "babad".to_string();
16-
let result = longuest_palindromic::Solution::longest_palindrome(target);
15+
// let target = "babad".to_string();
16+
// let result = longuest_palindromic::Solution::longest_palindrome(target);
17+
18+
let s = "PAYPALISHIRING".to_string();
19+
let num_rows = 3;
20+
let result = zigzag::Solution::convert(s, num_rows);
1721
println!("{:?}", result);
1822
}

src/zigzag.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pub struct Solution;
2+
impl Solution {
3+
pub fn convert(s: String, num_rows: i32) -> String {}
4+
}
5+
6+
#[cfg(test)]
7+
mod tests {
8+
use super::*;
9+
10+
#[test]
11+
fn test_1() {
12+
let s = "PAYPALISHIRING".to_string();
13+
let num_rows = 3;
14+
let result = "PAHNAPLSIIGYIR";
15+
assert_eq!(Solution::convert(s, num_rows), result);
16+
}
17+
18+
#[test]
19+
fn test_2() {
20+
let s = "PAYPALISHIRING".to_string();
21+
let num_rows = 4;
22+
let result = "PINALSIGYAHRPI";
23+
assert_eq!(Solution::convert(s, num_rows), result);
24+
}
25+
26+
#[test]
27+
fn test_3() {
28+
let s = "A".to_string();
29+
let num_rows = 1;
30+
let result = "A";
31+
assert_eq!(Solution::convert(s, num_rows), result);
32+
}
33+
}

0 commit comments

Comments
 (0)