Skip to content

Instantly share code, notes, and snippets.

View c650's full-sized avatar
🛰️

c650

🛰️
View GitHub Profile
@c650
c650 / __template.cpp
Last active July 2, 2018 15:42
competition template
/* c650Alpha __template.cpp */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FI first
#define SE second
typedef long long ll;
typedef std::pair<ll,ll> pairll;
@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|
@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!(/#/,"")
#!/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`
#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};
@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}
fn main() {
let v = vec![1,2,3,4];
let b: Vec<i32> = v.iter().map(|e| e * 2).collect();
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 = 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>
#include <numeric>
int main() {
std::vector<int> v{1,2,3,4};
std::vector<int> b;