7 kyu

Populate hash with array keys and default value

1,256 of 4,131jhoffner

Description:

Complete the function so that it takes a collection of keys and a default value and returns a hash (Ruby) / dictionary (Python) / map (Scala) with all keys set to the default value.

Example

solution([:draft, :completed], 0) # should return {draft: 0, completed: 0}
populate_dict(["draft", "completed"], 0)  # should return {"draft": 0, "completed: 0}
populateMap(Seq("draft", "completed"), 0) // => Map("draft" -> 0, "completed" -> 0)
Arrays
Fundamentals

Stats:

CreatedJun 20, 2013
PublishedJun 20, 2013
Warriors Trained5722
Total Skips770
Total Code Submissions13702
Total Times Completed4131
Ruby Completions2734
Python Completions1256
Scala Completions8
Total Stars48
% of votes with a positive feedback rating90% of 346
Total "Very Satisfied" Votes287
Total "Somewhat Satisfied" Votes47
Total "Not Satisfied" Votes12
Ad
Contributors
  • jhoffner Avatar
  • anter69 Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • saudiGuy Avatar
Ad