์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- Operating System
- Python challenge
- ๋ฌ์คํธ ์์
- ์๋ฐ ๊ธฐ์ด
- Python
- Rust
- ubuntu
- ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ
- ํ์ด์ฌ ์ฒผ๋ฆฐ์ง
- ๋ฐ์ดํฐ ํต์
- Database
- ๋ฐฑ์ค
- ์๋ฐ
- ๋ฐฑ์ค ๋ฌ์คํธ
- OS
- ์ฐ๋ถํฌ
- ํ์ด์ฌ
- ํ์ด์ฌ ์ฑ๋ฆฐ์ง
- ์ด์์ฒด์
- ์ค๋ผํดDB
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ์๋ฐ ๊ฐ๋
- ๋ฌ์คํธ
- ์๊ณ ๋ฆฌ์ฆ
- ๋ฌ์คํธ ํ๋ก๊ทธ๋๋ฐ ๊ณต์ ๊ฐ์ด๋
- Reversing
- data communication
- C
- ์ค๋ผํด
- java
Archives
- Today
- Total
IT’s Portfolio
[Algorithm] Baekjoon - ์ฌํ 1 ๋จ๊ณ ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
๐ป Baekjoon Deepening 1 Stage
Sprout
Basic Code
fn main(){
print!(r#" ,r'"7
r`-_ ,' ,/
\. ". L_r'
`~\/
|
|"#);
}
King, Queen, Rook, Bishop, Knight, Pawn
Basic Code
use std::io;
fn main() {
const P: [i32; 6] = [1, 1, 2, 2, 2, 8];
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
for (i, v) in
buf.split_whitespace().map(|x| x.parse::<i32>().unwrap()).enumerate() {
print!("{} ", P[i]-v);
}
}
Draw Stars - 7
Basic Code
use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let n = buf.trim().parse::<usize>().unwrap();
let mut t = 1;
for i in 1..=n {
if i==1 {
println!("{:>x$}", "*".repeat(t), x=n+(i-1));
} else {
println!("{:>x$}", "*".repeat(t+i), x=n+(i-1));
t = i;
}
}
t = n-1;
for i in (0..n-1).rev() {
if i==0 {
println!("{:>x$}", "*".repeat(t), x=n+i);
} else {
println!("{:>x$}", "*".repeat(t+i), x=n+i);
t = i;
}
}
}
Improvement Code - chain & trim_end
use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let n = buf.trim().parse::<usize>().unwrap();
let w = n*2-1;
for i in (1..=n).chain((1..n).rev()) {
let r = format!("{:^w$}", "*".repeat(i*2-1));
println!("{}", r.trim_end());
}
}
trait_Iterator_method_chain in Official Document
str_method_trim_end in Official Document
Palindrome
Basic Code
use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
if buf.trim() == buf.trim().chars().rev().collect::<String>() {
println!("1");
} else {
println!("0");
}
}
Word Study
Basic Code
use std::{io, collections::HashMap};
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let mut h: HashMap<char, u32> = HashMap::new();
let i = buf.trim().to_ascii_uppercase();
let mut r = vec![('A', 0)];
for j in i.chars() {
let c = h.entry(j).or_insert(0);
*c+=1;
}
for (k, v) in h {
if v > r[0].1 {
r.clear();
r.push((k, v));
} else if v == r[0].1 {
r.push((k, v));
}
}
if r.iter().count() > 1 {
println!("?");
} else {
println!("{}", r[0].0);
}
}
Croatia Alphabet
Basic Code
use std::io;
fn main() {
const C: [&str; 8] = [
"c=", "c-", "dz=", "d-",
"lj", "nj", "s=", "z="
];
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let mut m = String::from(buf.trim());
for i in C {
if m.contains(i) {
m = m.replace(i, "^");
}
}
println!("{}", m.len());
}
Group Word Checker
Basic Code
use std::io::{self, *};
fn main() {
let mut buf = String::new();
io::stdin().read_to_string(&mut buf).unwrap();
let mut cnt = 0;
for w in buf.lines().skip(1) {
let mut c = [0; 26];
let t = w.trim().bytes();
c[(t.clone().nth(0).unwrap()-97) as usize] = 1;
for i in 1..w.trim().len() {
if t.clone().nth(i).unwrap() == t.clone().nth(i-1).unwrap() {
continue;
} else if t.clone().nth(i).unwrap() != t.clone().nth(i-1).unwrap() &&
c[(t.clone().nth(i).unwrap()-97) as usize] == 1 {
cnt+=1;
break;
} else {
c[(t.clone().nth(i).unwrap()-97) as usize] = 1;
}
}
}
println!("{}", buf.lines().skip(1).count()-cnt);
}
Your Rating is
Basic Code
use std::io::{self, *};
fn make_array(m: &str) -> (Vec<f64>, Vec<f64>) {
let mut g: Vec<f64> = Vec::new();
let mut r: Vec<f64> = Vec::new();
for l in m.lines() {
let mut t = l.split(' ');
if t.clone().nth(2).unwrap() == "P" {
continue;
} else {
g.push(t.nth(1).unwrap().parse::<f64>().unwrap());
r.push(
match t.nth(0).unwrap() {
"A+" => 4.5,
"A0" => 4.0,
"B+" => 3.5,
"B0" => 3.0,
"C+" => 2.5,
"C0" => 2.0,
"D+" => 1.5,
"D0" => 1.0,
"F" => 0.0,
_ => -1.0,
}
);
}
}
(g, r)
}
fn main() {
let mut buf = String::new();
io::stdin().read_to_string(&mut buf).unwrap();
let mut a = 0.0;
let (g, r) = make_array(buf.trim());
if g.is_empty() {
println!("{:.6}", a);
} else {
for i in 0..g.len() {
a+=g[i]*r[i];
}
println!("{:.6}", a/g.iter().sum::<f64>());
}
}
728x90
๋ฐ์ํ
'Development Study > Rust' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Rust] Start Rust (Day 20) - Writing Automated Tests (0) | 2023.08.19 |
---|---|
[Algorithm] Baekjoon - 2์ฐจ์ ๋ฐฐ์ด ๋จ๊ณ (0) | 2023.08.10 |
[Algorithm] Baekjoon - ๋ฌธ์์ด ๋จ๊ณ (0) | 2023.07.31 |
[Algorithm] Baekjoon - 1์ฐจ์ ๋ฐฐ์ด ๋จ๊ณ (0) | 2023.07.13 |
[Rust] Start Rust (Day 19) - Generic Types, Traits, and Lifetimes (1) | 2023.07.01 |
Comments