We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Ruby
  3. Enumerables
  4. Ruby - Enumerable - each_with_index
  5. Discussions

Ruby - Enumerable - each_with_index

Problem
Submissions
Leaderboard
Discussions

Sort 87 Discussions, By:

recency

Please Login in order to post a comment

  • patilshashank929
    3 months ago+ 0 comments

    Solution 1 :

    arr = []
    animals.each_with_index { |item, index| arr.push( "#{index}:#{item}" ) unless index < skip }
    arr
    

    Solution 2 : animals.map.with_index { |item, index| ( "#{index}:#{item}" ) unless index < skip }.compact

    0|
    Permalink
  • creubend
    4 months ago+ 1 comment
    animals.map.with_index{|v,i| "#{i}:#{v}"}.drop(skip)
    
    0|
    Permalink
  • yashdeora98294
    5 months ago+ 0 comments

    Here is Ruby - Enumerable - each_with_index problem solution - https://www.gyangav.com/2022/10/hackerrank-ruby-enumerable-each-with-index-problem-solution.html

    0|
    Permalink
  • pappuchaubey7762
    5 months ago+ 0 comments

    Here are the solution of HackerRank Ruby Enumerable each_with_index Solution you can find All HackerRank Ruby Tutorial solutions in Single Post HackerRank Ruby Tutorial solutions

    0|
    Permalink
  • akhilshaik01
    8 months ago+ 0 comments

    def skip_animals(animals, skip) arr=[] animals.each_with_index{|a, index| arr.push("#{index}:#{a}") if index>=skip} return arr end

    0|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy