Skip to content

Instantly share code, notes, and snippets.

@ljcooke
Created July 2, 2022 00:01
Show Gist options
  • Save ljcooke/850ebe698ca1559383b93462fb288737 to your computer and use it in GitHub Desktop.
Save ljcooke/850ebe698ca1559383b93462fb288737 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
i = 0
poem = DATA.read.split("\n").select { |s| s.start_with?('>') }
poem.each_with_index do |line, num|
direction = rand(2) * (num > poem.size / 2 ? -1 : 1)
options = line[1..].split('.')
i = [[0, i + direction].max, options.size - 1].min
puts options[i].strip
end
__END__
OBLIGATIONS 2
by Layli Long Soldier
> As we
> embrace . resist
> the future . the present . the past
> we work . we struggle . we begin . we fail
> to understand . to find . to unbraid . to accept . to question
> the grief . the grief . the grief . the grief
> we shift . we wield . we bury
> into light . as ash
> across our faces
https://www.poetryfoundation.org/poems/149976/obligations-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment