Skip to content

Commit fe9269c

Browse files
committed
[rust] Adiciona Algoritmos torre de hanoi
1 parent 2b04411 commit fe9269c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
2727
| [Mín. e Máx. Recursivo][28] | [C/C++](./src/c/MaxMinRecursivo.c) | Java | [Python](./src/python/maximo_minimo_recursivo.py) | [Go](./src/go/maximominimo/MaximoMinimo.go) | Ruby | [JS](./src/javascript/RecursiveMinAndMax.js) | Pascal | Swift | Rust |
2828
| Mín. e Máx. D&C | C/C++ | Java | [Python](./src/python/maximo_recursivo_dc.py) | [Go](./src/go/maximominimo/MaximoMinimo.go) | Ruby | JS | Pascal | Swift | Rust |
2929
| [Passeio do Cavalo][30] | C/C++ | Java | [Python](./src/python/passeio_do_cavalo.py) | Go | Ruby | JS | Pascal | Swift | Rust |
30-
| [Torre de Hanói][33] | C/C++ | [Java](./src/java/TorreDeHanoi.java) | [Python](./src/python/torre_de_hanoi.py) | [Go](./src/go/hanoi/hanoi.go) | [Ruby](./src/ruby/Hanoi.rb) | [JS](./src/javascript/TorreDeHanoi.js) | Pascal | Swift | Rust |
30+
| [Torre de Hanói][33] | C/C++ | [Java](./src/java/TorreDeHanoi.java) | [Python](./src/python/torre_de_hanoi.py) | [Go](./src/go/hanoi/hanoi.go) | [Ruby](./src/ruby/Hanoi.rb) | [JS](./src/javascript/TorreDeHanoi.js) | Pascal | Swift | [Rust](./src/rust/torre_hanoi.rs) |
3131
| [Algoritmo Genético][51] | C/C++ | Java | [Python](./src/python/genetic_algorithm.py) | Go | Ruby | JS | Pascal | Swift | Rust |
3232

3333
| Estruturas de Dados | C/C++ | Java | Python | Go | Ruby | JS | Pascal | Swift | Rust |

src/rust/torre_hanoi.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn torre_hanoi(pin0: i32, pin2: i32, pin1: i32, num: i32){
2+
if num == 1{
3+
println!("Move from {} to {}", pin0, pin2)
4+
}else{
5+
torre_hanoi(pin0, pin1, pin2, num - 1);
6+
torre_hanoi(pin0, pin2, pin1, 1);
7+
torre_hanoi(pin1, pin2, pin0, num - 1);
8+
}
9+
}
10+
fn main(){
11+
torre_hanoi(0,2,1,3);
12+
}

0 commit comments

Comments
 (0)