Skip to content

Instantly share code, notes, and snippets.

@satos---jp
satos---jp / __writeup_STLC.md
Last active May 6, 2019 16:45
The intended solution for "STLC" in the TSG CTF 2019

The intended solution for "STLC" in the TSG CTF 2019

Step 1

When beta reducing, "capture avoiding substitution" is not taken place. For example, the term (\x. \y. x y) y should be reduced to \z. y z by renaming y to z in (\x. \y. x y), but in the interpreter, this term is reduced to \y. y y, which is ill typed lambda term. By exploiting this, the input

f1 = (\f:I->I. \g:A->A. g)
f2 = (\x:(I->I)->(A->A)->A->A. \f1:A->A. x dec) f1 (\d:A. d)
def eval(s,inputs):
mem = [0 for i in xrange(6000)]
ip = 0
mp = 0
stack = []
def state2s():
return (
''.join(map(lambda (i,c): "*"+c if i == ip else c ,enumerate(s))) + '\n' +
str(map(lambda (i,c): "@"+str(c) if i == mp else c ,enumerate(mem[:200])))
type tyvar = string
type var = string
type ty =
| TyV of tyvar
| TyFun of ty * ty
| TyAll of tyvar * ty
#coding: utf-8
import threading
import socket
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse
page_head = """
<!doctype html>
<html>
<head>
<title>igoclock</title>
<script>
function hoge(){
if(document.timer.player.value>=0){
document.timer.remain.value -= 1;
if(document.timer.remain.value < 0){
document.timer.player.value = -1;
document.body.style.backgroundColor = 'red';

蟻本はとりあえず急いでフローを求めたい人向けの説明なので、
アルゴリズムイントロダクション(図書館にある)とかを読むのをお勧めします。
http://hos.ac/slides/20150319_flow.pdf
これが分かりやすいですかね。

用語として、 フロー、フローの残余グラフ、増加路、カット、とかは理解しておきましょう。

増加路が存在しない⇔最大フローとか、 最大フロー最小カット定理、とかは理解しておくとよい。

#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
Dim A(1000) As Integer
Dim top, pc, isend
Dim s As String
Dim out As String
Sub initi()
@satos---jp
satos---jp / GoogleのDoodleのTuringMachineのやつ
Last active August 29, 2015 14:10
初期のExcel(VBA)のコード群
Dim k As Integer
Dim x As Byte
Dim y As Byte
Dim yoko As Byte
Dim gyou As Byte
Sub tyuring()
x = 1
ApSApSOT0,3pOpO+Mc92T3,20p\OT0,3pOpO+Mc92T3,20p