The Qiita Advent Calendar 2021 is made possible by the support of the following companies and services

TwilioT-DASHfreeeMicrosoftUdemySnykV-CUBEVonage JapanWorks Human IntelligenceCData SoftWare JapanカオナビPOTEPAN CAMP

Rubyプログラミング問題にチャレンジ! -改訂版・チェリー本発売記念- Advent Calendar 2021

251119

本カレンダーは、Qiita Top Contributor の @jnchito さんからのお題です。
みなさまの素敵な記事をお待ちしています。

この企画では「プロを目指す人のためのRuby入門」の著者である伊藤淳一(@jnchito)から、Rubyを使ったプログラミング問題を出します。「我こそは!」という人は解答となるコードを書いて、アドベントカレンダーの記事として投稿してください。

提出されたコード(記事)中から、僕・伊藤淳一が「これはイケてる!!」と思ったコードを表彰します。

「あれ?アドベントカレンダーってそういうもんだったっけ?」

特別企画なので細かいことは気にしないでください!!

参加資格

初心者から上級者までどなたでもOKです。書籍「プロを目指す人のためのRuby入門(通称チェリー本🍒)」を持っていてもいなくても構いません。「解答したい!」と思った人から早いもの勝ちでアドベントカレンダーに参加登録していってください。

動画でわかる!参加方法

このページで説明している参加方法や「お題」の仕様をYouTube動画で詳しく解説してみました。こちらもぜひご覧ください💁‍♂️

今回のお題「点字メーカープログラム」

この企画ではみなさんに「点字メーカープログラム」を作成してもらいます。このプログラムでは入力されたローマ字に対応する点字をテキストで出力します。以下はこのプログラムの実行例です。

tenji_maker = TenjiMaker.new
puts tenji_maker.to_tenji('A HI RU')
#=> o- o- oo
#   -- o- -o
#   -- oo --

puts tenji_maker.to_tenji('KI RI N')
#=> o- o- --
#   o- oo -o
#   -o -- oo

「はい、先生!点字のしくみがわかりません!!」

点字のしくみは以下のサイトでわかりやすく説明されているので、こちらを参考にしてください。

d3b5d184-269d-5fa0-0a48-e60e83487929.png

引用 全視情協:点字とは - 点字のしくみ

コード提出用の雛形リポジトリと詳細なプログラム仕様について

コード提出用の雛形リポジトリをこちらに用意しています。また、点字メーカープログラムの詳細なプログラム仕様についてもこの中のREADMEで説明しているので、参加される方はREADMEをよく読んでください。

参加方法

「よっしゃ、やったるでー!!」という方はまず、このアドベントカレンダーに参加登録してください。

コードが書けたら、自分が書いたコードを解説する技術記事を書き、そのURLを自分の担当日に貼り付けてください。

コードの提出方法は2通りあります。

プルリクエストの作り方がわかる場合

  1. 前述の雛形リポジトリをフォークする
  2. コードが書けたらプルリクエストを作る
  3. GitHub ActionsのテストがパスすればOK
  4. プルリクエストのリンクをアドベントカレンダーの記事に載せる

プルリクエストの作り方がわからない場合

  1. 前述のリポジトリのコードをローカルにダウンロードする
  2. ローカルでコードを書く
  3. rakeコマンドでテストが全部パスすれば完成
  4. アドベントカレンダーの記事に自分が書いたコードとrakeコマンドの実行結果(テストが全部パスしていることの証明)を載せる

「あれ、ちょっと待って!これだと、他の人のコードが見えちゃうんじゃ??」

はい、見ようと思ったら見えちゃいますが、この企画に参加する人は自分のコードを提出するまで、他の人のコードはなるべく見ないようにお願いします!(今回は「性善説」でいきます)

アドベントカレンダーの記事に書いてほしいこと

アドベントカレンダーの記事には以下の内容を記載してください。

  • プルリクエストのリンク、または自分が書いたコード
  • ロジックの解説
  • コードのアピールポイント
    • 頑張ったところ
    • 苦労したところ
    • 工夫したところ
    • 自慢したいところ
    • etc
  • 伊藤さんにメッセージ(もしあればw)

プレゼント内容

以下の2つの賞があり、表彰者にはプレゼントが贈られます!

LGTM賞(1名様):Qiitanぬいぐるみ1体

投稿された記事の中で、最もLGTM数が多かった記事の投稿者に贈られます。

Top Contributor賞(1名様):Qiitanぬいぐるみ1体

僕が「いいね!」と思ったコード(記事)を表彰します。
僕が重視するのは以下のようなポイントです。

  • 可読性が高いコードであること
  • 簡潔なコードであること
  • ロジックの解説や記事全体の内容が読者視点を意識したものになっていること

なお、提出してもらったコードのうちいくつかは、僕のQiita記事や勉強会等で僕がコードレビューさせてもらうかもしれません。あらかじめご了承ください。

まとめ

この点字メーカープログラムですが、拙著「プロを目指す人のためのRuby入門」の知識があれば、ほぼ解答可能なはずです!2021年12月2日に 改訂版が発売 されるので、この改訂版をざーっと読んでから解答に着手するのも良いと思います :thumbsup:

過去の日付が空いていたら、その日付にあとからその日付に参加登録してしまうのもアリです。みなさんからカッコいいコードがたくさん届くのを楽しみにしています〜😄

追記:投稿されたコードをレビューしています

投稿してもらったコードは僕の方で何回かに分けてレビューしていきます。レビュー記事はこちらです👇


CategoryQiita Official
Creator
Calendar1
SunMonTueWedThuFriSat

28

29

30

1

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

2

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

3

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

4

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

5

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

6

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

7

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

8

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

9

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

10

参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

11

参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

12

参加

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

13

チェリー本のアウトプットとしてやってみます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

14

挑戦します。

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

15

チャレンジしてみます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

16

チェリー本お世話になっております。参加希望します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

17

参加させていただきます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

18

参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

19

参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

20

高校生です。参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

21

参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

22

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

23

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

24

やります!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

25

たいよろ!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

1

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

2

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

3

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

4

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

5

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

6

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

7

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

8

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

9

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

10
参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

11
参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

12
参加

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

13
チェリー本のアウトプットとしてやってみます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

14
挑戦します。

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

15
チャレンジしてみます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

16
チェリー本お世話になっております。参加希望します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

17
参加させていただきます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

18
参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

19
参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

20
高校生です。参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

21
参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

22

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

23

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

24
やります!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

25
たいよろ!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

SunMonTueWedThuFriSat

28

29

30

1

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

2

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

3

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

4

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

5

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

6

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

7

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

8

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

9

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

10

参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

11

参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

12

参加

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

13

チェリー本のアウトプットとしてやってみます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

14

挑戦します。

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

15

チャレンジしてみます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

16

チェリー本お世話になっております。参加希望します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

17

参加させていただきます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

18

参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

19

参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

20

高校生です。参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

21

参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

22

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

23

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

24

やります!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

25

たいよろ!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

1

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

2

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

3

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

4

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

5

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

6

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

7

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

8

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

9

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

10
参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

11
参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

12
参加

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

13
チェリー本のアウトプットとしてやってみます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

14
挑戦します。

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

15
チャレンジしてみます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

16
チェリー本お世話になっております。参加希望します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

17
参加させていただきます!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

18
参加します

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

19
参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

20
高校生です。参加します!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

21
参加させていただきます

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

22

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

23

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

24
やります!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use

25
たいよろ!

Overwrite

You can post either your article on Qiita or your blog post.

When you participate, When you participate, we will assume that you have agreed to the terms of use