Coding/Tip2014. 11. 29. 01:42

Drop box -> 환경결성 -> 가져오기 -> 스크린샷 -> "Dropbox를 사용하여 스크린샷 공유" 선택

 





'Coding > Tip' 카테고리의 다른 글

Mac 에서 Trello PDF로 저장하기  (0) 2015.08.28
Sinppely ( Code snippet tool )  (0) 2013.05.19
SVN Local 저장소 사용법 간단 정리  (0) 2011.09.03
Posted by chobocho
Coding/Evernote2014. 11. 20. 23:13



에버노트 Altas 기능

내가 작성한 노트가 어느 지역에서 만들었는지를 알려준다. 

'Coding > Evernote' 카테고리의 다른 글

Evernote 템플릿 공유  (0) 2018.09.29
Safari web clipper 가 동작을 하지 않을 때  (0) 2017.10.07
[Evernote 활용] 바코드 모으기  (0) 2017.04.30
Posted by chobocho
Coding/CPP 삽질기2014. 11. 12. 00:07

#include <stdio.h>


#define BLOCK 1

 

#define SIZE 5


int mirror[SIZE][SIZE] = {

    { 0, 0, 0, 0, 0},

    { 0, 1, 1, 1, 0},

    { 0, 1, 0, 1, 0},

    { 0, 1, 1, 1, 0},

    { 0, 0, 0, 0, 1},    

};


int process(void);

int checkIsRect(int x, int y);


int main (int argc, char **argv) {

    

    int count = process();

       

    printf ("%d\n", count);

    

    return 0;

}


int process(void) {

    int count = 0;

    int i = 0, j = 0;

    

    for ( i = 0; i < SIZE; i++) {

        for ( j = 0; j < SIZE; j++ ) {

            if ( mirror[i][j] == BLOCK ) {

                count += checkIsRect(j, i);

            }

        }

    }

    

    return count;

}


int checkIsRect(int posX, int posY) {

    int count  = 0;

    int isEnd  = 0;

    int x = posX;

    int y = posY;

    int width  = 0;

    int height = 0; 

    

    int x2 = posX;

    int y2 = posY;

    //int width2  = 0;

    //int height2 = 0; 

    

    /* Check Right -> Check Down */

    do  {

        mirror[y][x] = 0;

        x++;

        width++;        

    } while (x < SIZE && mirror[y][x] == 1);

    x--;

    

    do {

        mirror[y][x] = 0;    

        y++;

        height++;

    } while (y < SIZE && mirror[y][x] == 1);

    y--;

    

   /* Check Down -> Check Left */

    do {

        mirror[y2][x2] = 0;    

        y2++;

        //height2++;

    } while (y2 < SIZE && mirror[y2][x2] == 1);

    y2--;

    

    do {

        mirror[y2][x2] = 0;    

        x2++;

        //width2++;

    } while (x2 < SIZE && mirror[y2][x2] == 1);

    // Already mirror[y2][x2] == 0 

    // Because x == x2, y == y2

    // No need to x2--;

    

    if ( x == x2 && y == y2 && width >= 3 && height >= 3 ) {

        count = 1;

    }

    

    //printf ("x: %d y: %d x2: %d y2: %d width: %d height: %d \n", x, y, x2, y2, width, height);              

    

    return count;

}



'Coding > CPP 삽질기' 카테고리의 다른 글

Couple  (0) 2015.12.23
Mirror  (0) 2014.10.27
대칭행렬  (0) 2014.10.24
Posted by chobocho
Coding/JVM 삽질기2014. 11. 11. 01:40

1. Groovy download

    http://groovy.codehaus.org/Download



2. 환경설정

    .bash_profile 을 아래와 같이 설정한다.



3. groovysh 실행 결과





4. GroovyConsole 실행결과



'Coding > JVM 삽질기' 카테고리의 다른 글

Mac에서 Kotlin 설치하기  (0) 2017.10.14
[groovy] 50!  (0) 2016.09.24
Pocket PC를 위한 JVM  (0) 2005.09.28
Posted by chobocho
Coding/CPP 삽질기2014. 10. 27. 00:56

#include <stdio.h>


#define UP 0

#define RIGHT 1

#define DOWN 2

#define LEFT 3


#define MIRROR_1 1

#define MIRROR_2 2


#define SIZE 5


int mirror[SIZE][SIZE] = {

    { 0, 0, 0, 0, 2},

    { 0, 1, 0, 2, 0},

    { 0, 2, 0, 0, 1},

    { 0, 0, 0, 1, 0},

    { 0, 0, 0, 0, 1},    

};


int process(int x, int y, int direction);


int main (int argc, char **argv) {

    

    int count = process(0, 0, RIGHT);

       

    printf ("%d\n", count);

    

    return 0;

}



int process(int x, int y, int direction) {

    int count = 0;

    int isEnd = 0;

    

    while ( isEnd == 0 && x >= 0 && x < SIZE && y >= 0 && y < SIZE) {

        switch(direction) {

            case UP:

                 while (y >= 0 && mirror[y][x] == 0) {

                     y--;

                 }

                 // printf ("Up %d %d\n", x, y);                   

                 break;

            case RIGHT:

                 while (x < SIZE && mirror[y][x] == 0) {

                     x++;

                 }

                 // printf ("Right %d %d\n", x, y);

                 break;

            case DOWN:

                 while (y < SIZE && mirror[y][x] == 0) {

                     y++;

                 }

                 // printf ("Down %d %d\n", x, y);

                 break;

            case LEFT:

                 while (x >= 0 && mirror[y][x] == 0) {

                     x--;

                 }

                 // printf ("LEFT %d %d\n", x, y);

                 break;

            default:

                 break;

        }

        

        if ( x >= 0 && x < SIZE && y >= 0 && y < SIZE ){

            if ( mirror[y][x] == MIRROR_1 ) {

               direction ^= 1;      

               count++;              

            } else if ( mirror[y][x] == MIRROR_2 ) {

               direction ^= 3;

               count++;

            }

                  

            switch (direction) {

                case UP : y--; break;

                case RIGHT : x++; break;

                case LEFT : x--; break;

                case DOWN : y++; break;

            }

            //printf ("%d %d %d\n",direction, x, y);

        } else {

            isEnd = 1;    

        }              

    };

    

    return count;

}


'Coding > CPP 삽질기' 카테고리의 다른 글

사각형 개수 구하기  (0) 2014.11.12
대칭행렬  (0) 2014.10.24
Programming 실습 예제  (0) 2014.03.28
Posted by chobocho
Coding/CPP 삽질기2014. 10. 24. 01:49

#include <iostream>

using namespace std;


int main (int argc, char **argv) {

    

    int i = 0;

    int j = 0;

    

    for ( i = 0; i < 7; i++ ) {

        for ( j = 0; j < 7; j++ ) {

            cout << int(i^j) << " ";

        }

        cout << endl;

    }

    

    return 0;

}



Hi-iMac:CPP chobocho$ ./matrix.o 

0 1 2 3 4 5 6 

1 0 3 2 5 4 7 

2 3 0 1 6 7 4 

3 2 1 0 7 6 5 

4 5 6 7 0 1 2 

5 4 7 6 1 0 3 

6 7 4 5 2 3 0 

'Coding > CPP 삽질기' 카테고리의 다른 글

Mirror  (0) 2014.10.27
Programming 실습 예제  (0) 2014.03.28
피보나치 수열  (0) 2013.06.06
Posted by chobocho
Coding/CPP 삽질기2014. 3. 28. 04:02

 Programming 실습 예제


[ 기초 ]

1. Array 기반의 스택

2. Array 기반의 큐

3. Array 기반의 환형 큐

4. Double Linked List

5. Linked list를 이용한 스택

6. Linked list를 이용한 큐

7. Array 한 개로, 스택과 큐를 동시에 쓸수 있게 하기


'Coding > CPP 삽질기' 카테고리의 다른 글

대칭행렬  (0) 2014.10.24
피보나치 수열  (0) 2013.06.06
함수 실행 시간 측정  (0) 2013.05.24
Posted by chobocho
Coding/Java 삽질기2014. 1. 3. 02:26

* 맥에서 이클립스 개발환경을 만드는 제일 간단한 방법


1) 아래 사이트에서 안드로이드 개발툴을 다운 받아서 설치한다.

http://developer.android.com/sdk/index.html

2) 이클립스를 실행하면 자동으로 자바를 다운 받는다.

3) 자바 설치 후 이클립스 실행



Next-> http://chobocho.tistory.com/2461355

'Coding > Java 삽질기' 카테고리의 다른 글

Tetris  (0) 2016.03.17
초간단 보이스 레코더  (0) 2013.03.08
ChoboSMS  (0) 2013.02.26
Posted by chobocho
Coding/Python 삽질기2013. 12. 15. 04:02

Cython 설치 ( Mac )

  1. python download ( http://www.cython.org )
  2. sudo python setup.py install
Cython 실습

factorial_100000.pyx ]

def Factorial(int N):
    cdef int checkSize = 5000
    cdef int fi
    cdef int endN
    endN = N / checkSize
    facResult = 1
    for fi in range(1, endN + 1):
        facResult = facResult * reduce(lambda x, y : x * y, range((fi-1)*checkSize+1,fi * checkSize+1))
   
    if ( (endN * checkSize + 1) != (N+1) ):   
        facResult = facResult * reduce(lambda x, y : x * y, range(endN * checkSize + 1, N+1))  
    return facResult


[ setup.py ]

from distutils.core import setup

from Cython.Build import cythonize

setup(
  name = 'Factorial app',
  ext_modules = cythonize("factorial_100000.pyx"),


[ Build ]
python setup.py build_ext —inplace

# 이러면 SO 파일이 생김

[ Sandbox.py ]

import time

from factorial_100000 import Factorial

startTime = time.time()
factorialN = Factorial(10000)

print "runtime is %s"%(time.time() - startTime) 


[ 실행결과 ]



'Coding > Python 삽질기' 카테고리의 다른 글

[Notepad++] Python 실행하기  (0) 2016.08.28
100000! ( 100000 팩토리얼 ) & 1000000! ( 1000000 팩토리얼 )  (0) 2013.06.22
fibonacci 수열  (0) 2013.06.20
Posted by chobocho
Coding/Python 삽질기2013. 6. 22. 04:48

import sys

import time


def Factorial(N):

    checkSize = 5000

    endN = N / checkSize

    facResult = 1

    for fi in range(1, endN + 1):

        facResult = facResult * reduce(lambda x, y : x * y, range((fi-1)*checkSize+1,fi * checkSize+1))

    

    if ( (endN * checkSize + 1) != (N+1) ):    

        facResult = facResult * reduce(lambda x, y : x * y, range(endN * checkSize + 1, N+1))   

    return facResult



number = 100000

startTime = time.time()

factorialN = Factorial(number)


print "runtime is %s"%(time.time() - startTime) 

#print "Factorial %d is %d"%(number, factorialN)


인터넷을 검색 중 100000! 계산에 관한 글을 보고 실습해 본 코드.

2008년 구매한 노트북에서도 3.2초면 계산이 끝난다. ( * 결과 출력 할 때는 "젠틀맨" 뮤비 한 편 보고 나면 된다. )

math.factorial() 함수를 사용하는 것보다, 분할해서 계산하는게 3배 이상 빠르다.



* 참고 : 100000! 관련 KLDP 링크


http://kldp.org/node/129900

http://kldp.org/node/129379

http://kldp.org/node/129116

http://kldp.org/node/129044

http://kldp.org/node/107470



100000! 결과 : 100000.txt


심심해서 추가로 돌려본 1000000! ( 백만 팩토리얼 )

계산은 5분 만에 끝났으나, 출력이 한 시간도 넘게 걸린 듯...


1000000! 결과 : 1000000!.zip





'Coding > Python 삽질기' 카테고리의 다른 글

Cython 설치  (4) 2013.12.15
fibonacci 수열  (0) 2013.06.20
KMP algorithm  (0) 2013.05.06
Posted by chobocho