Skip to content

Instantly share code, notes, and snippets.

View aadimator's full-sized avatar

Aadam aadimator

View GitHub Profile
@aadimator
aadimator / discount.py
Last active August 12, 2017 13:55
Student Discount
def create(self, cr, uid, vals, context=None, check=True):
# Calculate the acutal_fee and discounts again as readonly fields aren't
# stored in the database.
std_id = vals.get('student_id')
res = self.onchange_get_actual_fee(cr, uid, std_id, std_id, vals.get('fee_type'), context)
acutal_fee = res.get('value').get('actual_fee')
discounted_fee = acutal_fee - (vals.get('discount') * acutal_fee/100)
vals.update({'actual_fee':acutal_fee})
Verifying that "aadimator.id" is my Blockstack ID. https://onename.com/aadimator
#include <iostream>
using namespace std;
int main() {
int t, a, output = 0;
cin >> t;
while(t--){
cin >> a;
output += a;
}
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
print(sum(arr))
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
#include <iostream>
using namespace std;
int main(){
int t;
cin >> t;
for(int a0 = 0; a0 < t; a0++){
int n;
cin >> n;
@aadimator
aadimator / different_summands.cpp
Created July 25, 2016 02:51
Pairwise Distinct Summands
#include <iostream>
#include <vector>
using std::vector;
vector<int> optimal_summands(int n) {
// using the algorithm described in the pdf
vector<int> summands;
for (int k = n, l = 1; k > 0; l++) {
if (k <= 2 * l) {
@aadimator
aadimator / covering_segments.cpp
Created July 25, 2016 02:50
Covering Segments by Points
#include <algorithm>
#include <iostream>
using std::vector;
struct Segment {
int start, end;
};
vector<int> optimal_points(vector<Segment> &segments) {
@aadimator
aadimator / dot_product.cpp
Created July 25, 2016 02:49
Minimum Dot Product
#include <algorithm>
#include <iostream>
using std::vector;
long long min_dot_product(vector<int> a, vector<int> b) {
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end(), std::greater<int>());
long long result = 0;
for (int i = 0; i < a.size(); i++) {
@aadimator
aadimator / fractional_knapsack.cpp
Created July 25, 2016 02:49
Fractional Knapsack
#include <iostream>
#include <vector>
using std::vector;
int get_max_index (vector<int> weights, vector<int> values) {
int max_i = 0;
double max = 0;
for (int i = 0; i < weights.size(); i++) {