Created
July 25, 2026 23:12
-
-
Save CoralineAda/edef77f87015439b25d78862c4e09c30 to your computer and use it in GitHub Desktop.
Emoji Garden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Decorate your shared documents with an emoji garden, where collaborators can peacefully rest their cursors. | |
| class EmojiGarden | |
| PLANTS = %w{๐ฑ ๐ฟ โ๏ธ ๐ ๐ ๐ ๐ ๐ ๐พ ๐ต ๐ด ๐ณ ๐ฒ ๐ชด ๐ธ ๐ฎ ๐ต๏ธ ๐บ ๐ป ๐ผ ๐ท ๐ฅ ๐ชท ๐ชป ๐น ๐ ๐ฑ ๐ฟ โ๏ธ ๐ ๐ ๐ ๐ ๐ ๐พ ๐ต ๐ด ๐ณ ๐ฒ ๐ชด ๐ธ ๐ฎ ๐ต๏ธ ๐บ ๐ป ๐ผ ๐ท ๐ฅ ๐ชท ๐ชป ๐น ๐} | |
| INSECTS = %w{๐ ๐ ๐ ๐ ๐ฆ ๐ชฒ ๐ชณ ๐ชฐ ๐ฆ ๐ท๏ธ ๐ธ๏ธ ๐ฆ} | |
| HAPAX = %w{๐ฝ} | |
| SPACER = " " | |
| DENSITY = 0.2 | |
| attr_accessor :rows, :columns, :hapax | |
| def initialize(rows:, columns:) | |
| @rows = rows; | |
| @columns = columns | |
| @hapax = false | |
| end | |
| def print | |
| rows.times do | |
| row = (PLANTS | INSECTS).sample | |
| row << SPACER | |
| columns.times do | |
| seed = rand(100) | |
| if !hapax && seed == 1 | |
| character = HAPAX.sample | |
| hapax = true | |
| else | |
| character = (seed > (DENSITY * 100)) ? (PLANTS | INSECTS).sample : " " | |
| end | |
| row << character | |
| row << SPACER | |
| end | |
| puts row | |
| end | |
| end | |
| end | |
| EmojiGarden.new(rows: 5, columns: 10).print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment