This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
#include <algorithm> | |
int main() { | |
std::function<const int &(const int &, const int &)> func = | |
(const int & (*)(const int &, const int &)) & std::min; | |
std::cout << func(1, 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Solution | |
{ | |
// Algorithm discussion at https://www.hackerrank.com/challenges/volleyball-match/editorial referenced | |
// (Not enough time to develop algorithm!) | |
class Solution | |
{ | |
public const int Modular = 1000000007; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string BytesToString(long byteSize) | |
{ | |
const string format = "{0} {1}"; | |
const int orderBase = 1024; | |
var units = new[] {"B", "KB", "MB", "GB", "TB", "PB", "EB"}; | |
if (byteSize == 0) | |
return "0 B"; | |
var order = Convert.ToInt32(Math.Floor(Math.Log(byteSize, orderBase))); | |
var rescaledSize = Math.Round(byteSize/Math.Pow(orderBase, order), 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.spoj.pl/problems/PALIN/ | |
// Concept: http://www.algorithmist.com/index.php/SPOJ_PALIN | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
bool lessThan(vector<int> obj1, vector<int> obj2); | |
void helper(const vector<int> &input, vector<int> &output, int stage=0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mean medium and mode | |
#include <iostream> | |
#include <algorithm> | |
#include <iterator> | |
#include <vector> | |
#include <map> | |
using namespace std; | |
// This is a variant of merge sort that does mode counts and sums all the items. | |
template <typename InputIterator, typename OutputIterator, typename ValueType, typename SumType> void mergesort(InputIterator start, InputIterator end, OutputIterator output, SumType &sum, map<ValueType, int> &mode){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quicksort - see makefile for compiling options with G++. | |
// Will not compile in VS2012 due to initialiser syntax in main() for std::vector | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> // Required | |
#include <iterator> //Required | |
#include <stdlib.h> // Required | |
#include <time.h> // Required | |
// Function Prototypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_to_string(lst, delim=''): | |
"""Concatenate a list of strings to one single string. Specify a delimiter to append to end of each fragment""" | |
return reduce((lambda a, b: a + delim + b), lst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def strip(content): | |
"""Strip Empty Variables""" | |
if (type(content) is list): | |
return strip_list(content) | |
elif (type(content) is dict): | |
return strip_dictionary(content) | |
elif (content): | |
return content | |
else: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep -I -E "[^\n]\'" |
OlderNewer