Skip to content

Instantly share code, notes, and snippets.

@bChiquet
bChiquet / .py
Created March 26, 2021 17:09
json+argparse
import argparse, json
parser = argparse.ArgumentParser(description='take a json as param')
parser.add_argument('json', metavar='N', type=str, nargs='?',
help='some json')
args = parser.parse_args()
print (json.loads(args.json))
@bChiquet
bChiquet / Main.elm
Created March 12, 2021 14:17
Some Elm Code
module Main exposing (..)
import Browser
import Html exposing (text, div, button, Html)
import Html.Events exposing (onClick)
import Http exposing (get)
import Image exposing (Image)
type alias Model = String
fn main() {
println!("Hello, world!");
}
fn process(input: &str) -> Vec<Vec<String>> {
input.split("\n")
.map(|line| line.split(','))
.map(|fields| fields.map(|field| field.to_string()))
.map(|fields| fields.collect::<Vec<_>>())
.collect::<Vec<_>>()
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let problem = stdin.lock().lines().map(|x| x.unwrap()).collect::<Vec<String>>();
let result = solve_problem(&problem[0][..], &problem[1][..]);
println!("{}", result);
}
fn solve_problem(start_line: &str, target_line: &str) -> i32 {
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let problem = stdin.lock().lines().map(|x| x.unwrap()).collect::<Vec<String>>();
let result = solve_problem(&problem[0][..], &problem[1][..], &one_then_zeros()[..]);
println!("{}", result);
}
fn solve_problem(start_line: &str, target_line: &str, modification_requirement :&str) -> i32 {
use std::io::{self, BufRead};
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
fn main() {
let stdin = io::stdin();
let problem = stdin.lock().lines().map(|x| x.unwrap()).collect::<Vec<String>>();
let mut result = Vec::new();
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let problem = stdin.lock().lines().map(|x| x.unwrap()).collect::<Vec<String>>();
let result = solve_problem(&problem[0][..], &problem[1][..]);
println!("{}", result);
}
fn solve_problem(start_line: &str, target_line: &str) -> i32 {
import Test.Hspec
import Data.Function ((&))
main :: IO ()
main = hspec $ do
describe "the car insurance" $ do
it "new drivers pay their full premium" $ do
premium NewDriver `shouldBe` 100
it "drivers get 5% rebate after 1 year" $ do
@bChiquet
bChiquet / .hs
Created January 17, 2020 09:30
aoc_2
module Lib
( Program
, Cursor
, eval
, (|+|)
, at, writeIn
, Value(..)
) where
import Control.Monad (liftM2)
@bChiquet
bChiquet / .y
Created November 23, 2019 17:56
Quoted from parser.y
Coeffect :: { Coeffect }
: INT { let TokenInt _ x = $1 in CNat x }
| '∞' { infinity }
| FLOAT { let TokenFloat _ x = $1 in CFloat $ myReadFloat x }
| CONSTR { case (constrString $1) of
"Public" -> Level publicRepresentation
"Private" -> Level privateRepresentation
"Unused" -> Level unusedRepresentation
"Inf" -> infinity