Skip to content

Instantly share code, notes, and snippets.

@mattsan
mattsan / gist:767917
Created January 6, 2011 14:04
lisp by ruby
Global_env =
{
'+' => :+,
'-' => :-,
'*' => :*,
'/' => :/,
'not' => :not,
'>' => :>,
'<' => :<,
'>=' => :>=,
module Main where
import IO
type Function = [Atom] -> Atom
type Env = [(String, Atom)]
data Atom = INT Integer
| REAL Double
#ifndef EMATTSAN_TABTOSPACE_H
#define EMATTSAN_TABTOSPACE_H
namespace emattsan
{
template<typename InputIterator, typename OutputIterator>
OutputIterator tabToSpace(int tabSize, InputIterator begin, InputIterator end, OutputIterator out)
{
int spacingSize = tabSize;
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <algorithm>
void removeSuit(std::string::value_type& c)
{
switch(c)
{
@mattsan
mattsan / file0.cpp
Created November 13, 2012 14:10
第五回オフラインリアルタイムどう書くの回答例(C++) ref: http://qiita.com/items/33651c2c9ec1fe7aa285
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <functional>
@mattsan
mattsan / Answer.hs
Created November 13, 2012 14:13
第五回オフラインリアルタイムどう書くの回答例(Haskell) ref: http://qiita.com/items/4a1b341f45ebf1d05fc1
module Answer(solve, input_cards) where
import Data.List
rank '3' = 1
rank '4' = 2
rank '5' = 3
rank '6' = 4
rank '7' = 5
@mattsan
mattsan / file0.cpp
Created November 16, 2012 10:07
第五回オフラインリアルタイムどう書くの回答例(C++ その2) ref: http://qiita.com/items/aeec54980c454c3719ef
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
// 札の強さ(1〜14)、出せる札の条件を満たしていない場合は0
std::size_t getRank(const std::string& s)
{
static const std::string ranks = " 3456789TJQKA2o";
@mattsan
mattsan / answer.cpp
Created December 25, 2012 13:49
第六回オフラインリアルタイムどう書くの参考問題の回答例。C++ で。 ref: http://qiita.com/items/d690182ee73302ec4ff4
#include "answer.hpp"
#include <bitset>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
typedef std::bitset<100> Bitset;
module Answer(solve) where
type Pos = (Int, Int)
between x1 x2 x = (x1 - x) * (x2 - x) <= 0
inside x1 y1 x2 y2 x y = (between x1 x2 x) && (between y1 y2 y)
l_intersect :: (Pos, Pos, Pos) -> (Pos, Pos, Pos) -> String
l_intersect ((x11, y11), (x12, y12), (x13, y13)) ((x21, y21), (x22, y22), (x23, y23)) =
@mattsan
mattsan / backtracking.cpp
Created February 11, 2013 12:10
backtracking
#include <iostream>
#include <string>
template<typename ITEM, typename CONTAINER>
int search(const ITEM& item, const CONTAINER& container)
{
for(int i = 0; i < container.size() - 2; ++i)
{
if((container[i] == item) && (container[i + 1] == item) && (container[i + 2] == item))
{