[Solved] Rspec pass test in ruby testing

[ad_1] solution.highest_count_words_across_lines is an array of strings. When you do this: solution.highest_count_words_across_lines.map(&:highest_wf_words) you are calling highest_wf_words on each of the array items, and that method is not defined for a String (that is what the error message says). I guess that in fact you want something like this instead: words_found = solution.highest_count_words_across_lines.map( |x| highest_wf_words(x)).flatten UPDATE … Read more

[Solved] undefined method `round’ for nil:NilClass when calculating difference between dates [closed]

Introduction [ad_1] When calculating the difference between two dates, you may encounter the error “undefined method `round’ for nil:NilClass”. This error occurs when the difference between the two dates is nil, meaning that the two dates are the same. This error can be solved by checking if the difference between the two dates is nil … Read more

[Solved] Separate a row of strings into separate rows [closed]

[ad_1] Python Power Unleased : import csv,sys filename=”a.csv” with open(filename,’rb’) as csvfile: reader = csv.reader(csvfile,delimiter=”,”) try: for row in reader: if row[1].find(‘,’) == -1: line=”,”.join(row) print line else: for i in range(0,row[1].count(‘,’)+1): line = row[0]+’,’+row[1].split(‘,’)[i]+’,’+row[2].split(‘,’)[i] print line except csv.Error as e: sys.exit(‘file %s, line %d: %s’ % (filename, reader.line_num, e)) [ad_2] solved Separate a row … Read more

[Solved] Get min and max value from this array of hashes

[ad_1] By default when you sort an array sorts by the first element first. You can reverse the array for the purposes of the sort. channel_counts_for_history_graph.map(&:reverse).max[0] 0 [ad_2] solved Get min and max value from this array of hashes

[Solved] Gets.chomp not working

[ad_1] You are supposed to enter values, not just press enter, when prompted after running the program: # ⇓ prompt ⇓ ⇓⇓ YOUR INPUT!!! How old are you? 35 Sidenote: parentheses after chomp are redundant and not ruby idiomatic. 0 [ad_2] solved Gets.chomp not working

[Solved] `Case/when` statement works some of the time

[ad_1] For some reason you iterate over REGEXS, ignore the item in the iteration, then hard-code them again… you actually do text.gsub(Supertag::Tag::USERTAG_REGEX) … 3 times – once for each REGEX in your list. Also, you misuse the case when construct, I suggest you read more about it You should either drop the each entirely, and … Read more

[Solved] User Input + Random Word and Number printing

[ad_1] input and occupation are defined outside the scope of the occupationsfunction. Either declare it as a global variable with $input and $occupation, declare it inside the function or pass the variables as arguments to the function (as Lee suggested): puts ‘What is your name?(Enter in field below)’ $input = gets.chomp puts ‘end’ occupationslist = … Read more