Skip to content

Instantly share code, notes, and snippets.

View hajimehoshi's full-sized avatar
:octocat:
ギットハブ

Hajime Hoshi hajimehoshi

:octocat:
ギットハブ
View GitHub Profile
@hajimehoshi
hajimehoshi / gist:63795
Created February 13, 2009 08:26
ゼル伝
;;; ゼルダの伝説 (SFC) で、鍵と扉がそれぞれ n 個のとき、
;;; ダンジョンのとりうる状態数を返す zelda 関数 (仮)
(use srfi-1)
(define (zelda n)
(define (combination n m)
(/ (apply * (iota m (+ (- n m) 1) 1))
(apply * (iota m 1 1))))
(define (sum list)
package main
import (
"fmt"
)
func main() {
a := [...][4]int{
[...]int{1,2,3,4},
[...]int{1,2,3,4},
$ gcc-mp-4.5 -o test -std=c++0x -L/opt/local/lib test.cpp
Undefined symbols:
"operator new(unsigned long)", referenced from:
std::_Function_base::_Base_manager<main::{lambda()#1}>::_M_clone(std::_Any_data&, std::_Function_base::_Base_manager<main::{lambda()#1}> const&, std::integral_constant<bool, false>) in ccBk7Dwv.o
std::_Function_base::_Base_manager<main::{lambda()#1}>::_M_init_functor(std::_Any_data&, {lambda()#1}&&, std::integral_constant<bool, false>) in ccBk7Dwv.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
main::{lambda()#1}::operator()() const in ccBk7Dwv.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccBk7Dwv.o
"operator delete(void*)", referenced from:
#include <iostream>
#include <boost/range.hpp>
class foo {
private:
int values_[10];
public:
typedef decltype(values_) values_type;
foo()
: values_{3, 1, 4, 1, 5, 9, 2, 6, 5, 3} {
#include <algorithm>
#include <iostream>
#include <boost/range.hpp>
template<class Values>
int foo(Values values) {
std::for_each(boost::begin(value), boost::end(values), [](int& value) {
std::cout << value << std::endl;
});
}
(1..?d).each{|i|puts i%15>0?i%5>0?i%3>0?i:'Fizz':'Buzz':'FizzBuzz'}
@hajimehoshi
hajimehoshi / Main.hs
Created September 20, 2011 03:25
Simple Web App in Haskell
import Blaze.ByteString.Builder (fromByteString)
import Data.CaseInsensitive (mk)
import qualified Data.ByteString.Char8 as C8
import qualified Data.ByteString.UTF8 as U8
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp (run)
myApp :: Application
myApp _ = do
@hajimehoshi
hajimehoshi / Main.hs
Created September 30, 2011 02:33
Logic Puzzle (ID: O382PX)
import Data.List
import Data.Maybe
main :: IO ()
main = do
putStrLn $ show $ head solves
solves :: [[[Int]]]
solves = [state |
state <- initStates 3 5,
@hajimehoshi
hajimehoshi / fizzBuzz.hs
Created October 9, 2011 04:48
FizzBuzz in Haskell
main :: IO ()
main = print $ map fizzBuzz [1..]
fizzBuzz :: Integer -> String
fizzBuzz n
| n `rem` 15 == 0 = "FizzBuzz"
| n `rem` 3 == 0 = "Fizz"
| n `rem` 5 == 0 = "Buzz"
| otherwise = show n