Skip to content

Instantly share code, notes, and snippets.

@akht
akht / bowling.rb
Created January 18, 2023 17:11
ボウリングのスコア計算プログラム(旧ルール)
scores = ARGV[0].strip.split(',').flat_map { |p| p == 'X' ? [10, nil] : p.to_i }
frames = scores.each_slice(6).flat_map { |n| n.size.even? ? n.each_slice(2).to_a : [n] }
total = (0..9).inject(0) do |acc, i|
current_frame, next_frame, after_next_frame = frames.slice(i, 3)
bonus = [current_frame.first == 10, current_frame.compact.sum == 10].sum { |i| i ? 1 : 0 } # strikeは2投分,spareは1投分
acc + current_frame.compact.sum + [next_frame, after_next_frame].flatten.compact.take(bonus).sum
end
puts total

🤔 POAPって何? 🤔

POAPとは…?

「POAP:Proof of Attendance Protocol(ポープ)」は、現実世界・仮想空間問わずイベントに参加した際の証として発行し活用できる、NFT化された参加証明バッジ。

https://chizaizukan.com/property/616/ より引用

つまり「こんなイベントに参加したよ」「こんなことをしたよ」という証明がブロックチェーン上に刻まれるということです!