Skip to content

Instantly share code, notes, and snippets.

View joonas-yoon's full-sized avatar
🎃
Focusing

Joona Yoon joonas-yoon

🎃
Focusing
View GitHub Profile
@joonas-yoon
joonas-yoon / HotBrain-E73.cpp
Created October 29, 2017 06:39
문제적 남자 73화
#include <cstdio>
#include <vector>
using namespace std;
typedef long long lld;
// 중복되는 숫자가 있는가
bool duplCheck(lld n){
bool fq[10]={};
while(n>0){
@joonas-yoon
joonas-yoon / pinocchio.js
Last active October 29, 2017 06:59
slack-bot/pinocchio
module.exports = function (req, res, next) {
var user_name = req.body.user_name;
// avoid infinite loop
if (user_name === 'slackbot') {
return res.status(200).end();
}
var botPayload = null;
var notFound = false;
@joonas-yoon
joonas-yoon / 4. JOI国のお散歩事情.cpp
Created October 29, 2017 07:11
JOI 2015/2016 qualifying round
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
int main(){
lld a[100002], T;
char sig[100002];
int i, j, n, q;
scanf("%d %lld %d", &n, &T, &q);
@joonas-yoon
joonas-yoon / A-Counting-Sheep.cpp
Created October 29, 2017 07:22
Google Code Jam Qualification Round 2016
#include <bits/stdc++.h>
using namespace std;
string sum(int& bit, string &s, string &p){
int slen = s.length(), plen = p.length();
int i, j, cr = 0;
string r = "";
for(i=j=0; i<slen || j<plen; ++i, ++j){
if(i<slen) cr += s[i]-'0';
if(j<plen) cr += p[j]-'0';
function intersects(circle, rect){
var circleDistance = {};
circleDistance.x = Math.abs(circle.x - rect.left);
circleDistance.y = Math.abs(circle.y - rect.top);
if (circleDistance.x > (rect.width/2 + circle.rad)) { return false; }
if (circleDistance.y > (rect.height/2 + circle.rad)) { return false; }
if (circleDistance.x <= (rect.width/2)) { return true; }
if (circleDistance.y <= (rect.height/2)) { return true; }
@joonas-yoon
joonas-yoon / index.html
Created October 29, 2017 16:26
핑퐁 게임 index.html
<canvas id="pingping"></canvas>
<script type="text/javascript" src="..." />
<script type="text/javascript">
var game = new Game('pingpong');
game.start();
game.pushBall(1);
</script>
@joonas-yoon
joonas-yoon / game.state.pingpong.js
Created October 29, 2017 16:33
핑퐁에서 화면 전환 때 사용한 코드
this.state = function(stageName){
this.init(stageName);
if(stageName == 'PLAY_SOLO' || stageName == 'PLAY_DUO'){
this.balls = [];
// ...
} else {
// ...
}
};
@joonas-yoon
joonas-yoon / solving-collision-key-event.js
Created October 29, 2017 16:43
핑퐁에서 키보드 충돌 처리
this.keypress_table = {};
this.fireKeydown = function(event){
var _this = game;
_this.keypress_table[event.code.toString()] = true;
if(_this.stage == 'MAIN_MENU'){
switch(event.code){
case 'Digit1':
_this.state('SELECT_COMPUTER');
break;
@joonas-yoon
joonas-yoon / Ball+Racket.js
Last active October 29, 2017 16:46
핑퐁 게임 오브젝트들 생성자
function Ball(boundWidth, boundHeight){
this.x = Math.random()*(boundWidth/5) + (2*boundWidth/5);
this.y = Math.random()*(boundHeight/2) + (boundHeight/4);
this.dx = Math.random() > 0.5 ? -1 : 1;
this.dy = Math.random() > 0.5 ? -1 : 1;
this.rad = 10; this.color = "#fff"; this.speed = 2;
this.set = function(newX, newY){ this.x = newX; this.y = newY; };
this.setD = function(_dx, _dy){ this.dx = _dx; this.dy = _dy; };
this.randomDirection = function(){ ... };
@joonas-yoon
joonas-yoon / CmazeGeneratorDlg-drawCell.cpp
Created October 30, 2017 08:32
Draw Cell code on Maze Generator in C++
void CmazeGeneratorDlg::drawCell(int row, int col, char wallBit, int cellSize)
{
CPen *oldPen, pen;
pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
oldPen = mPicCtrl->SelectObject(&pen);
// 벽의 위치에 대해 4비트 (1111b) 로 나타낸다.
// 1111 은 각각 상/하/좌/우를 의미함.
// 위쪽 벽