Giter Site home page Giter Site logo

rustatcoder's Introduction

AtCoder with Rust in mac

cargo atcoderを使用させていただいています。

セットアップ

まずこのリポジトリをcloneします。 AtCoder用の環境を作りたい場所で、以下のコマンドを実行してください。

git clone https://github.com/hppRC/AtCoder-with-Rust-in-mac.git

次に、クローンしてきた場所に移動します。

# どこかのディレクトリからAtCoder用のディレクトリへ
cd AtCoder-with-Rust-in-mac

次に、セットアップ用のスクリプトを実行します。 これを実行すると、Rust本体のインストールし、AtCoder用のconfigファイルのシンボリックリンクを貼り、brewで必要なパッケージをインストールします。 もしすでにインストール済みならインストールを行わないように処理を書いていますが、気になるようであればinit.shを読んでみてください。めっちゃ単純です。

bash ./init.sh

ちなみにRustの各種ツールのインストールはちょっと長めです。気長に待ちましょう。自分のmacは火を吹きました。多分普通だと思います。

インストールが終わるとloginを求められるので、AtCoderのユーザー名とパスワードを入力ください。

Dockerをインストールしていない方へ

クロスコンパイル(コンパイルされる環境と実行環境が違う時にいい感じにコンパイル)するために、crossというツールを使用します。これはDockerを使用するので、Dockerをinstallする必要があります。

こちらの記事[DockerをMacにインストールする(更新: 2019/7/13)]に詳しく載っていますが、一応手順をさらっと書いておきます。

Dockerのインストールはやり方を知っていると簡単です。まずDocker公式サイトにアクセスしてcreate accountしてください。Dockerを使うためにはなぜかDockerHubというところのアカウントを作る必要があるので、ここは我慢してください。

適当にインストール手順が出てくると思うので、いい感じにこなすとコマンドラインでdockerが呼べるようになっています。docker versionを実行してみましょう。

長い戦いの果てに

さて、これで環境は整ったはずです。 早速問題を解いて提出してみましょう!

ちなみにですが、Rust何もわからん、という方のための動作確認用に自分のリポジトリへのリンクを貼っておきます。 ご自由にお使いください。

https://github.com/hppRC/AtCoder

また、cloneしてきたリポジトリを自分のリポジトリとして管理したい!という場合はgit initなりrm -rf ./.gitなりして頂いて大丈夫です。こちもご自由にお使いください。

基本操作

使用させて頂いているcargo-atcoderのREADMEに詳しい説明が載っているので、特に書くことはありませんがメモがわりに残しておきます。

また、AtCoderで使えるRustの基本的な情報については、先人の方々が残してくださった記事のリンクを列挙させていただきます。 以下をご参照ください。

Rustアップデート以前の記事(バージョンは違いますが役に立つ情報がたくさん載っていますのでぜひご参照ください)

解法を投げる

cargo atcoder submit <problem-id>

バイナリで投げる(デフォルトはこっちにしてあります)

手元でコンパイル済みのものを提出として投げるので、自作のcrate(ライブラリ)を使えるようになったり、世の中の便利crateを引っ張ってきて使わせてもらうこともできます。 proconioというcrateは言語アップデート後のジャッジでしか対応していないはずなので、とりあえずバイナリを投げておくのが安全策ではあります。(どんな問題にも使えるので)

cargo atcoder submit --bin <problem-id>

便利なやつ

alias cas="cargo atcoder submit"

これで例えばabc152ディレクトリに移動して

cas a

と打てば提出できる

提出状況確認

cargo atcoder status

便利alias群

既存のエイリアスやコマンドとかぶらないようにしてお使いください。

alias cas="cargo atcoder submit"
alias can="cargo atcoder new"

cargo-atcoder.tomlをGit管理

tomlファイルもgit管理したいのは非常に常識的な感覚だと思うので、シンボリックリンクの貼り方も載せておきます。 シンボリックリンクは(誤解を恐れずに言うと)ファイルのドッペルゲンガーを作るようなコマンドで、一方で編集した内容がもう一方にも反映させることができます。

macOS環境を想定

# ln -sf ~/path/to/your_directory/cargo-atcoder.toml ~/Library/Preferences/
# 現在いるディレクトリのcargo-atcoder.toml から ~/Library/Preferences/ へ貼るには以下

ln -sf $(pwd)/cargo-atcoder.toml ~/Library/Preferences/

rustatcoder's People

Contributors

hpprc avatar

Stargazers

Yodai Kishimoto avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.