Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Map-range/Ruby/map-range-1.rb
Normal file
6
Task/Map-range/Ruby/map-range-1.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
def map_range(a, b, s)
|
||||
af, al, bf, bl = a.first, a.last, b.first, b.last
|
||||
bf + (s - af)*(bl - bf).quo(al - af)
|
||||
end
|
||||
|
||||
(0..10).each{|s| puts "%s maps to %g" % [s, map_range(0..10, -1..0, s)]}
|
||||
3
Task/Map-range/Ruby/map-range-2.rb
Normal file
3
Task/Map-range/Ruby/map-range-2.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(0..10).each do |s|
|
||||
puts "%s maps to %s" % [s, map_range(0..10, -1..0, s)]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue