Skip to content

Instantly share code, notes, and snippets.

View coderodde's full-sized avatar

Rodion Efremov coderodde

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#define MAX(A, B) (((A) > (B))? (A) : (B))
#define MIN(A, B) (((A) < (B))? (A) : (B))
using System.Collections.Generic;
using System;
public sealed class BinaryHeap<T>
{
private readonly List<T> _elements;
private readonly Comparison<T> _compare;
/// <summary>
@coderodde
coderodde / main.cpp
Last active December 18, 2016 10:13
CodeReview Fibonacci heap performance demonstration
#include <iostream>
#include <algorithm>
#include <stdexcept>
#include <functional>
#include <unordered_map>
#include <vector>
template<typename K, typename P, typename Func = std::less<P>>
class fib_heap {
import random
import time
def merge_sort(numbers, start, end):
if start == end:
return
pivot_index = start + (end-start)//2
merge_sort(numbers, start, pivot_index)
merge_sort(numbers, pivot_index+1, end)
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
public class Main {
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
public class Main {
public class DigitSum {
public static int digit(int n) {
String numbers = n + "";
int sum = 0;
for (int x = 0; x < numbers.length(); x++) {
sum += Integer.parseInt(numbers.charAt(x) + "");
}
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Starting program...");
int n = readFromKeyboard();
using System;
class MainClass
{
private static int[] copyArray(int[] A, int start, int end)
{
int[] result = new int[end - start];
int cnt = 0;
def compute_loan_cut(principal, month_interest_rate, total_months):
divisor = (1 - pow(1 + month_interest_rate, total_months)) / (-month_interest_rate)
return pow(1 + month_interest_rate, total_months) * principal / divisor
print('Lowest Payment: ',end='')
print(round(minPayment,2))
print("Loan cut:", compute_loan_cut(balance, mRate, 24))