Skip to content

Instantly share code, notes, and snippets.

@suppy
suppy / answer.txt
Last active August 29, 2015 13:58
The Essence of Programming 結城 浩さんからのアルゴリズムの問題:クリプタン帝国の暗号文を解読しよう!:私の回答(惜しくも不正解)
"You see, my dear Watson," -- he propped his test-tube in the rack, and began to lecture with the air of a professor addressing his class -- "it is not really difficult to construct a series of inferences, each dependent upon its predecessor and each simple in itself. If, after doing so, one simply knocks out all the central inferences and presents one's audience with the starting-point and the conclusion, one may produce a startling, though possibly a meretricious, effect.Now, it was not really difficult, by an inspection of the groove between your left forefinger and thumb, to feel sure that you did NOT propose to invest your small capital in the gold fields."
Abort.
ENV: Ruby, "The Adventure of the Dancing Men"
POINT: シャーロック・ホームズになりきる
■暗号文1の解読
# 復号用のハッシュ
decryptan = {
@suppy
suppy / deathma.coffee
Created January 9, 2015 01:50
デスマコロシアム未挑戦言語出力
# Description:
# デスマコロシアム未挑戦言語出力
#
# 第n回デスマコロシアムで挑戦者0名の言語を指定数分ランダムに出力します
#
# Commands:
# deathma n count - 第 n 回で挑戦者0名の言語を count 個ランダムに出力する
# deathma - 最新回で挑戦者0名の言語をランダムに出力する
#
# Author:
@suppy
suppy / yukicoder192.c
Last active August 29, 2015 14:22
No.192 合成数
#include <stdio.h>
int main(void) {
int i, j, N;
scanf("%d", &N);
for(i = 2;i <= N + 100;i++){
for(j = 2;j < N + 100;j++){
if(i * j >= N - 100 && i * j <= N + 100){
printf("%d\n", i * j);
return 0;
@suppy
suppy / yukicoder211.c
Created May 28, 2015 01:18
No.211 素数サイコロと合成数サイコロ (1)
#include <stdio.h>
int main(void) {
int i, j, K;
int prime[] = {2, 3, 5, 7, 11, 13};
int composite[] = {4, 6, 8, 9, 10, 12};
int count = 0, total = 0;
scanf("%d", &K);
for(i = 0;i < 6;i++){
for(j = 0;j < 6;j++){
@suppy
suppy / yukicoder175.c
Created May 28, 2015 01:19
No.175 simpleDNA
#include <stdio.h>
int main(void) {
int i, L, N, length;
int ans;
char S[31];
scanf("%d", &L);
scanf("%d", &N);
for(i = 1;i <= N;i++){
scanf("%s", S);
@suppy
suppy / yukicoder82.c
Created May 28, 2015 01:20
No.82 市松模様
#include <stdio.h>
int main(void) {
int W, H, x, y;
char C[2];
scanf("%d%d%s", &W, &H, C);
for(y = 0;y < H;y++){
for(x = 0;x < W;x++){
printf("%c", C[0]);
if(C[0] == 'B')C[0] = 'W';
@suppy
suppy / yukicoder104.c
Created May 28, 2015 01:20
No.104 国道
#include <stdio.h>
int main(void) {
int i, r;
char str[31];
scanf("%s", str);
//printf("%s\n", str);
i = 0;
r = 1;
while(str[i] != '\0'){
@suppy
suppy / yukicoder32.c
Created May 28, 2015 01:21
No.32 貯金箱の憂鬱
#include <stdio.h>
int main(void) {
int L, L1, M, M1, N;
scanf("%d", &L);
scanf("%d", &M);
scanf("%d", &N);
M1 = N / 25;
N %= 25;
L1 = (M + M1) / 4;
@suppy
suppy / yukicoder22.c
Created May 28, 2015 01:22
No.22 括弧の対応
#include <stdio.h>
int main(void) {
int i, N, K;
int l, r, num;
char str[10001];
scanf("%d%d", &N, &K);
scanf("%s", str);
if(str[K - 1] == '('){
@suppy
suppy / yukicoder18.c
Created May 28, 2015 01:23
No.18 うーさー暗号
#include <stdio.h>
int main(void) {
int i;
char s[1025];
scanf("%s", s);
i = 0;
while(s[i] != '\0'){
printf("%c", (s[i] - (i % 26) - 1 - 65 + 26) % 26 + 65);
i++;