Skip to content

Instantly share code, notes, and snippets.

View anisaraf's full-sized avatar

Ani Saraf anisaraf

  • Meta | ex-Datadog | ex-Google
  • San Francisco, CA
View GitHub Profile
@anisaraf
anisaraf / TheBoredomDivTwo.cxx
Created November 21, 2010 20:14
SOlution to SRM488 TheBoredomDivTwo
#include <iostream>
using namespace std;
class TheBoredomDivTwo {
public:
int find(int n, int m, int j, int b);
};
int TheBoredomDivTwo::find(int n, int m,int j, int b){
int PenLift::numTimes(vector<string> segments, int n)
{
transform(segments.begin(), segments.end(),
back_inserter(m_inLines), PenLift::getLine);
mergeLines();
intersectLines();
createGraph();
vector< Graph<Point> > g = m_graph.getConnectedGraphs();
if(n % 2 == 0)
return (g.size() - 1);
@anisaraf
anisaraf / PenLift.cxx
Created October 3, 2010 01:12
Solution to SRM144 Penlift
#include <sstream>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <set>
#include <list>
#include "graphs.h"
@anisaraf
anisaraf / Srm144Lottery.cxx
Created September 23, 2010 02:13
Solution to TopCoder:SRM144 Lottery
#include <sstream>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
unsigned long long factorialDivide(int num, int den){
unsigned long long rValue = 1;
@anisaraf
anisaraf / Srm144-300Dirty
Created September 21, 2010 04:18
Srm144-300Dirty
#include<vector>
#include<iostream>
using namespace std;
class BinaryCode {
public:
vector<string> decode(string message){
@anisaraf
anisaraf / Srm144300.cxx
Created September 21, 2010 04:02
Srm144BinaryCodeHerb
#include<vector>
#include<iostream>
using namespace std;
class BinaryCode {
private:
char decodeChar(const string& message, const string& decoded, int pos){
if(pos == 1) return (getIntFromChar(message[pos-1]) - getIntFromChar(decoded[pos-1]) + '0');
return (getIntFromChar(message[pos-1]) - getIntFromChar(decoded[pos-2]) - getIntFromChar(decoded[pos-1]) + '0');
}