Skip to content

Instantly share code, notes, and snippets.

View ara-ta3's full-sized avatar

Arata Tanaka ara-ta3

View GitHub Profile
@ara-ta3
ara-ta3 / gist:fbaab9106c896cdfb4f7
Created August 10, 2014 13:23
SQLでfizzbuzz問題
CREATE DATABASE IF NOT EXISTS test_db;
USE test_db;
CREATE TABLE IF NOT EXISTS unya
(
id INT(11),
message TEXT
);
DROP PROCEDURE IF EXISTS find_treasure;
DELIMITER //
CREATE PROCEDURE find_treasure()
@ara-ta3
ara-ta3 / fizzbuzz.scala
Created August 24, 2014 10:31
scalaでfizzbuzz問題
package com.main
object Fizzbuzz {
def main(args:Array[String]){
this.run(15).zipWithIndex foreach {
case(x,i) => println( (i+1) + " : " + x)
}
}
def run(max:Int):Seq[String] = {
@ara-ta3
ara-ta3 / fibonacci
Created September 21, 2014 08:27
schemeで遊ぼうと思った
(define (fib n)
(if (> n 0)
(+ (fib (- n 1)) (fib (- n 2)))
1
))
(print (fib 5) )
(print (fib 1) )
(print (fib 2) )
@ara-ta3
ara-ta3 / httpテスト
Created September 22, 2014 15:31
countがどんどん増えていくことを試したかった
var http = require('http');
var count = 0;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n' + count++);
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
@ara-ta3
ara-ta3 / cto-challenge-level3.php
Last active August 29, 2015 14:07
CTOからの挑戦状 L3
<?php
class CouponMaster
{
const COUPON_TYPE_RATE = 'rate';
const COUPON_TYPE_FIXED = 'fixed';
private $coupons = [
'10%' => [
'type' => self::COUPON_TYPE_RATE,
(define (selectOptimalCoupons amount myCouponList)
(consume amount (sort myCouponList >) (list))
)
(define (consume amount coupons usedCoupons)
(if (null? coupons)
usedCoupons
(if (>= amount (car coupons))
(consume (- amount (car coupons)) (cdr coupons) (append usedCoupons (list (car coupons))))
(consume amount (cdr coupons) usedCoupons))
@ara-ta3
ara-ta3 / httptest.go
Created October 14, 2014 11:29
golangでhttp get request
package main
import (
"io/ioutil"
"net/http"
)
func main() {
response, _ := http.Get("http://google.com")
body, _ := ioutil.ReadAll(response.Body)
@ara-ta3
ara-ta3 / install-vim74.sh
Last active August 29, 2015 14:10
Install Vim 7.4 Script
#! /bin/sh
yum install -y gcc git mercurial ncurses-devel lua lua-devel
cd /usr/local/src
hg clone https://vim.googlecode.com/hg/ vim
cd /usr/local/src/vim
./configure --enable-multibyte \
--with-features=huge \
--disable-selinux \
--prefix=/usr/local \
<?php
/**
* クーポン自体が独立しているから順次処理していく感じにした
* @param array $amount
* @param array $myCouponList
* @return array
*/
function selectOptimalCoupons($amount, $myCouponList){
$hydrate = function($coupons){
<?php
/**
* 入力を{ 割引額 => 枚数 }の形に変える
* 枚数制限に引っかかる分を取り除く
* 同時利用可能でないクーポンリストを分ける(複数のクーポンリストにする)
* 複数のクーポンリストから割引額が多いものを返す。
* @param $amount
* @param $myCouponList
* @return array