This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const delayed_yeah = () => { | |
console.log('delayed_yeah!') | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve('yeah!'), 2000) | |
}) | |
} | |
const delayed_hi = () => { | |
console.log('delayed_hi!') | |
return new Promise((resolve, reject) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129 | |
-- http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2162974#1 | |
main :: IO () | |
main = do | |
s <- getContents | |
mapM_ print $ solve (strings2ds s) [] | |
solve :: [[Int]] -> [[Int]] -> [Int] | |
solve ([0, 0]:_) acc = map head $ reverse acc | |
solve datasets acc = solve rest (result : acc) where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
main :: IO () | |
main = print $ solve [ "def", "fdc", "abcd", "char", "hoge"] | |
solve :: [String] -> [String] | |
solve wrds = snd $ last $ sortOn fst $ map (\ws -> (calc ws, ws)) $ permutations wrds | |
calc :: [String] -> Int | |
calc [] = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List as List | |
import Data.Map as Map | |
import Data.Maybe as Maybe | |
import Data.Sequence as Seq | |
import Data.Set as Set | |
maze = "#S######.#" ++ | |
"......#..#" ++ | |
".#.##.##.#" ++ | |
".#........" ++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Rx = require('rx'); | |
var RtmClient = require('@slack/client').RtmClient; | |
var CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS; | |
var botToken = process.env.SLACK_BOT_TOKEN; | |
var rtm = new RtmClient(botToken); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
o :: Ord a => a -> a -> Bool | |
o x y = x >= y | |
e :: Eq a => a -> a -> Bool | |
e x y = x == y | |
f :: Ord a => (a -> a -> Bool) -> a -> a -> String | |
f cmp x y = if cmp x y then "YES" else "NO" | |
main :: IO () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
fn primes(n: usize) -> Vec<usize> { | |
if n < 2 { | |
return vec![]; | |
} | |
if n == 2 { | |
return vec![2]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn fib(n: usize) -> Vec<u64> { | |
let mut fibs = Vec::new(); | |
while fibs.len() < n { | |
let current = match fibs.len() { | |
0 => 0, | |
1 => 1, | |
_ => { | |
fibs.iter().rev().take(2).sum() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalCoroutinesApi | |
class MainActivity : AppCompatActivity() { | |
private var working = false | |
private var job: Job? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val button = findViewById<Button>(R.id.button) |