Coding/CPP 삽질기2023. 7. 3. 23:53

보기 > 도구 상자 (X) 클릭 

단축키: Ctrl +Atl +X 

Posted by chobocho
Coding/CPP 삽질기2023. 7. 1. 18:03

주말 동안 C# 을 공부 하기로 하고, 첫 프로그램을 작성해 보았다.

언어을 배우면 누구나 만들어 보는 Word Count 프로그램.

class WordCount
{
    private readonly string fileText;

    WordCount(string fileText)
    {
        this.fileText = fileText;
    }

    private void printInfo()
    {
        var wordCount = getWordCount(fileText);
        var lineCount = getLineCount(fileText);

        Console.WriteLine($"LineCount: {lineCount}");
        Console.WriteLine($"WordCount: {wordCount}");
        Console.WriteLine($"Character Count: {fileText.Length}");
    }

    private int getWordCount(string fileText)
    {
        return fileText.Split(new[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Length;
    }
    
    private int getLineCount(string fileText)
    {
        return fileText.Split(new[] { '\n' }).Length;
    }
    
    static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Usage: WordCount [FileName]");    
            return;
        }

        string filePath = args[0];
        if (!File.Exists(filePath))
        {
            Console.WriteLine($"{filePath} not exist!");
            return;
        }

        string fileText = File.ReadAllText(filePath);
        WordCount wc = new WordCount(fileText);
        wc.printInfo();
    }
}

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

[C#] Visual studio 도구 상자 활성화 방법  (0) 2023.07.03
Intellij Code snippet 사용법  (0) 2023.06.13
[CPP] 펜윅 트리 (Fenwick Tree)  (0) 2023.06.09
Posted by chobocho
Coding/CPP 삽질기2023. 6. 13. 23:50
Coding/Python 삽질기2023. 6. 9. 23:28

1. Python 3.10.6 설치 

https://www.python.org/downloads/release/python-3106/

 

Python Release Python 3.10.6

The official home of the Python Programming Language

www.python.org

2.  Git 설치

https://git-scm.com/downloads

 

Git - Downloads

Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp

git-scm.com

3. Stable diffusion webui 설치

https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

 

GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI

Stable Diffusion web UI. Contribute to AUTOMATIC1111/stable-diffusion-webui development by creating an account on GitHub.

github.com

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

4. 모델 다운로드

https://civitai.com/

 

Civitai | Stable Diffusion models, embeddings, LoRAs and more

Civitai is a platform for Stable Diffusion AI Art models. Browse a collection of thousands of models from a growing number of creators. Join an engaged community in reviewing models and sharing images with prompts to get you started.

civitai.com

https://huggingface.co/WarriorMama777/OrangeMixs

 

WarriorMama777/OrangeMixs · Hugging Face

AOM3 Counterfeit2.5 Add SUM @ 1.0 0,0.6,0.6,0.6,0.6,0.6,0,0,0,0,0.6,0.1,0.6,0.6,0.6,0.6,0.6,0.5,0.1,0.1,0.6,0.6,0.2,0.6,0.6,0.6 AOM3A3

huggingface.co

 

모델을 다운 받아서, \stable-diffusion-webui\models\Stable-diffusion 에 넣어 준다.

확장자가 .safetensors 인 것을 받는 걸 추천 한다.

5. 실행

webui-user.bat 를 수행한다. (첫 실행시 이것 저것 설치한다고 시간이 걸린다.)

6. http://127.0.0.1:7860/ 로 웹 브라우저로 접속 하면 된다.

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

HTTP Protocol  (0) 2023.08.18
[Python] PyTorch 설치  (0) 2023.04.05
[ChatGPT에게 묻다] python으로 Simple Stack VM 만들기 (3)  (0) 2023.03.17
Posted by chobocho
Coding/CPP 삽질기2023. 6. 9. 23:14
#include <iostream>

const int MAX_SIZE = 10;

void update(int* TREE, int idx, int value) {
    for (++idx; idx <= MAX_SIZE+1; idx += (idx & -idx))
        TREE[idx] += value;
}

int sum(int *TREE, int s) {
    int r = 0;
    for (++s; s > 0; s &= (s-1))
        r += TREE[s];
    return r;
}

int main(int argc, char **argv) {
    int TBL[MAX_SIZE] = {0};
    int TREE[MAX_SIZE+1] = {0, };

    for (auto i = 0; i < MAX_SIZE; i++) {
        TBL[i] = i+1;
        update(TREE, i, TBL[i]);
    }

    // GET SUM from 1 ~ N
    for (auto i = 0; i < MAX_SIZE; i++)
        std::cout << sum(TREE, i) << ", ";
    std::cout << std::endl;
    
    return 0;
}
Posted by chobocho
Coding/CPP 삽질기2023. 6. 7. 00:59

문득 기초 코딩(?) 실력이 떨어진것 같아서, 프로그래머스의  Level 0 문제를 C로 모두 풀어 보았다.

중간 중간 예상외로 막히는(?) 문제를 만나면서, 잊고 있었던 것들이 많았다는 걸 배웠다.

심심하신 분들에게 추천합니다.

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

[CPP] 펜윅 트리 (Fenwick Tree)  (0) 2023.06.09
[ChatGPT에게 묻다] Fast sqrt 함수  (0) 2023.02.26
별 그리기  (0) 2021.06.08
Posted by chobocho
Coding/Java 삽질기2023. 5. 10. 19:22

Classic Block Game V2 는 어떠한 개인 정보도 수집하지 않습니다.

Classic Block Game V2 does not collect any personal information.

Posted by chobocho

1. 시작하기

   1.1. 테트리스 게임 소개

테트리스는 누구나 한 번쯤 들어 본 게임이기에, 설명은 생략 합니다.

테트리스에 대한 자세한 사항은 아래 링크를 참고 하시기 바랍니다.

 

   1.2. 구현 할 테트리스 게임의 요구사항 정의

우리가 만들 테트리스 게임은 아래 사이트에서 플레이 할 수 있습니다.

 

Chobosho's tetris

Tetris!

chobocho.com

 

안드로이드로 포팅한 버전은 아래 사이트에서 플레이 할 수 있습니다.

 

Classic Block Game V2 - Google Play 앱

안드로이드용 클래식 블록 게임입니다.

play.google.com

 

그리고, 전체 소스는 아래에서 다운 받을 수 있습니다.

 

이번에 구현 할 테트리스 게임은 아케이드 모드, 퍼즐 모드, 아이템 모드 총 3개의 모드로 구성이 됩니다.

 

1.2.1 아케이드 모드

테트리스의 기본 형태로, 모두가 잘 알고 있는 내용이라, 자세한 설명은 생략합니다.

1.2.2 퍼즐모드

퍼즐 모드 테트리스는 고전적인 테트리스 게임을 벗어나, 플레이어의 두뇌와 반응 속도를 동시에 시험하는 독특한 경험을 제공합니다. 이 게임에는 70가지 이상의의 다양한 퍼즐이 포함되어 있어, 게임을 진행하면서 플레이어의 전략적 사고력을 향상시키는 동시에 문제 해결 능력을 증진시키는 데 도움이 됩니다.
각 스테이지의 목표는 화면에 보이는 색상이 있는 블록을 모두 제거하는 것입니다. 이는 단순히 블록을 빠르게 쌓는 것을 넘어서, 플레이어가 어떻게 블록을 배치하고 어떤 블록을 사용할지를 신중하게 고려해야 하는 전략적인 요소를 게임에 도입합니다.

1.2.3 아이템 모드

아이템 모드는 다양한 아이템들이 포함된 전략적인 게임을 제공 합니다. 이 모드의 주요 아이템들은 Yellow Thunder, Black Thunder, Orange Thunder, Red Thunder, Blue Boom, Black Boom, Green Boom, 그리고 Red Boom입니다.

Yellow Thunder는 화면의 모든 검은 폭탄을 폭발시키며, Black Thunder는 최대 3개의 폭탄을 화면에 추가합니다. Orange Thunder는 아이콘이 바닥에 닿을 때 중심을 기준으로 3x3 영역을 지웁니다. 단, 아이콘이 포함된 줄이 꽉 차있다면 작동하지 않습니다. Red Thunder는 아이콘이 바닥에 닿으면 현재 위치한 세로 라인과 오른쪽 세로 라인을 지웁니다.

Blue Boom은 아이콘이 바닥에 닿았을 때 중심 주변 3x3 크기를 회색 블록으로 채웁니다. Black Boom은 폭탄이 포함된 줄이 블록으로 꽉 차면 위 아래 한 줄씩 총 3줄을 삭제합니다. Green Boom은 원형의 회색 블록을 추가합니다. 단, 아이콘이 포함된 줄이 꽉 차있다면 작동하지 않습니다. Orange Boom은 아이콘 중심으로 빈 3x3 사각형을 그립니다. 마찬가지로, 아이콘이 포함된 줄이 꽉 차있다면 작동하지 않습니다. Red Boom은 아이콘이 위치한 한 줄을 지웁니다.

아이템 테트리스는 이러한 독특한 아이템들을 활용해 주어진 판의 블록들을 모두 제거하면서, 전략적으로 높은 점수를 달성하는 것이 목표입니다.

플레이어들은 다양한 아이템을 사용하여 게임을 더욱 재미있게 즐길 수 있습니다.

 

Posted by chobocho
Coding/JavsScript 삽질기2023. 4. 18. 00:16

게임 플레이 해보기
http://www.chobocho.com/game/tetris/

 

Chobosho's tetris

Tetris!

chobocho.com

 

자바스크립트를 공부하면서 만든 아이템 테트리스 소스 입니다.
인터넷을 대충 뒤져 보니, 간단한 테트리스 소스는 많으나,
퍼즐 테트리스, 아이템 테트리스 소스는 없어서 공개 합니다.


 



소스코드 위치
https://github.com/chobocho/webTetris/tree/item_tetris

 

GitHub - chobocho/webTetris: Javascript tetris

Javascript tetris. Contribute to chobocho/webTetris development by creating an account on GitHub.

github.com

좋아요, 추천은 힘이 됩니다! ^^
 

Posted by chobocho
Coding/Python 삽질기2023. 4. 5. 01:25

1. 아래 사이트에서  설치해야 하는 PyTorch 버전 체크

https://pytorch.org/get-started/locally/

 

PyTorch

An open source machine learning framework that accelerates the path from research prototyping to production deployment.

pytorch.org

2. Command를 복사하여 실행한다.

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

3.  Python을 실행하여 확인 한다.

 

Posted by chobocho