ビンゴゲーム・ジェネレータ

30分プログラム、その696。ビンゴゲーム・ジェネレータ。

とはいっても、実際にシートを作るわけではく、ターミナルにテキストを吐き出すだけです。

 9 34 72 74 10
93 16 36 95 61
 3 12  * 32 34
64 77 64 57  2
51 24 42 92  0

要するに

  • 5x5のマス目に数字を並べる
  • 各マス目が0-99の乱数
  • 真ん中のマス目だけは数字にしない

みたいなやつを生成します。

使い方

$ perl bingo.pl
 9 90 76 69 15
98 94 35 79 20
36 91  * 83 53
21 45 31 45  1
64 69 97 31 30

$ perl bingo.pl
 9 34 72 74 10
93 16 36 95 61
 3 12  * 32 34
64 77 64 57  2
51 24 42 92  0

ソースコード

#! /usr/bin/perl
# -*- mode:perl; coding:utf-8 -*-
#
# bingo.pl -
#
# Copyright(C) 2009 by mzp
# Author: MIZUNO Hiroki / mzpppp at gmail dot com
# http://howdyworld.org
#
# Timestamp: 2009/11/16 21:19:14
#
# This program is free software; you can redistribute it and/or
# modify it under MIT Lincence.
#
use strict;
use warnings;
use Data::Dumper;

my @table=();
for (0..25){
    $table[$_] = int(rand(99));
}
$table[13] = '*';

for(0..4){
    my $n = $_ * 5;
    for my $cell (@table[$n + 1 .. $n+5]){
	printf "%2s ",$cell;
    }
    print "\n";
}