Mae向きなブログ

Mae向きな情報発信を続けていきたいと思います。

大学入学共通テスト「情報」の試作問題をRubyで解く

奥村先生の「シーザー暗号」を読んで、自分も数年後を見据えて解いておこうということで、以下の試作問題を書き慣れているRubyで動かしてみました。

jouhou_shisaku.rb

実行

$ ruby jouhou_shisaku.rb
 a:   1  b:  79  c:  44  d: 126  e:  21
 f:  24  g:  28  h:   0  i:  10  j:   0
 k: 102  l:  14  m:  31  n:  58  o: 165
 p:  27  q:  28  r:  80  s:  68  t:   0
 u:   3  v:  42  w:  13  x:  77  y:  93
 z:  15
four score and seven years ago our fathers brought forth on this
continent, a new nation, conceived in liberty, and dedicated to the
proposition that all men are created equal.

now we are engaged in a great civil war, testing whether that nation,
or any nation so conceived and so dedicated, can long endure. we are
met on a great battle-field of that war. we have come to dedicate a
portion of that field, as a final resting place for those who here
gave their lives that that nation might live. it is altogether fitting
and proper that we should do this.

but, in a larger sense, we can not dedicate -- we can not consecrate
-- we can not hallow -- this ground. the brave men, living and dead,
who struggled here, have consecrated it, far above our poor power to
add or detract. the world will little note, nor long remember what we
say here, but it can never forget what they did here. it is for us the
living, rather, to be dedicated here to the unfinished work which they
who fought here have thus far so nobly advanced. it is rather for us
to be here dedicated to the great task remaining before us -- that
from these honored dead we take increased devotion to that cause for
which they gave the last full measure of devotion -- that we here
highly resolve that these dead shall not have died in vain -- that
this nation, under god, shall have a new birth of freedom -- and that
government of the people, by the people, for the people, shall not
perish from the earth.

参考