From 224bf52811c230567a47cb4badbbe20a3afd2f41 Mon Sep 17 00:00:00 2001 From: m4siri Date: Mon, 1 Dec 2025 17:16:26 +0545 Subject: fix: init script --- 05_longest-palindromic-substring/Cargo.toml | 6 ++++++ 05_longest-palindromic-substring/src/main.rs | 3 +++ init.nu | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 05_longest-palindromic-substring/Cargo.toml create mode 100644 05_longest-palindromic-substring/src/main.rs diff --git a/05_longest-palindromic-substring/Cargo.toml b/05_longest-palindromic-substring/Cargo.toml new file mode 100644 index 0000000..0b94a20 --- /dev/null +++ b/05_longest-palindromic-substring/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "longest-palindromic-substring" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/05_longest-palindromic-substring/src/main.rs b/05_longest-palindromic-substring/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/05_longest-palindromic-substring/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/init.nu b/init.nu index def503f..7039947 100755 --- a/init.nu +++ b/init.nu @@ -5,11 +5,9 @@ def main [ name: string idx?: int ] { let idx = if ($idx | is-empty) { ( glob "*_*" - | split row '/' - | get (($in | length) - 1) - | split row '_' - | get 0 - | into int + | each {|l| $l | split row '/' | last | split row '_' | first | into int } + | sort + | last | $in + 1 | (if $in < 10 { $"0($in)" } else { $in } ) ) @@ -31,7 +29,9 @@ def main [ name: string idx?: int ] { cargo new $problem_name --name $name --vcs none if $env.LAST_EXIT_CODE == 0 { - rm -r $tmp_dir + if ($existing | is-not-empty) { + rm -r $tmp_dir + } } else { mv $tmp_dir $problem_name } -- cgit v1.2.3