Skip to content

Instantly share code, notes, and snippets.

View mucahitkaradag's full-sized avatar

mucahitkaradag

  • Turkey
View GitHub Profile
/*
word frequency program in cpp
Mucahit Karadag
compiler is g++ v6.3.1
*/
#include<iostream>
#include<string>
using namespace std;
class Fixnum
def random_split(set = nil, repeats = false)
set ||= 1..self
set = [*set]
return if set.empty? || set.min > self || set.inject(0, :+) < self
tried_numbers = []
while (not_tried = (set - tried_numbers).select {|n| n <= self }).any?
tried_numbers « number = not_tried.sample
return [number] if number == self
new_set = set.dup