gistlib
other ruby categories
syntax-error code snippets in ruby
fix : `def convert(n) res = ''; nums = [3, 5, 7]; sounds = %w[pling plang plong]; nums.each |i| { (n % nums[i]).zero? ? res += sounds[i] : (res == '' ? n.to_s : "") } end res end in ruby
fix this `class grains def self.square(n) = 2 ** (n - 1); raise argumenterror if !n.between?(1,64) def self.total = 18_446_744_073_709_551_615 end` in ruby
fix: `def conv(n) res = ''; nums = [3, 5, 7]; sounds = ['pling', 'plang', 'plong'] nums.length.times do |i| if n % nums[i] == 0 res << sounds[i] else res.empty? ? n.to_s : res end end end` in ruby
in ocaml, i ran this caml program: `x + 2 where x = 34` why did it fail? in ruby
what is wrong here? " def cheap = @items.map { |itm| itm[:price].select {|prod| prod if prod < 30}}" in ruby
what's wrong? ` def solution(n) multiples = [] (1..n).each do |x| if x % 15 == 0 multiples << x end if x < 0 return 0 end return multiples.sum end` in ruby
what's wrong? ` module resistorcolorduo cols = %w(black brown red orange yellow green blue violet grey white).map.with_index.to_h def self.value(input) = input.first(2).sum('', &cols).to_i end` in ruby
gistlib
by LogSnag