Skip to content

Instantly share code, notes, and snippets.

View tolumide-ng's full-sized avatar

Tolumide Shopein tolumide-ng

  • Ex-Andela
  • Berlin, Germany
  • 07:05 (UTC -12:00)
View GitHub Profile
pub fn execute() {
use Graphs;
// Graphs::DAG::new(vec![(4, 3), (1, 2), (4, 1), (3, 1)]);
// Graphs::DAG::new(vec![(1, 2), (1, 4), (2, 3), (2, 4), (4, 3), (4, 5)]);
let result = Graphs::DAG::new(vec![(0, 2), (1, 2), (2, 3), (3, 4)]);
println!("THE RESULT >>> {:?}", result);
}
pub fn execute() {
use Graphs;
// Graphs::DAG::new(vec![(4, 3), (1, 2), (4, 1), (3, 1)]);
// Graphs::DAG::new(vec![(1, 2), (1, 4), (2, 3), (2, 4), (4, 3), (4, 5)]);
Graphs::DAG::new(vec![(0, 2), (1, 2), (2, 3), (3, 4)]);
}
mod Graphs {
use std::collections::HashMap;
mod Graph {
use std::collections::HashMap;
pub struct DAG {
graph: Option<HashMap<u8, Vec<u8>>,
}
impl DAG {
pub fn new(graph_info: Vec<(u8, u8)>) -> Vec<u8> {...}
mod Graph {
use std::collections::HashMap;
pub struct DAG {
graph: Option<HashMap<u8, Vec<u8>>,
}
impl DAG {
pub fn new(graph_info: Vec<(u8, u8)>) -> Vec<u8> {
mod Graph {
use std::collections::HashMap; //import hashmap from std lib
pub struct DAG { // define the DAG struct
graph: Option<HashMap<u8, Vec<u8>>,
}
}
@tolumide-ng
tolumide-ng / topo_final.rs
Created October 16, 2020 12:56
Topological sorting of Directed Acyclic Graph in Rust using DFS
pub fn execute() {
use Graphs;
// Graphs::DAG::new(vec![(4, 3), (1, 2), (4, 1), (3, 1)]);
// Graphs::DAG::new(vec![(1, 2), (1, 4), (2, 3), (2, 4), (4, 3), (4, 5)]);
let result = Graphs::DAG::new(vec![(0, 2), (1, 2), (2, 3), (3, 4)]);
println!("THE RESULT >>> {:?}", result);
}
@tolumide-ng
tolumide-ng / fibonacci.rs
Created June 6, 2020 00:05
Fibonacci Series in Rust
pub fn fibonnacci_recursive(n: i32) -> i32 {
if n < 2 {
n
} else {
fibonnacci_recursive(n - 1) + fibonnacci_recursive(n - 2)
}
}
}
@tolumide-ng
tolumide-ng / ls__001
Created June 5, 2020 23:09
Convert temperatures between Fahrenheit and Celsius.
pub mod temps {
use std::io;
pub fn calc_temp() -> () {
println!("Please enter a temperature you widh to convert");
println!("Expected format: 32C ==> to convert 32C to F");
println!("Expected format: 68F ==> to convert 32F to C");
let mut value_to_convert = String::new();

Keybase proof

I hereby claim:

  • I am tolumide-ng on github.
  • I am tolumide (https://keybase.io/tolumide) on keybase.
  • I have a public key ASCKYyiYbdRkE2w8PEDZqQDgb4VHVrXbBSMSoXZbkBtykgo

To claim this, I am signing this object:

@tolumide-ng
tolumide-ng / generateTime
Created April 30, 2020 12:51
Simple function to generate time by hours in AM/PM
dayTime() {
const differentTimes = [];
const timePeriods = ['AM', 'PM'];
for (let j = 0; j < timePeriods.length; j++){
for (let i = 1; i <= 12; i++){
const theTime = `${i}:00 ${timePeriods[j]}`
differentTimes.push(theTime)
}
}
console.log('the time periods>>>>>>>', differentTimes)