Files
hello-algo/ru/codes/ruby/utils/vertex.rb
Yudong Jin 7a78369e4c Migrate to Zensical (#1869)
* Fix Russian Ruby code extraction.

* Add zensical configs.
2026-03-29 05:41:25 +08:00

25 lines
677 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
=begin
File: vertex.rb
Created Time: 2024-04-25
Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
=end
### Класс вершины ###
class Vertex
attr_accessor :val
def initialize(val)
@val = val
end
end
### На вход подается список значений vals, на выходе возвращается список вершин vets ###
def vals_to_vets(vals)
Array.new(vals.length) { |i| Vertex.new(vals[i]) }
end
### На вход подается список вершин vets, на выходе возвращается список значений vals ###
def vets_to_vals(vets)
Array.new(vets.length) { |i| vets[i].val }
end