Skip to content

Instantly share code, notes, and snippets.

@ariesobj
Last active May 10, 2016 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariesobj/a7186eb632e2db7274565882497dcfcd to your computer and use it in GitHub Desktop.
Save ariesobj/a7186eb632e2db7274565882497dcfcd to your computer and use it in GitHub Desktop.
package main
import "fmt"
var T = map[string][2]int{
"black": [2]int{
0,
1,
},
"brown": [2]int{
1,
10,
},
"red": [2]int{
2,
100,
},
"orange": [2]int{
3,
1000,
},
"yellow": [2]int{
4,
10000,
},
"green": [2]int{
5,
100000,
},
"blue": [2]int{
6,
1000000,
},
"violet": [2]int{
7,
10000000,
},
"grey": [2]int{
8,
100000000,
},
"white": [2]int{
9,
1000000000,
},
}
func main() {
var x, y, z string
fmt.Scan(&x, &y, &z)
fmt.Println((T[x][0]*10 + T[y][0]) * T[z][1])
}
from random import sample
from itertools import product
import subprocess
colors = [
"black",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"violet",
"grey",
"white",
]
# 질문 게시판에서 소스 가져와서 고침
# 아래 코드는 백준 채점을 통과한 코드임.
def right_proof(x, y, z):
a=['black','brown','red','orange','yellow','green','blue','violet','grey','white']
b=a.index(x)*10+a.index(y)
b*=10**a.index(z)
return str(b)
def interstitial_newline(it):
it = iter(it)
try:
yield next(it)
except StopIteration:
pass
else:
for line in it:
yield "\n"
yield line
def easy_popen(execargs, args):
po = subprocess.Popen(execargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
[po.stdin.write(line.encode()) for line in interstitial_newline(args)]
po.stdin.close()
returncode = po.wait()
if returncode != 0:
raise RuntimeError('something errornous happended!: ' + str(returncode))
output = po.stdout.read()
output = output.decode()
return output
def verify():
# compiled go path
execpath = ["1076.exe"]
passed = 0
for args in product(colors, repeat=3):
witness = easy_popen(execpath, args).strip()
testament = right_proof(*args).strip()
if witness == testament:
passed += 1
print("내가 작성한 프로그램이 올바를 확률 = %.3f" % (passed / 1000))
else:
linediv = '-' * 70
print("내가 작성한 프로그램이 올바르지 않음이 증명되었습니다!")
print(linediv)
print(args)
print(linediv)
print(witness)
print(linediv)
print(testament)
return False
return True
def main():
if verify():
print('내가 작성한 프로그램이 모든 입력에 대하여 올바르게 동작함이 증명되었습니다!')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment