Skip to content

Instantly share code, notes, and snippets.

View c650's full-sized avatar
🛰️

c650

🛰️
View GitHub Profile
itertools::base_iter<int, std::vector<int>::iterator>(a.begin(), a.end())
.map<int>([](int a) { return 3 * a; })
.reduce<int>(0, [](int& acc, int x) { return acc + x; });
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
int main() {
std::vector<int> v{1,2,3,4};
std::vector<int> b;
fn main() {
let v = vec![1,2,3,4];
let b = v.iter().map(|e| e * 2).filter(|e| e % 6 == 0).fold(0, |acc, x| acc + x);
println!("{:?}", b);
}
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::vector<int> v{1,2,3,4};
std::vector<int> b;
std::transform(v.begin(), v.end(), std::back_inserter(b), [](int a){return 2 * a;});
fn main() {
let v = vec![1,2,3,4];
let b: Vec<i32> = v.iter().map(|e| e * 2).collect();
println!("{:?}", b);
}
@c650
c650 / stats-crap.rb
Created September 9, 2018 16:29
stats stuff
arr = []
loop do
s = gets.chomp
break if s == "END"
arr << s.to_f
end
sum = 0
arr.map{|e| sum += e}
#include <bits/stdc++.h>
#define FI first
#define SE second
typedef long long ll;
typedef std::pair<ll,ll> pairll;
const int rot_delta[4] = {3,0,0,1};
#!/bin/env ruby
CASES = 25
PRODUCE_DATA = false
STDERR.puts "gif program ?"
program = gets.chomp
`g++ --std=c++17 -Wall -O2 -o #{program}.out #{program}.cpp`
@c650
c650 / correlation-inator.rb
Last active June 19, 2018 17:38
Takes CSV. Calculates pairwise correlations (excludes empty cells)
require 'csv'
# correlation-inator.rb
# by Charles (c650)
# Takes in CSV, calculates pairwise correlations but excluding empty cells
class Pair
attr_accessor :a, :b
def initialize(a, b)
a.gsub!(/#/,"")
@c650
c650 / judge.rb
Last active June 18, 2018 02:29
A very crappy judging script
#!/bin/env ruby
# A very crappy judging script
if ARGV.length < 2
puts "Usage: ./program.rb [executable] [data folder]"
exit
end
Dir.chdir(ARGV[1])
Dir.glob("case*").sort.each do |testcase|