This file contains 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 java.util.Scanner | |
import scala.xml.XML | |
import scala.util.Random | |
/** div.boardを入力として与える **/ | |
object Main extends App { | |
val sc = new Scanner(System.in) | |
val xmlString = sc.nextLine() |
This file contains 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
function solve() { | |
// a / b | |
function modDiv(a, b, p) { | |
function repeatSquares(x, n) { | |
if (n === 0) | |
return 1 | |
else if (n % 2 === 0) | |
return repeatSquares(x*x % p, n/2) | |
else |
This file contains 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
function solve() { | |
const board = document.getElementsByClassName('board')[0].children | |
const side = board.length | |
document.dispatchEvent(new KeyboardEvent( 'keypress', {key: "w"})) | |
var table = new Array(side); | |
for (let y = 0; y < side; y++) { | |
table[y] = new Array(side).fill(false); | |
for (let x = 0; x < side; x++) { | |
// sisisin is true |
This file contains 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 java.util.Scanner | |
import scala.xml.XML | |
import scala.util.Random | |
/** div.boardを入力として与える **/ | |
object Main extends App { | |
val answer = Array( | |
"00000000", | |
"00000000", |
This file contains 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
module type VLIST = sig | |
type 'a t | |
val nth: 'a t -> int -> 'a | |
val length: 'a t -> int | |
val cons: 'a -> 'a t -> 'a t | |
val head: 'a t -> 'a | |
val tail: 'a t -> 'a t |
This file contains 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 java.util.Scanner | |
import scala.collection.mutable.PriorityQueue | |
sealed trait NodeState | |
case object Free extends NodeState | |
case class Half(a: Int) extends NodeState | |
case class Full(a: Int, b: Int) extends NodeState | |
case class Point(x: Long, y: Long){ |
This file contains 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
(** ペアノ数 **) | |
type nat = Z | S of nat | |
let rec nat_of_string = function | |
| Z -> "Z" | |
| S n -> "S(" ^ nat_of_string n ^ ")" | |
(*** DSL ***) | |
(* syntax *) | |
type exp = Plus of nat * nat (* _1 plus _2 *) |
This file contains 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
open Printf | |
(** ペアノ数 **) | |
type nat = Z | S of nat | |
let rec string_of_nat = function | |
| Z -> "Z" | |
| S n -> sprintf "S(%s)" @@ string_of_nat n | |
let rec int_of_nat = function | |
| Z -> 0 |
This file contains 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
type nat = Z | S of nat | |
let rec nat_of_int = function | |
| 0 -> Z | |
| n -> S (nat_of_int (n-1)) | |
let rec plus n m = | |
match n with | |
| Z -> m | |
| S n' -> plus n' (S m) |
This file contains 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
// data type | |
sealed abstract class Tree { | |
def foldLeft[B](z: B)(f: (B, Int) => B): B | |
} | |
case class Branch(value: Int, left: Tree, right: Tree) extends Tree { | |
def foldLeft[B](z: B)(f: (B, Int) => B): B = | |
right.foldLeft(f(left.foldLeft(z)(f), value))(f) | |
} | |
case object Empty extends Tree { | |
def foldLeft[B](z: B)(f: (B, Int) => B): B = z |