This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import qualified Data.List as List | |
{-- | |
This are the bingo numbers. Try to match the numbers in card. The numbers that matches any bingo card line | |
vertically/horizontally is the winner | |
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 | |
This are the bingo cards | |
22 13 17 11 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import qualified Data.Array as A | |
import Text.Printf (printf) | |
import qualified Data.Foldable as Foldable | |
import qualified Data.List as List | |
solve ::[[Char]] -> [(Int, Int)] | |
solve [] = [] | |
solve x = solve' $ List.transpose x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn majority_element(nums: Vec<i32>) -> i32 { | |
let mut mymap:HashMap<i32, i32> = HashMap::new(); | |
for n in &nums { | |
mymap.entry(*n).and_modify(|e| {*e += 1;}).or_insert(1); | |
} | |
for (k, v) in mymap.iter(){ | |
if v >= &((nums.len() as i32 / 2)){ | |
return *k; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//advent of code day 15 | |
use std::collections::HashMap; | |
use std::fmt::Formatter; | |
struct Pair (i32, Option<i32>); | |
pub trait NewValue { | |
fn is_new(&self) -> bool; | |
fn new_nbr(&self) -> i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
fn main() { | |
let m:[i32; 5] = [1,2,3,4,5]; | |
getvalues(Some(&m)); | |
} | |
fn getvalues(m:Option<&[i32]>) { | |
if let Some(k) = m{ | |
if k.len() > 0 { | |
println!("{:?}", k); | |
getvalues(Some(&k[1..])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-to-list 'load-path "/home/prasad/.emacs.d/extensions/rust-mode-master/") | |
(autoload 'rust-mode "rust-mode" nil t) | |
(add-hook 'rust-mode-hook | |
(lambda () (setq indent-tabs-mode nil))) | |
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::RefCell; | |
use std::rc::Rc; | |
use std::iter::FromIterator; | |
type TreeNode<T> = Option<Rc<RefCell<Node<T>>>>; | |
pub struct Node<T:PartialOrd+ std::fmt::Display>{ | |
pub value:T, | |
pub right: TreeNode<T>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::rc::Rc; | |
use std::cell::RefCell; | |
use std::iter::FromIterator; | |
pub type NodeType = Option<Rc<RefCell<TreeNode>>>; | |
#[derive(Debug, PartialEq, Eq)] | |
pub struct TreeNode { | |
pub val: i32, | |
pub left: NodeType, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fn getInfo(info: actix_web::web::Json<Info>) -> impl Responder { | |
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); | |
builder.set_verify(SslVerifyMode::NONE); | |
let myconnector = builder.build(); | |
let client = Client::builder() | |
.connector(Connector::new().ssl(myconnector).finish()) | |
.finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cargo.toml | |
// actix-web = {version="3.0.0", features=["openssl"]} | |
// openssl = "0.10" | |
// code | |
// ` | |
use actix_web::client::{Client, Connector}; | |
use openssl::ssl::{SslMethod, SslConnector, SslVerifyMode}; |