Skip to content

Instantly share code, notes, and snippets.

View mayth's full-sized avatar

Mei Akizuru mayth

View GitHub Profile
@mayth
mayth / ProblemD.cs
Created May 24, 2014 17:25
AtCoder Beginner Contest #009 - Problem D (TLE)
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC009
{
static class ProblemD
{
public static void Main(string[] args)
{
@mayth
mayth / amida_problem.txt
Last active August 29, 2015 14:04
problem samples of amida (Programming 300 SECCON 2014 Online Preliminary)
1 2 3 4 5 6 7 8
|-| |-| | | |-|
| | | | | |-| |
| | | | | | |-|
|-| | |-| | | |
| | |-| |-| |-|
|-| | |-| | | |
| |-| | |-| |-|
|-| |-| | | | |
| | | | |-| | |
@mayth
mayth / amida.rb
Created July 20, 2014 08:04
amida solver (SECCON 2014 Online Preliminary)
def read_problem(io)
problem = ''
loop {
ch = io.getc
break if !ch || ch == '?'
problem << ch
}
io.getc
problem
end
@mayth
mayth / gochiusa.html
Created November 10, 2014 02:14
あぁ^〜心がぴょんぴょんするんじゃぁ^〜
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>あぁ^〜心がぴょんぴょんするんじゃぁ^〜</title>
<script src="gochiusa.js"></script>
</head>
<body>
<canvas id="gochiusa" width="640" height="480">
あぁ^〜心ぴょんぴょんするには最新のブラウザが必要なんじゃぁ^〜
@mayth
mayth / gochiusa2.css
Created November 10, 2014 11:42
あぁ^〜心がぴょんぴょんするんじゃぁ^〜(あぁ^〜Canvas使わずにぴょんぴょんするんじゃぁ^〜)
#pyonpyon-container {
position: relative;
width: 100px;
height: 120px;
}
#kokoro {
position: absolute;
left: 0;
top: 0;
@mayth
mayth / Slice.fs
Created December 4, 2014 19:21
Slice array
let slice n arr =
let len = int (ceil ((float (Array.length arr)) / (float n)))
Array.init len (fun i -> arr.[(i * n)..(i * n + (n - 1))])
// test code
[<EntryPoint>]
let main args =
let arr = [|1; 2; 3; 10; 20; 30; 100; 200; 300|]
let result = slice 3 arr
printfn "%A" result
@mayth
mayth / mission1.fs
Created December 4, 2014 21:22
paiza Online Hackathon 4 Lite : Answers with F#
// https://paiza.jp/poh/enkoi-second/e144f4da
open System
let readLines (reader : IO.TextReader) =
seq {
let eof = ref false
while not !eof do
match reader.ReadLine() with
| null -> eof := true
| str -> yield str
@mayth
mayth / ap.html
Last active August 29, 2015 14:25
Clustering with JavaScript (k-means and Affinity Propagation) (NOTE: jQuery required!)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Affinity Propagation clustering</title>
<script src="./jquery-2.1.3.min.js"></script>
<script>
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@mayth
mayth / iTunesCurrentTrack.cs
Created November 24, 2011 23:14
Get Current Track from iTunes
// * Add reference to iTunesLib to your project.
// * If iTunes isn't running when this code run, iTunes will start.
// * After this code run, iTunes will ask you that "are you sure to exit?" when you close iTunes because this code cannot release COM interface. Releasing code is no effects...
using System;
using iTunesLib;
iTunesApp app = new iTunesApp();
IITTrack track = app.CurrentTrack;
if (track != null)
@mayth
mayth / LinearCellularAutomaton.cs
Created December 15, 2011 16:11
Linear Cellular Automaton Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimulationPhys2_5
{
/// <summary>
/// Represents a linear cellular automaton.
/// </summary>