Dataset Viewer (First 5GB)
The table contains 100 rows per page, up to 5GB.
Full Screen Viewer
Full Screen
query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. | def longest_word(sen)
tmp_arr = sen.split(" ")
tmp_longest = 0
tmp_arr.each do |i|
tmp_longest = i.size if i.size > tmp_longest
end
tmp_arr.select { |i| i.size == tmp_longest }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LongestWord(sen)\n str = sen.split(\" \")\n longest_word = str[0]\n str.each do |word|\n word.sub(/[\\w\\s]/, '')\n if longest_word.length < word.length\n longest_word = word\n end\n end\n longest_word\nend",
"def LongestWord(sen)\n\tarr = sen.gsub(/[^a-zA-Z]+/m, ' ').strip.split(\" \")\n\tcounter = \"\" \n\t\tarr.each do |word|\n\t\t\tif word.length >= counter.length \n\t\t\t\tcounter = word \n\t\t\tend\n\t\tend\n\t\tcounter\nend",
"def LongestWord(sen)\n longest = \"\"\n sen.scan(/\\w+/) do |word|\n if word.length > longest.length\n longest = word\n end\n end\n \n return longest\nend",
"def get_the_shortest_word(str)\n str.split(\" \").sort! {|s, l| s.length <=> l.length}[0]\nend",
"def LongestWord(sen)\n arr = sen.split(' ')\n longest = arr[0]\n arr.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\nend",
"def find_short(s)\n return s.split(' ').min_by{|word| word.length}.length\nend",
"def find_short(s)\n l = s.split(\" \").min_by { |x| x.length}.length\n return l #l: length of the shortest word\nend",
"def longest_word (sen)\n i = 0\n while i < sen.length do\n # negated regex boolean\n if sen[i] !~ /[a-z]|\\s/\n sen.slice!(i)\n else\n sen[i]\n i += 1\n end\n end\n return sen.split(\" \").max_by(&:length).length\nend",
"def longest_word(sen)\n words = sen.split\n words.map! { |word| word.delete('^A-Za-z1-9_\\'') }\n longest = words.first\n words.each_with_index do |word, idx|\n next if idx >= words.size - 1\n longest = longest.size < words[idx + 1].size ? words[idx + 1] : longest\n end\n longest\nend",
"def shortest_string(list_of_words)\n return nil if no_string?(list_of_words)\n return list_of_words[0] if one_string?(list_of_words)\n \telse\n \t\tfirst_word = list_of_words[0]\n \t\tx = 1\n \t\twhile x < list_of_words.length\n \t\t\tif first_word.length > list_of_words[x].length\n \t\t\t\tfirst_word = list_of_words[x]\n \t\t\tend\n \t\t\tx += 1\n \t\tend\n \t\treturn first_word\nend",
"def LongestWord(sen)\n arr = sen.split(\" \")\n arr.sort! { |a, b| b.length <=> a.length }\n arr[0]\n\nend",
"def find_short(s)\n return s.split(\" \").map { |word| word.length }.min\nend",
"def first_word(sentence)\n\tsentence.split(\" \").first\nend",
"def longestWord(sen)\n\tarray = []\n\tsen.gsub!(/[^0-9a-zA-Z\\s]/i, '')\n\tsen = sen.split(' ')\n\tsen.each {|word| array.push(word)}\n\tarray.sort! { |x,y| y.length <=> x.length }\n\treturn array.first\nend",
"def shortest_string(list_of_words)\n if list_of_words == []\n \treturn nil\n else\n \tcounter = 0\n \tshortest_word = ''\n \tshorest_word_length = list_of_words[0].length\n \twhile counter < list_of_words.length\n \t\tif shorest_word_length >= list_of_words[counter].length\n \t\t\tshortest_word = list_of_words[counter]\n \t\tend\n \tcounter += 1\n \tend\n end\n return shortest_word\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest_length = list_of_words.first.length\n shortest_word = ''\n list_of_words.each do |word|\n if word.length <= shortest_length\n shortest_length = word.length\n shortest_word = word\n else\n shortest_word = shortest_word\n end\n end\n return shortest_word\n end\nend",
"def first_word(str); str.split.first end",
"def first_word string\n string.split(' ')[0]\nend",
"def find_short(s)\n # your code here\n the_1st_array = s.split(\" \")\n this_counts = []\n i = 0\n while i < the_1st_array.count\n this_counts.push(the_1st_array[i].length)\n i+=1\n end\n l = this_counts.min\n return l # l: length of the shortest word\nend",
"def shortest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.min == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend",
"def start_of_word word, length\n word.chars.take(length).join\nend",
"def first_word(s)\n\ta = s.split()\n\treturn a[0]\nend",
"def first_word(string)\n\tstring.split(\" \")[0]\nend",
"def LongestWord(str)\n words = str.split.map { |s| s.gsub(/\\W/, '') }\n longest = words [0]\n words.each { |word| longest = word if word.length > longest.length }\n longest\nend",
"def get_the_shortest_word(str)\n words = str.split()\n return words.max\nend",
"def first_word(sentence)\n\t\tsentence.split[0]\nend",
"def first_word(string)\n\treturn string.split.first \nend",
"def first_word(words)\n\twords.split(\" \")[0]\nend",
"def shortest_word(words)\n words.inject { |memo, word| memo.length < word.length ? memo : word}\nend",
"def get_the_longest_word(str)\n str.split(\" \").sort! {|s, l| l.length <=> s.length}[0]\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty? == true\n return nil\n end\n word = 1\n list_of_words.each do |x|\n if x.length <= word.to_s.length\n word = x\n end\n end\n p word\nend",
"def find_short(s)\n s.split(' ').map{|e|e.length}.min\nend",
"def shortest_string(list_of_words)\n if list_of_words == []\n return nil\n end\n i = 0\n array_length = array_size(list_of_words)\n smallest_index = 0\n for i in 0..array_length - 1\n if string_length(list_of_words[smallest_index]) > string_length(list_of_words[i])\n smallest_index = i\n end\n end\n return list_of_words[smallest_index]\nend",
"def LongestWord(sen)\n words = sen.split(' ').map do |i|\n /[a-zA-Z0-9]+/.match(i)\n end\n\n longest = words.max_by.each do |i|\n i.to_s.length\n end\n\n longest\n\nend",
"def first_word(string)\n\twords = string.split(\" \")\n\treturn words[0]\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty? \n return nil\n end\n \n short=list_of_words[0]\n list_of_words.each { |str| \n if str.length < short.length\n short=str\n end \n }\n return short\nend",
"def middle_word(string)\n words = string.split(' ')\n size = words.size\n if size == 0\n \"Invalid input! Empty string!\"\n elsif size.even?\n \"Invalid input! Even number of words in sentance!\"\n elsif size == 1\n \"Invalid input! Only one word in the string!\"\n else\n words[-(size/2)-1]\n end\nend",
"def longest_word(str)\n longest_word = \"\"\n words = str.split(' ')\n\n words.each do |word|\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\nend",
"def longest_word(str)\r\n\r\n # temporary variables created\r\n word_length = 0\r\n longest_word = \"\"\r\n\r\n # checks length of each word\r\n str.split(\" \").each {|word|\r\n\r\n if word.length >= word_length\r\n word_length = word.length\r\n longest_word = word\r\n end\r\n\r\n }\r\n\r\n longest_word\r\nend",
"def trim_to_word( max_length )\n string = self\n if string.length > max_length\n string = string[0..max_length-4]\n while string[-1,1] =~ /[\\w]/ && string.length > 1\n string = string[0..string.length-2]\n end\n string += \"...\"\n end\n string\n end",
"def longest_word(sentence)\n words = sentence.split(\"\") #This automically creates a new array with the string split already right?\n idx = 0\n # initially the longest word is empty\n \n longest_w = ''\n \n # We will loop over the current word.\n \n while idx < words.length\n if (words[idx].length > longest_w.length)\n longest_w = words[idx]\n else \n longest_w = longest_w\n end\n \n idx = idx + 1\n end\n \n return longest_w\nend",
"def longest_word(sentence)\n result = \"\"\n sentence.split.each do |word|\n if word.length > result.length\n result = word\n end\n end\nresult\nend",
"def first_word(text)\n text.split.first\nend",
"def shortest_string(list_of_words)\n if list_of_words.length == 0\n nil\n else\n index = 0\n shortest_word = list_of_words[0]\n while index < list_of_words.length do\n if list_of_words[index].length <= shortest_word.length\n shortest_word = list_of_words[index]\n end\n index+=1\n end\n shortest_word\n end\n end",
"def first_word(input)\n # Split string into array of words and select first entry\n input.split(\" \")[0]\nend",
"def first_word(text)\n first_word = ''\n for num in 0...text.length\n break if text[num] === ' '\n first_word << text[num]\n end\n first_word\nend",
"def first_word(text)\n\treturn text.split.first\nend",
"def find_short(s)\n # input is string\n # convert string to array\n converted = s.split(\" \") # gives us an array of words\n # order elements of array by length\n sorted_by_length = converted.sort_by {|x| x.length}\n # returns an array of words sorted by length\n # return the first element in array\n return sorted_by_length[0].length\n \nend",
"def first_word (phrase)\n morceaux = phrase.split\n return morceaux[0]\nend",
"def first_word(str)\n\treturn str.split[0]\nend",
"def first_word(str)\n str.split[0]\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n\n list_of_words.each do |word|\n if word.length < shortest.length\n shortest = word\n end\nend\n\nreturn shortest\nend",
"def first_word str\n arr = str.split(' ')\n arr[0]\nend",
"def words_of_same_length(word)\n\treturn $words[word.length]\nend",
"def first_word (s)\n # On mets tout les mots dans un tableau et on revoie le contenue le la première case du tableau\n s.split.first\nend",
"def start_of_word(str, l); l == 1 ? str[0] : str[0...l] end",
"def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend",
"def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend",
"def longest_word(sentence)\n words = sentence.split(\" \") # words = \"hello, you, motherfucker\"\n\n idx = 0\n while idx < words.length # 0 < 3\n current_word = words[idx] # current_word = words[0]\n\n longest_word = \"\" # set initial longest_word as empty string.\n if current_word.length > longest_word.length\n longest_word = current_word\n end\n\n idx += 1\n end\n return longest_word\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n for word in 1...list_of_words.length\n if shortest.length > list_of_words[word].length then\n shortest = list_of_words[word]\n end\n end\n return shortest\nend",
"def middle_word(text)\n words = text.split\n return '' if words.size <= 1\n\n words[words.size / 2]\nend",
"def longest_word(string_of_words)\n # Give me back the longest word!\n longest = \"\"\n string_of_words.split(\" \").each do | word |\n if longest.length <= word.length\n longest = word\n end\n end\n return longest\nend",
"def shortest_string(list_of_words)\n\tif list_of_words==[]\n\t\treturn nil\n\telse\n\t\tshort_string=list_of_words[0]\n \t\tlist_of_words.each do |x|\n \t\t\tif x.length < short_string.length\n \t\t\t\tshort_string = x\n\t\t\tend\t\t\n\t\tend\n \t\treturn short_string\n \tend\nend",
"def shortest_string(list_of_words)\n\treturn list_of_words.min_by {|x| x.length }\nend",
"def first_word(word)\n\treturn word.split[0]\nend",
"def first_word(word)\n words = word.split(\" \")\n words[0]\nend",
"def first_word (a)\n\t return a.split[0]\nend",
"def find_short(sentence)\n word_array = sentence.split\n\n word_array.sort! do |word_a, word_b|\n word_a.length <=> word_b.length\n end\n\n return word_array.first.length\nend",
"def find_longest_word(string)\n sentence = string.split\n longest_word = \"\"\n sentence.each do |word|\n word.gsub!(/\\W/, \"\") # filters out non alphanumeric\n longest_word = word if word.length >= longest_word.length\n end\n longest_word\nend",
"def find_longest_word(sentence)\n words = sentence.downcase.tr(\"^a-z\", \" \").split\n longest = \"\"\n words.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\n\nend",
"def middle_word(string)\n words = string.split\n word_count = words.length\n mid_index = word_count / 2\n if word_count == 0\n ''\n elsif word_count.even?\n # if even number of words, return the two words across the middle.\n \"#{words[mid_index - 1]} #{words[mid_index]}\"\n else\n words[mid_index]\n end\nend",
"def longest_word(sentence)\n\t\n\tarr = sentence.split(\" \")\n\tarr = []\n\tlongest = \"\"\n\t\n\tarr.each do |word|\n\tlongest = word if longest.length < word.length\t\n end\n return longest\nend",
"def find_longest_word(input)\n array = input.split(\" \")\n array.sort! { |x, y| y.length <=> x.length }\n array[0]\nend",
"def first_word\r\n text =~ /^.*?\\S.*?/\r\n $&\r\n end",
"def longest_word(sentence)\n word_arr = sentence.split\n longest = word_arr.shift\n \n word_arr.each do |word|\n longest = word if word.length >= longest.length\n end\n\n longest\nend",
"def shortest_string(list_of_words)\n list_of_words = list_of_words.sort_by {|x| x.length}\n short_string = list_of_words[0]\n return short_string\nend",
"def shortest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length > list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend",
"def first_word(word)\n\treturn \"#{word}\".split.first ###### divise le premier element du reste de la chaine\nend",
"def get_the_longest_word(str)\n words = str.split()\n longest = [0, \"\"]\n\n for word in words\n if word.length > longest[0]\n longest[0] = word.length\n longest[1] = word\n end\n end\n\n print(longest[1])\n return longest[1]\nend",
"def longest_string(list_of_words)\n if list_of_words.length > 0\n longest_word = list_of_words[0]\n for word in list_of_words\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\n end\nend",
"def middle_word(str)\n words = str.split(\" \")\n middle_word = words[words.size/2]\nend",
"def shortest_string(list_of_words)\n \n array = []\n\n list_of_words.each {|value|\n \tarray << value.length\n }\n\n if array.empty?\n \tnil\n else\n return list_of_words[array.index(array.min)]\n end\n\nend",
"def find_longest_word(sentence)\n # removes special characters | sorts by length | reverses to start with the longest\n longest = sentence.split(/\\W+/).sort_by { |word| word.length }.reverse!\n longest[0]\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n shortest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length < shortest.length\n shortest = word\n end\n }\n\n return shortest\nend",
"def start_of_word(a)\n return a.chars.first.join\nend",
"def shortest_string(list_of_words)\n length_of_words = {}\n list_of_words.each do |word|\n word_length = word.length\n length_of_words[word] = word_length\n end\n answer = length_of_words.min_by{|k,v| v}\n if answer == nil\n return nil\n else\n answer.first\n end\nend",
"def shortest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\tlist_of_words.sort_by! {|i| i.length}\n\treturn list_of_words[0]\nend",
"def longest_two_words(string)\n string.gsub(/[[:punct:]]/, '').split.sort_by(&:length)[-2..-1]\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest = list_of_words[0]\n list_of_words.each.to_s do |x|\n if list_of_words.length < shortest\n shortest = x\n end\n end\n end\n return shortest\nend",
"def longest_word(string)\n\t\n\tsplitted_string = string.split(\" \")\n\tword_length = []\n\t\n\tsplitted_string.each { |word| word_length << word.length }\n\t\n\tmax = word_length.max\n\tidx = word_length.index(max)\n\tsplitted_string[idx]\n\t\nend",
"def shortest_string(list_of_words)\n if list_of_words.length == 0\n \treturn nil\n end\n shortest_str = list_of_words[0]\n list_of_words.each do |str| \n \tif str.size < shortest_str.size\n \t\tshortest_str = str\n \tend\n end\n shortest_str\nend",
"def longest_word(sentence)\n words = sentence.split(\"\\s\")\n \n max_word = nil\n for word in words do\n if max_word == nil \n max_word = word\n elsif word.length > max_word.length \n max_word = word\n end\n end\n \n return max_word\nend",
"def shortest_string(list_of_words)\n \n short_string = list_of_words[0]\n \n i = 0\n while i < list_of_words.length\n current_item = list_of_words[i]\n if current_item.length < short_string.length\n short_string = current_item\n end\n i = i + 1\n\n end\n short_string\nend",
"def longest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.max == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n array_number = 1\n while array_number < list_of_words.length\n \tif list_of_words[array_number].length < shortest.length\n \t\tshortest = list_of_words[array_number]\n \tend\n \tarray_number += 1\n end\n return shortest\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n if list_of_words.empty?\n return nil\n end\n shortest_word = list_of_words[0]\n for word in list_of_words\n if word.length < shortest_word.length\n shortest_word = word\n end\n end\n return shortest_word\n\nend",
"def shortest_string(list_of_words)\n\n#If presented with an array of mixed objects, maybe not all strings\n# strings = []\n# list_of_words.each do |i|\n# if i.is_a? String\n# strings.push(i)\n# end\n# end\n\n\n\n if list_of_words.length ==0\n return nil\n else\n i=0\n shorty = list_of_words[0]\n while i<list_of_words.length do\n if list_of_words[i].length <= shorty.length\n shorty = list_of_words[i]\n end\n i += 1\n end\n return shorty\n end\nend",
"def longest_word(phrase)\n longestWord = \"\"\n longestWordLength = 0\n \n wordArray = phrase.split(\" \")\n wordArray.each do |word|\n if word.length > longestWordLength\n longestWord = word\n longestWordLength = word.length\n end\n end\n return longestWord\nend",
"def longest_word(sentence)\n\tarr = sentence.split(\" \")\n\tp arr\n\titer = 0\n\twhile iter < arr.length\n\t\tlongest_word = nil\n\t\tcurrent_word = arr[iter]\n\t\tif longest_word == nil\n\t\t\tlongest_word = current_word\n\t\telsif longest_word.length < current_word.length\n\t\t\tlongest_word = current_word\n\t\tend\n\t\titer+=1\n\tend\n\treturn longest_word\nend",
"def shortest_string(list_of_words)\n\treturn list_of_words.min{|a,b| a.size <=> b.size}\nend"
] | [
"0.781355",
"0.758387",
"0.74880713",
"0.74303347",
"0.73972505",
"0.7377614",
"0.7355616",
"0.7231046",
"0.7179081",
"0.7120521",
"0.70515186",
"0.7044977",
"0.7025602",
"0.7022134",
"0.7019273",
"0.6981005",
"0.6978153",
"0.69676393",
"0.69303095",
"0.6930229",
"0.6918541",
"0.6913213",
"0.6890667",
"0.6867375",
"0.6864495",
"0.6836116",
"0.6828815",
"0.6782521",
"0.67589414",
"0.6757986",
"0.6752001",
"0.6713143",
"0.67060137",
"0.6700114",
"0.66906154",
"0.668472",
"0.66836524",
"0.6683358",
"0.66768336",
"0.6671723",
"0.6659513",
"0.66574734",
"0.6643902",
"0.662719",
"0.6626571",
"0.66213727",
"0.660991",
"0.6609507",
"0.6606227",
"0.6606132",
"0.6600773",
"0.6594053",
"0.65930873",
"0.6589846",
"0.6584737",
"0.65789527",
"0.65768224",
"0.65768224",
"0.657359",
"0.6567339",
"0.65660006",
"0.6565872",
"0.6560191",
"0.65580463",
"0.6552885",
"0.65478724",
"0.65369403",
"0.6517868",
"0.6516508",
"0.6502217",
"0.64977",
"0.6494581",
"0.6493246",
"0.64826584",
"0.6479429",
"0.64586246",
"0.64548343",
"0.6433684",
"0.6419109",
"0.6417301",
"0.6392552",
"0.6392305",
"0.6388806",
"0.63806164",
"0.6374807",
"0.63706887",
"0.6369439",
"0.6364969",
"0.63585275",
"0.6357744",
"0.6356799",
"0.63525504",
"0.6349405",
"0.63452613",
"0.6337842",
"0.63329166",
"0.632315",
"0.6317218",
"0.63111717",
"0.63091224"
] | 0.6989949 | 15 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.welcome_email.subject | def product_email(product, user)
@greeting = 'Hi'
@product = product
mail to: user.email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def message_subject=(value)\n @message_subject = value\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject\n @mail.subject\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def welcome_email(user)\n @user = user\n mail(to: @user.email, subject: t(\"users.email.welcome.subject\"))\n end",
"def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end",
"def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end",
"def welcome_email\n NotifierMailer.welcome_email User.take\n end",
"def welcome_email(resource)\n \n @resource = resource\n\n mail :to => @resource.email, :from => \"email@domain.com\", :subject => \"Subject line\"\n \n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def welcome_email\n UserMailer.welcome_email\n end",
"def welcome_email\n UserMailer.welcome_email\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def send_welcome_email(user)\n mail to: user.email, subject: \"Sign Up Confirmation - Welcome to NetworkMill\"\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"welcome_email\")\n end",
"def welcome_email(user)\n \t@user = user\n\n \tmail :to\t\t=> user.email,\n \t\t :subject\t=> \"Welcome to Project Help!\"\n end",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def subject=(string)\n set('Subject', string)\n end",
"def welcome_email(user_info)\n @email = user_info[:mail]\n @name = user_info[:name]\n mail(:to => @email, :subject => \"تم تأكيد تسجيلك في !\")\n end",
"def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end",
"def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end",
"def subject_name=(value)\n @subject_name = value\n end",
"def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end",
"def welcome_mail(user)\n mail to: user.email,\n subject: \"Welcome to Startglory\"\n\n end",
"def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def welcome(organisation)\n @organisation = organisation\n\n if !@organisation.email.nil? and ['en', 'fr'].include? @organisation.locale\n I18n.with_locale(@organisation.locale) do\n mail(to: @organisation.email, subject: t('emails.welcome.subject')) do |format|\n format.html { render layout: 'email_simple.html.erb' }\n format.text\n end\n end\n end\n end",
"def welcome_user_email(user)\n @user = user\n @url = login_url\n mail(\n :subject => \"Welcome to StudyHall\",\n :from => \"noreply@studyhall.com\",\n :to => @user.email\n )\n end",
"def welcome_email(person, options = {})\n @person = person\n @host = ENV['HOST_NAME'] || \"localhost:3000\"\n\n mail(:to => [@person.personal_email],\n :subject => options[:subject] || \"Welcome to Carnegie Mellon University Silicon Valley (\" + @person.email + \")\",\n :date => Time.now)\n\n end",
"def group_welcome_email\n NotifierMailer.group_welcome_email Group.take\n end",
"def welcome_email(user)\n @user = user\n mail( to: user.email,\n subject: 'Thanks for signing up for Shiftable!',\n sent_on: Time.now )\n end",
"def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end",
"def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end",
"def send_welcome\n UserMailer.welcome_email(self).deliver\n end",
"def welcome_email(user)\n @user = user\n\n mail to: user.email, subject: 'Welcome to Alumni Connection!', from: 'WebMaster@AlumniConnection.com'\n end",
"def subject_name\n return @subject_name\n end",
"def welcome_email(user)\n @user = user\n mail to: @user.email, subject: 'Welcome to Our Jungle Store'\n end",
"def welcome_email(user)\n @user = user\n @subject = \"Welcome to Rays Cruiser, home of customized cruisers\"\n result = mail(:to => @user.email, :subject => @subject)\n # puts \"+++++++ Notification Email status: -> \" + result.to_s\n end",
"def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end",
"def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = 'paigepon@gmail.com'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def send_welcome\n UserMailer.welcome_email(self).deliver!\n end",
"def welcome_email\n # NewsletterMailer.welcome_email.deliver\n mail(:to => \"rajakuraemas@gmail.com\", :subject => \"Welcome to My Awesome Site\")\n end",
"def send_welcome_email\n UserMailer.welcome(self).deliver_now\n end",
"def welcome_email(user, currenthost)\n\t @user = user\n\t @currenthost = currenthost\n\n\t mail(to: @user.email, subject: 'Welcome to Changefindr').deliver()\n\tend",
"def welcome_email(user)\n\t\t@user = user\n\t\tmail(to: user.email.to_s, subject: \"Welcome to Interest Points\")\t\n\tend",
"def welcome_email(user)\n @user = user\n @url = 'http://example.com/login' #\n mail(to: @user.email, subject: 'Welcome to My Awesome Site') #gets user email address and supplies a generic subject line\n end",
"def user_added_email(user)\n ActsAsTenant.without_tenant do\n @course = user.course\n end\n @recipient = user.user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end",
"def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end",
"def user_welcome_notice(user)\n @user = user\n mail(:to => @user.email, :subject => \"Welcome to SocialStreet\") unless @user.email.blank?\n end",
"def send_welcome(user)\n @user = user\n mail(:to => user.email, :subject => \"Welcome to My Awesome Site\", :content_type => 'text/html', :template_name => 'send_welcome.html')\n end",
"def subject_titles\n @subject_titles ||= sw_subject_titles\n end",
"def subject_name\n subject_full_name\n end",
"def welcome_signup_email(signup)\n @signup = signup\n mail(\n :subject => \"We will be coming to your school soon!\",\n :from => \"noreply@studyhall.com\",\n :to => @signup.email\n )\n end",
"def headers\n { subject: \"#{I18n.t('cms.contact_form.subject_prefix')}: #{reason}: #{subject}\",\n to: Account.current.preferred_support_email,\n from: Account.current.preferred_support_email,\n reply_to: %(\"#{name}\" <#{email}>) }\n end",
"def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end",
"def welcome_email(user)\n @greeting = \"Hi\"\n\n mail to: user.email\n end",
"def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end",
"def send_welcome_mail\n UserMailer.welcome(self).deliver_now\n end",
"def message_subject\n return @message_subject\n end",
"def welcome_email email_address\n @greeting = \"Hi\"\n @user_name = UserInfo.last.user\n\n mail to: email_address\n end",
"def welcome_email(user)\n\n @user = user\n Rails.logger.info 'hello'\n emails = ['leolopelofranco@gmail.com', 'leo@palmsolutions.co']\n\n mail(to: user[\"to\"], subject: user[\"subject\"])\n\n end",
"def welcome_email\n UserMailer.with(user: @user).welcome_email.deliver_later\n end",
"def send_welcome_email\n UserMailer.welcome_message(self).deliver_later\n end",
"def newcompany_email(company)\n @company = company\n @message = t('mailers.company.created')\n \n emails = AdminUser.all.collect(&:email).join(\",\")\n\n mail(:to => emails, :subject => \"#{t('site_title')}: #{@message}\")\n \n end",
"def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end",
"def reminder_email(user)\n @user = user\n I18n.with_locale user.locale do\n mail to: @user.email\n end\n end",
"def subject_alternative_name\n extensions[R509::Cert::Extensions::SubjectAlternativeName]\n end",
"def subject\n self['subject']\n end",
"def subject\n message.subject\n end",
"def default_sender_address\n address = Mail::Address.new(Gitlab.config.gitlab.email_from)\n address.display_name = \"GitLab\"\n address\n end",
"def welcome(user)\n @appname = \"Oasis Books\"\n mail( :to => user.email,\n :subject => \"Welcome to #{@appname}!\")\n end",
"def set_subject(subject)\n\t\tend",
"def newsletter(user, subject, text)\n @user = user\n @text = text\n\n mail(to: user.email, subject: subject)\n end",
"def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end",
"def alert_preamble\n text = user ? user.email : ''\n text += \" [#{company.name}]\" if company\n text\n end",
"def headers\n { subject: \"#{site_name} contact form\", to: site_email, from: email }\n end",
"def headers\n {\n subject: \"[#{Setting.site_name}] Neue Quelle eingesendet\",\n to: Setting.email,\n reply_to: email,\n from: Setting.get('from'),\n }\n end",
"def welcome(user)\n @name = user.email.split(\"@\").first\n @name = @name.titleize\n @greeting = \"Hi\"\n\n mail to: \"#{@name} <user.email>\"\n end",
"def welcome(email)\n @greeting = \"Hi\"\n\n mail to: email, subject: \"Email template\"\n end",
"def welcome(user)\n @user = user\n mail :to => user.email, :subject => \"vm2014.ifkff.org - Välkommen!\"\n end",
"def subject\n title \n end"
] | [
"0.6765104",
"0.6726595",
"0.67247695",
"0.67163604",
"0.67111814",
"0.67100495",
"0.6694839",
"0.6693109",
"0.6671716",
"0.6627427",
"0.6599362",
"0.65409476",
"0.6539258",
"0.65040624",
"0.64823294",
"0.64546007",
"0.6429769",
"0.6403822",
"0.6354559",
"0.6319615",
"0.6319615",
"0.62802696",
"0.62658256",
"0.6239452",
"0.62319535",
"0.62114763",
"0.6156722",
"0.61546624",
"0.61331713",
"0.61200047",
"0.6114654",
"0.61121917",
"0.6087684",
"0.6081847",
"0.6081847",
"0.6081847",
"0.6081847",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6077619",
"0.6072605",
"0.60657924",
"0.60589385",
"0.6049369",
"0.6046061",
"0.60459036",
"0.60423553",
"0.60347223",
"0.6028135",
"0.60243154",
"0.6024258",
"0.6017076",
"0.6016118",
"0.6003834",
"0.59990084",
"0.5993068",
"0.598231",
"0.59817725",
"0.59785104",
"0.59694135",
"0.59605527",
"0.5957238",
"0.5953056",
"0.59450346",
"0.5944203",
"0.5943193",
"0.5933614",
"0.59270024",
"0.59128004",
"0.5911129",
"0.5908231",
"0.59021664",
"0.5894119",
"0.5885052",
"0.5882026",
"0.5881592",
"0.5868445",
"0.5862252",
"0.58309126",
"0.5828483",
"0.5806986",
"0.5805586",
"0.5797181",
"0.57932055",
"0.5777705",
"0.577642",
"0.5768358",
"0.57640666",
"0.5758628",
"0.5747379",
"0.5737509",
"0.57281804",
"0.572308",
"0.5718437",
"0.5708765",
"0.57079816"
] | 0.0 | -1 |
a single dash before and after each odd digit. There is one exception: don't start or end the string with a dash. You may wish to use the `%` modulo operation; you can see if a number is even if it has zero remainder when divided by two. Difficulty: medium. | def dasherize_number(num)
str = ""
arr = num.to_s.split('')
i = 0
while i<arr.count
if is_odd?(arr[i].to_f)
if i>0 && !(str[-1]=='-')
str += '-'
end
str += arr[i]
if i<arr.count-1
str += '-'
end
else
str += arr[i]
end
i+=1
end
return str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dasherize_number(num)\n\n index = 0\n \n num_string = num.to_s\n new_string = ''\n \n while index < num_string.length\n # Simplify your checks for odd and evenness here. \n # You are checking for so many things which makes the code messy.\n # Just divide the number using modulo you don't need to check for index\n \n if num_string[index].to_i.even? \n new_string += num_string[index].to_s \n elsif num_string[index].to_i.odd? \n new_string = \"-\" + num_string[index].to_s + \"-\"\n end\n \n index = index + 1\n end\n puts new_string\nend",
"def dasherize_number(num)\n\tnum_string = num.to_s\n\tidx = 0\n\n\twhile idx < num_string.length-1\n\t\tif num_string[idx].to_i % 2 != 0\n\t\t\tnum_string.insert(idx+1, \"-\")\n\t\tend\n\t\tidx += 1\n\tend\n\n\twhile num_string[idx] != \"-\"\n\t\tif num_string[idx2].to_i % 2 == 0 && num_string[idx2+1] != \"-\"\n\t\t\tputs \"#{num_string[idx2]} qualifies\"\n\t\tend\n\t\tidx2 += 1\n\tend\n\treturn num_string\nend",
"def dasherize_number(num)\n i=1\n num = num.to_s\n new_str = num[0]\n\n while (i>0 && i<num.length)\n if (num[i].to_i%2==1 || num[i-1].to_i%2==1)\n new_str = new_str + \"-\" + num[i].to_s\n else\n new_str = new_str + num[i].to_s\n end\n i+=1\n end\n return new_str\nend",
"def dasherizer(integer)\n array = integer.to_s.chars.map(&:to_i)\n new_string = \"\"\n size = array.size - 1\n\n array.each_with_index do |int, index|\n if index == size\n new_string << int.to_s\n elsif int.odd? && array[index + 1].odd?\n new_string << int.to_s + \"-\"\n else\n new_string << int.to_s\n end\n end\n\n new_string\nend",
"def dasherize_number(num)\n num = num.to_s\n result = ''\n\n idx = 0\n while idx < num.length\n # No dash to be added: all even digits\n if num[idx].to_i % 2 == 0\n result += num[idx]\n \n # Is first\n elsif idx == 0\n result += num[idx] + '-'\n\n # Is last\n elsif idx == num.length-1\n result += '-' unless result[-1] == '-'\n result += num[idx] \n \n # All others\n else\n result += '-' unless result[-1] == '-'\n result += num[idx] \n result += '-'\n end \n\n #puts result #debug\n idx += 1\n end\n\n #puts result #debug\n return result\nend",
"def dasherize_number(num)\n arr = num.to_s.split(\"\")\n idx = 0\n while idx < arr.length\n if arr[idx].to_i % 2 == 0\n idx += 1\n elsif idx == 0 && arr[idx].to_i % 2 != 0\n arr[idx] = \"#{arr[idx]}-\"\n elsif arr[idx].to_i % 2 != 0 && arr[idx - 1].length > 1\n arr[idx] = \"#{arr[idx]}-\"\n else\n arr[idx] = \"-#{arr[idx]}-\"\n end\n idx += 1\n end\n return final = arr.join(\"\").split(\"\")\n if final[-1] == \"-\"\n final.pop\n end\n return final.join(\"\")\nend",
"def dasherize_number(num)\n\n arr = num.to_s.split(\"\")\n arr.each do |x|\n if x[0].to_i.odd?\n puts x[0] + \"-\"\n end\nend\n\n # if arr[0].to_i.odd?\n # puts arr[0] + \"-\"\n # elsif arr[arr.length-1].to_i.odd?\n # puts \"-\" + arr[arr.length-1]\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[arr.length-1]\n # # puts \"-\" + x\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[0]\n # # puts x + \"-\"\n # # else\n # # return nil\n # # end\n # end\n # end\nend",
"def dasherize_number(num)\n\tstr_num = num.to_s\n\tnew_str = \"\"\n\ti = 0\n\twhile i < str_num.length\n\t\tif (str_num[i].to_i % 2 == 1) || (str_num[i - 1].to_i % 2 == 1)\n\t\t\tnew_str += '-'\n\t\tend\n\t\tnew_str += str_num[i]\n\t\ti += 1\n\tend\n\n\tif(new_str[0] =='-')\n\t\tnew_str[0] = ''\n\tend\n\t\n\t#if(new_str[(new_str.length - 1)] == '-')\n\t#\tnew_str[(new_str.length - 1)] = ''\n\t#end\n\t\n\tputs new_str\n\tnew_str\nend",
"def dasherize_number(num)\n number_string = num.to_s\n i = 0\n result = []\n while i < number_string.length\n if number_string[i].to_i % 2 == 1 && number_string[i + 1].to_i % 2 == 1\n letter = \"-\" + number_string[i]\n else\n leter = number_string[i]\n end\n result.push(letter)\n i += 1\n end\n result.join(\"\")\nend",
"def dasherize_number(num)\n i = 1\n answer = [num[0]]\n while i < num.to_s.length\n if num[i].to_i % 2 == 1 || num[i-1].to_i % 2 == 1\n answer << \"-\"\n end\n answer << num\n i += 1\n end\n return answer.join(\"\")\nend",
"def dasherize_number(num)\n \n idx = 0\n string = num.to_s.split(\"\")\n arr = \"\"\n \n while idx < string.length\n \n if string[idx].to_i % 2 != 0 \n string[idx] = \"-\" , \"#{string[idx]}\" , \"-\"\n end\n \n idx += 1\n \n end\n\t\n arr = string.join.to_s\n\tarr.split(\"\")\n\t\n\tif arr[-1] == \"-\"\n\t\tarr[-1] = \"\"\n\tend\n\t\n\tif arr[0] == \"-\"\n\t\tarr[0] = \"\"\n\tend\n\t\n\tarr.gsub! \"--\", \"-\"\n\treturn arr\n \nend",
"def insert_dash(num)\n string_split = num.to_s.split(\"\")\n \n string_split.each_with_index do |num, i|\n if string_split[i].to_i.odd? == true && string_split[i+1].to_i.odd? == true\n string_split.insert(i+1, \"-\")\n i+=2\n end \n end\n return string_split.join\n \nend",
"def DashInsert(str)\n \n i = 0\n while i < str.length - 1\n if str[i].to_i % 2 != 0 && str[i+1].to_i % 2 != 0 && str[i].to_i != 0 \n \t str[i] = str[i] + \"-\"\n end\n i += 1\n end\n \n str\n \nend",
"def dasherize_number(num)\n #split number into an array\n array = num.to_s.chars.map(&:to_i)\n i = 0\n #iterate over array to find odd numbers\n while i < array.length\n if !(array[i] % 2 == 0)\n #if it is the first number, only put a dash on the right side\n if i == 0\n array[0] = [array[i], \"-\"].join\n puts \"first number: #{array[0]}\"\n #if it is the last number, only put a dash on the left side\n elsif i == array.length-1\n array[array.length-1] = [\"-\", array[array.length-1]].join\n puts \"last number: #{array[array.length-1]}\"\n #else put a dash on both sides\n else\n if (i-1 == 0 && i+1 == array.length-1)\n array[i] = array[i]\n elsif i-1 == 0\n array[i] = [array[i], \"-\"].join\n elsif i+1 == array.length-1\n array[i] = [\"-\", array[i]].join\n else\n array[i] = [\"-\", array[i], \"-\"].join\n end \n end \n end \n i += 1\n end \n #return dashedString\n array = array.join\n puts array\n return array\nend",
"def dasherize_number(num)\n#my counter variable\n i = 1\n# Convert numbers to a string \n number_string = num.to_s\n# Create result variable to add in the numbers after they've been 'dashed'\n result= \"#{number_string[0]}\"\n\n while i < number_string.length\n #need to convert number_string to variables because \"1\" != 1\n current_num = number_string[i].to_i\n # if there isnt a remainder after i divide by two add current_num to result \n if(current_num % 2 == 0) \n result += \"#{current_num.to_s}\"\n #if there is a remainder after i divide by 2 add current_num to result with a dash in front of current_num\n elsif (current_num % 2 == 1) \n result += \"-#{current_num.to_s}\"\n end\n i += 1\n end\n puts result\n return result\nend",
"def dasherize_number(num)\n num = num.to_s\n new = []\n \n if num[0].to_i % 2 == 1\n new.push(num[0])\n new.push('-')\n else\n new.push(num[0])\n end\n \n i = 1\n while i < num.size - 1\n if num[i].to_i% 2 == 1\n if (new[new.length-1] != '-')\n new.push(\"-\")\n end\n new.push(num[i])\n new.push(\"-\")\n else \n new.push(num[i])\n end\n i += 1\n end\n if num[num.size-1].to_i % 2 ==1 && new[new.length-1] != '-'\n new.push('-')\n end\n new.push(num[num.length-1])\n print new.join\n return new.join\n \nend",
"def dashing_odds(num)\n\n # convert integer to string\n int_to_string = num.to_s()\n\n\n # checking the type of int_string\n #\n #\n\n # p num.instance_of? Integer # Fixnum is deprecated and replaced by Integer\n # p int_to_string.instance_of? String\n #\n # puts int_to_string.respond_to?(:to_s)\n\n # all 3 prints true !\n #\n # end of checking type of int_string\n # https://stackoverflow.com/questions/15769739/determining-type-of-an-object-in-ruby\n\n\n i = 0\n\n dashified = \"\"\n\n # treat string as an array\n while( int_to_string.length() > i )\n\n # p \"int_to_string[i].to_i #{int_to_string[i].to_i} % 2 = #{int_to_string[i].to_i % 2}\"\n\n # checks if number is odd\n if( int_to_string[i].to_i % 2 == 0 )\n\n if( int_to_string[i-1].to_i % 2 == 1 )\n\n dashified += \"-\"\n end\n\n dashified += int_to_string[i]\n\n\n else\n\n dashified += \"-\"\n dashified += int_to_string[i]\n # dashified += \"-\"\n\n end # if\n\n i += 1\n end # while\n\n # p dashified\n\n # remove leading dashes\n # treating string as array\n # p \"dashified[0] #{dashified[0]}\"\n\n if( dashified[0] == \"-\" )\n\n dashified = dashified.slice( 1, dashified.length() )\n\n end # if\n\n # remove trailing dashes\n # treating string as array\n\n # p dashified\n\n # p \"dashified[ dashified.length() - 1 ] #{dashified[ dashified.length() - 1 ]}\"\n\n if( dashified[ dashified.length() - 1 ] == \"-\" )\n\n dashified = dashified.slice( 0, dashified.length() - 1 )\n\n end # if\n\n p dashified\n\n\n # IMPROVEMENT !!!! \n #\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n # maybe best to have own method !\n\n # End of:\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n\n p dashified\n return dashified\n\nend",
"def dasherize_number(num)\n number = num.to_s\n dashed = \"\"\n\n dashed = number[0]\n if number[0].to_i % 2 == 1\n dashed += \"-\"\n end\n\n number[1..-1].each_char do |n|\n\n if n.to_i % 2 == 1\n if dashed[-1] != \"-\"\n dashed = dashed + \"-\" + n + \"-\"\n else\n dashed += n\n end\n else\n dashed += n\n end\n end\n\n if dashed[-1] == \"-\"\n return dashed[0...-1]\n end\n\n dashed\nend",
"def dasherize_num(num)\n\n num_s = num.to_s\n\n result = \"\"\n\n i = 0\n\n while num_s.length > i\n\n digit = num_s[i].to_i\n\n if (i > 0) # only if the it's not the leading digit\n\n prev_digit = num_s[i - 1].to_i\n\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n\n end\n\n end\n\n result += num_s[i]\n\n i += 1\n end\n\n return result\nend",
"def dash_insert_ii(str)\n result = ''\n str.each_char.with_index do |char, idx|\n result << char\n next if char == '0' || idx >= str.size - 1 || str[idx + 1] == '0'\n if char.to_i.even? && str[idx + 1].to_i.even?\n result << '*'\n elsif char.to_i.odd? && str[idx + 1].to_i.odd?\n result << '-'\n end\n end\n result\nend",
"def dasherize_number(num)\n num_s = num.to_s\n\n result = \"\"\n\n idx = 0\n while idx < num_s.length\n digit = num_s[idx].to_i\n\n if (idx > 0)\n prev_digit = num_s[idx - 1].to_i\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n end\n end\n result += num_s[idx]\n\n idx += 1\n end\n\n return result\nend",
"def dasherize_number(num)\r\n nums = num.to_s.split('') #turns argument into a string and splits it into an array of single numbers. NOTE: '2' != 2\r\n nums.map! do |i| #Loop through nums .map! so you can change the orginal array\r\n if i.to_i.odd? == true # convert each iteration from string to integer, if its odd...\r\n i = \"-\"+ i # add a \"-\" before the number\r\n end\r\n i.to_s #leave it alone if its not odd and convert it back a string\r\n end#^^^\r\n\r\n if nums[0].to_i.odd? #this is to compensate for odd numbers at the beginning. \r\n nums[0].reverse! #example: [\"-3\",\"0\", \"-3\"] >> [\"3-\",\"0\", \"-3\"] \r\n end\r\n\r\nnums = nums.join('').split('') #converts [\"-3\",\"0\", \"-3\"] >> [\"3\", \"-\", \"0\", \"-\", \"3\"].\r\nnums.map! do |k| #loop through nums\r\n index = nums.index(k) #set index\r\n if nums[index] == \"-\" && nums[index+1] == \"-\" # checks to see if a dash is next to a dash\r\n nums.delete_at(index) #if so, delete it\r\n end\r\n k = k # otherwise leave k alone\r\n end\r\nreturn nums.join('') #return as a single string\r\nend",
"def DashInsert(str)\n str = str.split(\"\")\n odd = \"13579\"\n i = 0\n new = \"\"\n\n while i < str.length\n new += str[i]\n if odd.index(str[i]) && str[i+1] && odd.index(str[i + 1])\n new += \"-\"\n end\ni+= 1\n end\n # code goes here\n return new\n\nend",
"def dasherize_number(num)\n\tanswer = ''\n\tnum.to_s.each_char do |x|\n\t\tif x.to_i.odd? \n\t\t\tif answer.match(/-$/)\n\t\t\t\tanswer += x + '-' \n\t\t\telse\n\t\t\t\tanswer += '-' + x + '-'\n\t\t\tend\n\t\telse\n\t\t\tanswer += x\n\t\tend\n\n\tend\n\tanswer.reverse.chomp('-').reverse.chomp('-')\nend",
"def dasherize_number(num)\n\t num_s = num.to_s\n\t\n\tresult = \"\"\n\t\n\ti = 0\n\twhile i < num_s.length\n\tdigit = num_s[i].to_i\n\t\n\tif (i > 0)\n\tprev_digit = num_s[i - 1].to_i\n\tif (prev_digit % 2 == 1) || (digit % 2 == 1)\n\tresult += \"-\"\n\tend\n\tend\n\tresult += num_s[i]\n\t\n\ti += 1\n\tend\n\t\n\treturn result\nend",
"def dasherize_number(num)\n result = String.new \n \n while num > 0 do\n digit = num % 10\n if digit % 2 != 0\n result = \"-\" + digit.to_s + \"-\" + result\n else\n result = digit.to_s + result\n end\n num = num / 10\n end\n # puts result\n result = result.gsub(\"--\", \"-\")\n# puts result\n \n \n \n if result[0] == \"-\" || result[len-1] == \"-\"\n len = result.length\n if result[0] == \"-\" \n result = result[1..len-1]\n end\n len = result.length\n if result[len-1] == \"-\"\n result = result[0..len-2]\n end\n end\n # puts result\n return result \nend",
"def DashInsert(num)\n\n # step1: convert the integer to a string\n # step2: determine whether a number is odd or not and grab index \n # step3: insert a dash after it \n\n num.scan(/[13597]{2}|.+/).join(\"-\")\n # num_arr = num.to_s\n # num_arr.each_char do |n|\n # \tif n % 3 = 0 \n # \t\tstr.insert(i+1, '-')\n # \tend\n # end\n # code goes here \n \nend",
"def dasherize_number(num)\n\nnumx = num.to_s\nlength = numx.length\n\nidx = 0\n\nif numx[1] == nil\n\treturn numx[0]\nend\n\n\nwhile idx < length\nstring = ''\n\tif numx[idx] == 0\n\t\tstring = string + 0\n\t\tidx += 1\n\telsif num[idx] == nil\n\t\treturn string\t\n\telsif (numx[0] % 2) == 0\n\t\tstring = string + numx[0]\n\t\tidx += 1\n\telsif (numx[0] % 2 != 0)\n\t\tstring = string + numx[0] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + '-' + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = string + '-' + numx[idx]\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = '-' + numx[idx] + '-'\n\t\tidx += 1\n\telse\n\t\tstring = string + numx[idx]\n\t\tidx += 1\n\tend\t\nend\n\nreturn string\n\nend",
"def dasherize_number(num)\n\tnum_arr = []\n\toutput_arr = []\n\tevens = ''\n\twhile num > 0\n\t\tnum_arr.unshift(num % 10)\n\t\tnum /= 10\n\tend\n\ti = 0\n\twhile i < num_arr.size\n\t\tif num_arr[i] % 2 != 0\n\t\t\toutput_arr.push(evens) if evens != ''\n\t\t\tevens = ''\n\t\t\toutput_arr.push(num_arr[i].to_s)\n\t\telse\n\t\t\tevens += num_arr[i].to_s\n\t\tend\n\t\ti += 1\n\tend\n\toutput_arr.join('-')\n\nend",
"def DashInsert(str)\n str.chars\n .each_cons(2)\n .map { |i,j| (i.to_i.odd? && j.to_i.odd?) ? i+'-' : i }\n .join + str[-1]\nend",
"def dashatize(n)\n n ? n.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def dashatize(num)\n return 'nil' if num == nil\n str = num.to_s.each_char.map do |char|\n char.to_i.odd? ? char = \"-#{char}-\" : char\n end\n\n str = str.join.squeeze('-')\n str.slice!(0,1) if str[0] == '-'\n str.slice!(-1,1) if str[-1] == '-'\n str\nend",
"def dashatize(num)\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def dasherize_number(num)\n arr = num.to_s.chars\n arr.each { |char| char.gsub!(char, \"-#{char}-\") if char.to_i.odd? }\n string = arr.join\n string.chop! if string[-1] == '-'\n string[0] = '' if string[0] == '-'\n string.squeeze('-')\nend",
"def dashatize(num)\n return \"nil\" if num.nil?\n s = ''\n num = num.abs\n num.digits.reverse.each_with_index do |digit,index|\n if digit.odd?\n s += \"-#{digit}-\"\n else\n s += \"#{digit}\"\n end\n end\n s = s.gsub(\"--\",\"-\")\n if s[0] == \"-\"\n s = s.reverse.chop.reverse\n end\n if s[-1] == \"-\"\n s.chop!\n end\n return s\nend",
"def dasherize(str)\n (str.length > 1 ? \"--\" : \"-\") + str\n end",
"def insert_dash(num)\n num.to_s.gsub(/(?<=[13579])([13579])/, '-\\1')\nend",
"def DashInsertII(num)\n\n # code goes here\n str = num.to_s.chars.to_a\n str.each_index do |i|\n next if i == 0\n if str[i] && str[i-1] =~ /\\d+/\n if str[i-1].to_i.even? && str[i].to_i.even?\n str.insert(i,'*')\n elsif str[i-1].to_i.odd? && str[i].to_i.odd?\n str.insert(i,'-')\n end\n end\n end\n return str.join\n \nend",
"def DashInsert(num)\n\n num.to_s.gsub(/[13579]{2,}/){|x| x.split('').join(\"-\")}\n \nend",
"def dashatize(num)\n # scan(pattern) -> [String] | [[String]]\n # self に対して pattern を繰り返しマッチし、 マッチした部分文字列の配列を返します。\n # pattern が正規表現で括弧を含む場合は、 括弧で括られたパターンにマッチした部分文字列の配列の配列を返します。\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def seperation\n puts \"-\" * 10\n end",
"def fix_dash_dash(text); end",
"def DashInsert(str)\n str.to_s.gsub(/([13579])(?=[13579])/, '\\1-')\nend",
"def num_to_dashes(num)\n\treturn '-'*num\nend",
"def dasherize(word)\n word.gsub(/_/,'-')\nend",
"def stringy_hightech(num, zero_start=1)\n half, remainder = num.divmod 2\n\n case zero_start\n when 0 then '01' * half + '0' * remainder\n when 1 then '10' * half + '1' * remainder\n end\nend",
"def _n(str)\n str.gsub(/(-)(.*)/, '\\2')\n end",
"def divider(char=\"-\")\n char * 80\nend",
"def odd(str)\n result = ''\n is_odd_idx = false\n space_just_added = false\n last_letter_idx = nil\n last_space_idx = nil\n str.each_char do |char|\n if char == ' '\n next if space_just_added\n result << ' '\n space_just_added = true\n last_space_idx = result.size\n is_odd_idx = !is_odd_idx\n elsif char.match?(/[a-z]/i)\n is_odd_idx ? result.insert(last_space_idx, char) : result << char\n last_letter_idx = result.size - 1\n raise ArgumentError if last_letter_idx - last_space_idx.to_i >= 20\n space_just_added = false\n elsif char == '.'\n break\n else\n raise ArgumentError, 'invalid input'\n end\n end\n last_letter_idx ? result[0..last_letter_idx] + '.' : result\nend",
"def odds_and_evens(string, return_odds)\n newstring = \"\"\n n = 1 if return_odds\n n = 0 if !return_odds\n # n = return_odds ? 1 : 0\n\n for index in 0..(string.length-1)\n if index % 2 == n\n newstring = newstring + string[index]\n end\n end\n return newstring\nend",
"def odds_and_evens(string, return_odds)\nif return_odds == false\n return string.gsub(/(.)./, '\\1')\n\nelse return_odds == true\n if string.length.odd?\n return string.gsub(/.(.)/, '\\1')[0...-1]\n else \n return string.gsub(/.(.)/, '\\1')\n end\nend\nend",
"def odds_and_evens(string, return_odds)\n new_string = ''\n\n if return_odds\n string.length.times {|num| new_string << string[num] if num.odd?}\n\n elsif\n string.length.times {|num| new_string << string[num] if num.even?}\n\n end\n\n new_string\n\nend",
"def odds_and_evens(string, return_odds)\n return_odds ? odd_string = '' : even_string = ''\n if return_odds\n string.chars.each_with_index {|char, index| odd_string += char if index.odd?}\n odd_string\n\t else\n\t\t string.chars.each_with_index {|char, index| even_string += char if index.even?}\n even_string\n\t end\n\nend",
"def reverse_odds(string)\n result = arr = string.chars\n arr.each_with_index do |letter, i|\n if i.odd?\n result[i] = arr[- 1 - i]\n result[-1 - i] = letter\n else\n letter\n end\n return result.join('') if i >= (arr.length / 2)\n end\nend",
"def dasherize\n\t\treturn self.split.join('-')\n\tend",
"def stringy(int)\n (int/2).times { print 10 }\n 1 if int.odd?\nend",
"def to_dash(s)\n s.gsub(/\\.|\\_/, '--')\n end",
"def odds_and_evens(string, return_odds)\n stringy = \"\"\n string.chars.each_with_index do |char, i|\n stringy += char if i.odd? == return_odds\n end\n stringy\nend",
"def as(besar)\n\tbesar = besar.to_i\n\tstr = \"\"\n\tcount = 1\n\t# besar.odd? ? mid = besar + 1 : mid = besar\n\tbesar.odd? ? mid = besar - 1 : mid = besar\n\tx = (mid/2).ceil + 1\n\n\tfor i in 1..mid do\n \n\t\tfor j in i...mid do\n\t\t\tstr += \"-\"\n\t\tend\n\n\t\tif i != x\n\t\t\tfor j in 1..count do\n\t\t\t j > 1 && j < count ?\tstr += \"-\" : str += \"A\"\n\t\t\tend\n\t\telse\n\t\t\tfor j in 1..count\n\t\t\t\tj.odd? ? str += \"A\" : str += \"-\"\n\t\t\tend\n\t\tend\n\n\t\tstr += \"\\n\"\n\t\tcount += 2\n\tend\n\n\tprint str\nend",
"def alternate string, num\n range = ('a'..'z').to_a.rotate(num)\n working = string.split(//)\n working.map! do |x|\n x = range[('a'..'z').to_a.index(x)]\n end.join\n \n \n\nend",
"def evenator(s)\n s.delete(\".,?!_\").split(\" \").map do |word|\n word.length % 2 == 1? word << word[-1] : word\n end.join(\" \")\nend",
"def even_or_odd(number)\n if number % 2 == 0\n \"Even\"\n else\n \"Odd\"\n end\n end",
"def stringy(int)\n new_string = \"\"\n (int / 2).times { new_string << \"10\" }\n new_string << \"1\" if int.odd? \n new_string\nend",
"def oddness(count)\n count.odd? ? \"odd\" : \"even\"\n end",
"def all_digits_odd?\n self.to_s.split('').inject(0) { |memo, s| memo + ( s.to_i%2==0 ? 1 : 0 ) } == 0\n end",
"def odds_and_evens(string, return_odds)\n\nindex = 1\n\n (string.length/2).times do\n string.slice(index)\n index += 1\n string\n end\n\n\n#return string.chars.select.each_with_index{|x, y| y.odd?}.join if return_odds == true\n#return string.chars.select.each_with_index{|x, y| y.even?}.join if return_odds == false\n\nend",
"def dashify\n strip.gsub(/[ \\/_~]/, '-').squeeze('-')\n end",
"def add_dashes(uuid)\n return uuid if uuid =~ /\\-/\n [uuid[0..7], uuid[8..11], uuid[12..15], uuid[16..19], uuid[20..-1]].join(\"-\")\n end",
"def stringy(num, start=1)\n string = '10' * (num/2)\n if start == 1\n num.even? ? string : string + '1'\n else\n num.even? ? string.reverse : string.reverse + '0'\n end\nend",
"def twice(num)\n number = num.to_s\n length = number.length\n\n case\n when length.odd?\n return num * 2\n when length.even?\n left = number.slice(0, number.length / 2)\n right = number.slice((number.length / 2)..-1)\n left == right ? num : num * 2\n end\nend",
"def dash_separator\n 60.times { @results += '-' }\n newline\n end",
"def undasherize(str)\n str.sub(/^-{1,2}/, '')\n end",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '': string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '' : string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def odds_and_evens(string, return_odds)\n chars = string.chars\n for i in 0..(chars.length-1)\n (chars[i] = '') if (return_odds ? i.even? : i.odd?)\n end\n chars.join\nend",
"def stringy(number)\n digits = []\n counter = 0\n while counter < number do\n digits[counter] = counter.odd? ? 0 : 1\n counter += 1\n end\n digits.join\nend",
"def staircase(n)\r\n # Write your code here\r\n empty = \" \"\r\n value = \"#\"\r\n n.times do |num|\r\n \tnumber = num + 1\r\n first = empty*(n-number).abs\r\n second = value*number\r\n puts first+second\r\n end\r\nend",
"def is_odd?\n return TRUE if get_dash_version.match(/^\\d+\\.(\\d+)\\.\\d+/)[1].to_i.odd?\n return FALSE\n end",
"def stringy(int)\n str = ''\n int.times { |i| str += ((i + 1) % 2).to_s }\n str\nend",
"def odds_and_evens(string, return_odds)\n range = 0..string.length-1\n new_string = String.new\n range.step(2) {|x| string[x+1] && new_string << string[x+1]} if return_odds\n range.step(2) {|x| new_string << string[x]} if !return_odds\n new_string\nend",
"def odd_or_even (number)\n if number % 2 == 0\n \"even\"\n elsif number % 2 == 1\n \"odd\"\n end\nend",
"def hide_last_four(string)\n string.gsub!(/-\\d{4}/,\"-****\")\nend",
"def dasherize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"-\").downcase)\n end",
"def is_odd?(integer)\r\n !(integer.abs.remainder(2) == 0)\r\nend",
"def oddify(string)\n words = string.split(/[ .]+/)\n\n words.map.with_index do |word, idx|\n idx.odd? ? word.reverse : word\n end.join(' ') << '.'\nend",
"def odds_and_evens(string, return_odds)\n\n even = []\n odd = []\n arr = string.each_char.to_a\n arr.each_index{|index| index % 2 == 0 ? even << arr[index] : odd << arr[index]}\n if return_odds == true\n return odd.join('')\n else\n return even.join('')\n end\n\n\n\n\nend",
"def show_game_title(title)\n formatted_title = '| ' + title + ' |'\n dashes = '-' * formatted_title.length\n puts dashes\n puts formatted_title\n puts dashes\nend",
"def show_game_title(title)\n formatted_title = '| ' + title + ' |'\n dashes = '-' * formatted_title.length\n puts dashes\n puts formatted_title\n puts dashes\nend",
"def all_digits_odd?(number)\n number.to_s.split(//).each_with_index do |digit,index|\n if index == 0 && digit.to_i == 2\n #Don't return false if first digit is 2\n elsif digit.to_i%2==0\n return false\n end\n end\n return true\nend",
"def twice(number)\n num_length = number.to_s.length\n num_is_odd = (num_length % 2 == 0) ? false : true \n return (number * 2) if num_is_odd\n \n first_half = number.to_s.slice(0, num_length / 2)\n second_half = number.to_s.slice(num_length / 2, num_length)\n first_half == second_half ? number : number * 2\nend",
"def odds_and_evens(string, return_odds)\n result = \"\"\n string.length.times do |index|\n next if\n return_odds == true && index.even?\n next if\n return_odds == false && index.odd?\n result << string[index]\n end\nresult\nend",
"def hideWord (word)\n\tnumDashes = word.length\n\tdisplayDash = Array.new(numDashes) { |i| \n\ti = \"_\" }\n\n\treturn displayDash.join(\" \")\nend",
"def is_odd?(integer)\n integer.abs.remainder\nend",
"def staircase(n)\n i = 1\n while i <= n\n puts \" \" * (n - i) + \"#\" * i\n i += 1 \n end\nend",
"def odds_and_evens(string, return_odds)\n odds = \"\"\n evens = \"\"\n string.each_char.with_index { |char, i|\n if i.odd?\n odds << char\n else\n evens << char\n end }\n if return_odds == true\n return odds\n else\n return evens\n end\nend",
"def stringy(num)\n string = '10' * (num/2)\n num.even? ? string : string + '1'\nend",
"def hide_last_four(string)\n\treturn string.gsub(/(\\d{2})-(\\d{2})-\\d{4}/, '\\1-\\2-****')\nend",
"def odd_number_check_two(number)\r\n number % 2 == 1 || number % 2 == -1 \r\nend",
"def two_digit(number)\n dizaine = (number/10) * 10\n unit = (number % 10)\n if unit == 0\n return specific_word(dizaine)\n else\n return specific_word(dizaine) + \" \" + specific_word(unit)\n end\nend",
"def croon(str)\n str.split('').join('-')\nend"
] | [
"0.8318996",
"0.7968655",
"0.79432404",
"0.7927553",
"0.79227006",
"0.7920647",
"0.7899584",
"0.77757",
"0.7765964",
"0.7704206",
"0.77036357",
"0.76868725",
"0.7661751",
"0.76534855",
"0.7652473",
"0.7633463",
"0.7631875",
"0.7612631",
"0.7606616",
"0.7600646",
"0.7583064",
"0.756611",
"0.75653327",
"0.74805915",
"0.747643",
"0.74665844",
"0.74454904",
"0.74432474",
"0.74100095",
"0.73733664",
"0.72559667",
"0.72403663",
"0.71688443",
"0.7075159",
"0.70394534",
"0.69987434",
"0.6965745",
"0.69231695",
"0.68870115",
"0.68259317",
"0.6756817",
"0.6588163",
"0.65674096",
"0.6529883",
"0.6477833",
"0.6476324",
"0.64539677",
"0.6421343",
"0.63638306",
"0.6347846",
"0.6341708",
"0.63040364",
"0.62720937",
"0.6266184",
"0.62646914",
"0.6263388",
"0.6251602",
"0.6224617",
"0.62132573",
"0.6202843",
"0.61988163",
"0.6197292",
"0.6193731",
"0.618545",
"0.61813486",
"0.61763906",
"0.6169777",
"0.6150122",
"0.61479914",
"0.61417055",
"0.6136163",
"0.6117099",
"0.61124843",
"0.61117095",
"0.6109506",
"0.61066216",
"0.60974854",
"0.6077501",
"0.60641897",
"0.6054672",
"0.604757",
"0.6046363",
"0.60351455",
"0.60312366",
"0.6030134",
"0.60256433",
"0.602462",
"0.602462",
"0.60155517",
"0.60092306",
"0.60091317",
"0.6006652",
"0.599893",
"0.5995014",
"0.599346",
"0.5989285",
"0.5987672",
"0.5980625",
"0.5978889",
"0.5973459"
] | 0.78489393 | 7 |
Returns true if the user is logged in, false otherwise. | def logged_in?
!curr_worker_id.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n return false\n end\n end",
"def logged_in?\n if !session[:user_id].nil?\n return true\n else\n return false\n end\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def logged_in?\n return false unless session[:user_id]\n\n User.find_by_id(session[:user_id]).present?\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n (current_user ? login_access : false).is_a?(User)\n end",
"def logged_in?\n if current_user\n true\n else\n false\n end\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n current_user.present?\n end",
"def logged_in?\n return true if self.current_user\n return false\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\r\n current_user != :false\r\n end",
"def loggedin?\n @session.nil? ? false : (return true)\n end",
"def is_logged_in?\n\t\t!session[:user_id].nil?\n\tend",
"def logged_in?\n\t\t\tcurrent_user.is_a? User\n\t\tend",
"def logged_in?()\n if session[:user_id]\n return true\n else \n return false\n end\n end",
"def logged_in?\n current_user != :false \n end",
"def is_logged_in_user?\n session[:user_authenticated]\n end",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\n if current_user\n true\n else \n false\n end\n end",
"def is_logged_in?\n !session[:user_id].nil?\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def logged_in?\n\t\tif not current_user.present? then redirect_to \"/unauthorized\" and return false\n\t\tend\n\t\treturn true\n\tend",
"def logged_in?\n return false unless @auth_header\n true\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n\t\t !!current_user\n end",
"def logged_in?\r\n\t\t!current_user.nil?\r\n\tend",
"def logged_in?\n\n if session[:current_user_id]\n return true\n end\n \n #Default return false\n false\n \n end",
"def logged_in?\n\t\tcurrent_user.present?\n\tend",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !!logged_in_user \n end",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n current_user ? true : false;\n end",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n current_user.present? # True neu user login\n end",
"def logged_in?\n #boolean return\t\n \tcurrent_user != nil\n end",
"def is_user_logged_in?\n\tlogged_in = false\n\t if logged_in\n then true\n else\n redirect_to root_path\n end\n end",
"def logged_in?\n @logged_in ? true : false\n end",
"def logged_in?\n current_user != nil ? true : false\n end",
"def logged_in?\n return session['current_user']\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n\t\t!current_user.nil?\n \tend",
"def is_logged_in?\n return true if current_user || current_admin\n end",
"def logged_in?\n \t\t!current_user.nil?\n \tend",
"def logged_in?\n\t\t#if currentuser.nil returns true then logedin is false\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n !current_user.blank?\n end",
"def logged_in?\n !!session[:logged_in]\n end",
"def logged_in?\n # !! turns this into a boolean, so we DON'T get nil\n !!session[:user_id]\n end",
"def logged_in?\n !!session[:user_id]\n # !!@current_user\n end",
"def logged_in?\n ## to query if the logged in, call the current_user with !! preceeded, this turns it to true or false\n # TRUE or FALSE\n !!current_user\n end",
"def _is_login\n p session[:user]\n session[:user] ? true : false\n end",
"def logged_in?\n if session[:username].blank? or\n session[:authenticated].blank? or\n !session[:authenticated]\n return false\n end\n\n return true\n end",
"def user_logged_in?\n current_user.present?\n end",
"def user_logged_in?\n current_user.present?\n end",
"def logged_in?\n current_user_id.to_i > 0\n end",
"def is_logged_in?\n session[:user_id].present?\n end",
"def logged_in?\n current_user.is_a? User\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end"
] | [
"0.9082417",
"0.8764097",
"0.87552106",
"0.8718715",
"0.86894006",
"0.86498255",
"0.86469626",
"0.86372185",
"0.8631328",
"0.86285406",
"0.86285406",
"0.8582609",
"0.85669243",
"0.85613596",
"0.85613596",
"0.8551865",
"0.85491496",
"0.85443276",
"0.85409296",
"0.8539988",
"0.8517927",
"0.8511279",
"0.8508452",
"0.8508452",
"0.8507709",
"0.8505226",
"0.84988797",
"0.8491304",
"0.8484085",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.8482917",
"0.84715056",
"0.8469552",
"0.84658724",
"0.8465275",
"0.84569186",
"0.84569186",
"0.84569186",
"0.84569186",
"0.84564346",
"0.8454783",
"0.8454261",
"0.8453559",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.84534836",
"0.8442786",
"0.8442786",
"0.8442786",
"0.8442786",
"0.84288824",
"0.84257317",
"0.84221077",
"0.8421079",
"0.84119624",
"0.8409261",
"0.840512",
"0.840512",
"0.8403647",
"0.8402856",
"0.8402169",
"0.83969295",
"0.83946496",
"0.8387275",
"0.8384129",
"0.83830756",
"0.83823043",
"0.83774966",
"0.83763194",
"0.8374361",
"0.8374361",
"0.83696514",
"0.8369602",
"0.836562",
"0.8361304",
"0.8361304",
"0.8361304",
"0.8361304"
] | 0.0 | -1 |
Redirects to stored location (or to the default). | def redirect_back_or(default)
redirect_to(session[:forwarding_url] || default)
session.delete(:forwarding_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end",
"def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end",
"def redirect(options = {})\r\n end",
"def redirect_to_stored_or_default(default)\n if session['return-to'].nil?\n redirect_to default\n else\n redirect_to_url session['return-to']\n session['return-to'] = nil\n end\nend",
"def redirect_back_or_default(default)\n redirect_to(location_stored? ? session[:return_to] : default)\n session[:return_to] = nil\n end",
"def redirect(location, status = '302'); request.redirect(location, status); end",
"def store_location\n session[:redirect] = request.url\n end",
"def restore_location_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end",
"def redirect?; end",
"def store_location!\n session[\"return_to\"] = request.env[\"warden.options\"][:attempted_path] if request.get?\n end",
"def store_location\n session[:redirect_path] = request.path\n end",
"def redirect_to_target(default=nil)\n \n goto_url=params[:return_to] || session[:return_to] || default || \"/\"\n \n session[:return_to] = nil\n redirect_to(goto_url)\n end",
"def redirect\n redirect_to @goto_url\n end",
"def store_and_redirect_location\n #session[:return_to] = \"/\"\n redirect_to \"/welcome/new\",:status => 401\n end",
"def redirect_back_or_default(default)\n redirect_to url_for_redirect(default)\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url) # Delete the stored URL for next log in\n end",
"def redirect(path)\n throw :redirect, path\n end",
"def store_location(url = url_for(:controller => controller_name, :action => action_name))\n # It's possible to create a redirection attack with a redirect to data: protocol... and possibly others, so:\n # Whitelisting redirection to our own site and relative paths.\n url = nil unless url =~ /\\A([%2F\\/]|#{root_url})/\n session[:return_to] = url\n end",
"def redirect(url); end",
"def store_redirect\n if params.key?(:redirect)\n store_redirect_url_for(params[:redirect], request.referer)\n end\n end",
"def redirect_back_or_default(default)\n loc = session[:return_to] || default\n session[:return_to] = nil\n redirect loc\n end",
"def redirect_path(name, default = nil)\n stored_redirect_path(name) || default || root_path\n end",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t\tend",
"def store_location!\n session[:\"#{scope}_return_to\"] = attempted_path if request.get? && !http_auth?\n end",
"def redirect_to_path(path)\n redirect_to path\n end",
"def redirect_back_or_to(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or_default(default)\n redirect_to(default)\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n # The following deletion happens even though the redirect stastement is written first.\n # This is because the redirect doesn't actually happen until an explicit\n # return statement or until the end of a method.\n session.delete(:forwarding_url)\n end",
"def redirect_back_or(default)\n\n\t\t# redirects user to page stored in session symbol or the\n\t\t# dafault location if return_ to is not set.\n\t\tredirect_to(session[:return_to] || default)\n\n\t\t# Deletes the session symbol return_to\n\t\tsession.delete(:return_to)\n\tend",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n # Delete after the redirect so that the user will not be forwarded to the\n # same URL upon each login attempt.\n # Redirects always wait for the rest of the code block to return before\n # actually redirecting.\n end",
"def redirect_to(args={})\n # use an url if specified\n @redirect = args[:url] if args[:url]\n # or build up an action if specified\n @redirect = File.join(\"/#{@workingpath[1..-1].join('/')}\",args[:action].to_s) if args[:action]\n logmsg \"base_controller::redirect_to() setting redirect to #{@redirect}\" if @@debug\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url) #delete what is stored.\n end",
"def store_location\n\t\tsession[:return_to] = request.url\n\tend",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n\n\t\t# Stores the requested page in a session symbol return_to\n\t\tsession[:return_to] = request.url\n\tend",
"def redirect_back_or(default)\n #send back to what was stored in\n #\"session[:return_to] or default location\n redirect_to(session[:return_to] || default)\n #deletes saved return location\n session.delete(:return_to)\n end",
"def redirect_back_or( default )\n\t\tredirect_to( session[:forwarding_url] || default )\n\t\tsession.delete( :forwarding_url )\n\tend",
"def set_redirect_location\n @redirect_location = @shareable\n end",
"def redirects; end",
"def store_location\n session[:redirect_after_login] = request.request_uri\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_to(path)\n render(:status => 302, \"Location\" => path) { p { text(\"You are redirected to \"); a(path, :href => path) } }\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def store_location\n\t\tsession[ :forwarding_url ] = request.original_url if request.get?\n\tend",
"def redirect_back(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default )\n session.delete(:forwarding_url)\n end",
"def redirect_back(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete :forwarding_url\n end",
"def redirect_back_or(default)\n redirect_to session[:forwarding_url] || default\n session.delete(:forwarding_url)\n end",
"def store_location\n store_location_for(:user, params[:redirect_to]) if params[:redirect_to].present?\n\n # note: don't store the previous url on each call. this led to an issue where\n # missing asset might get run through this code, causing the user to be redirected\n # to the missing asset during a login\n # session[:previous_url] = request.url if request.url != new_user_session_url\n end",
"def hubssolib_redirect_back_or_default(default)\n url = hubssolib_get_return_to\n hubssolib_set_return_to(nil)\n\n redirect_to(url || default)\n end",
"def redirect_to options = {}\n @has_redirect = options\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or_default(default=nil)\n default = self.default_route\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def redirect_back_or(default)\n # Redirects don’t happen until an explicit return or the end of the method, \n # so any code appearing after the redirect is still executed.\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or(default)\n redirect_url = session[:forwarding_url] || default\n session.delete :forwarding_url\n redirect_to redirect_url\n end",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def redirect_to_forwarding_url_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarding_url)\n end",
"def store_location\n session[:return_to] = request.original_url\n end",
"def redirect_back_or_default(default)\n redirect(session[:return_to] || default)\n session[:return_to] = nil\n end",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t end",
"def redirect_back_or(default)\n\t\tredirect_to(session[:return_to] || default)\n\t\tclear_return_to\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:return_to] || default)\n\t\tclear_return_to\n\tend",
"def redirect_back_or_default(default)\n loc = session[:return_to] || default\n session[:return_to] = nil\n redirect_to loc\n end",
"def redirect_back_or_default(default, options = {})\n target = url_to_store(session[:return_to])\n (target = logged_in? ? home_url(current_user) : nil) if target == '{home}'\n #target = nil if target == APP_CONFIG.hostname || target == APP_CONFIG.hostname + '/'\n target = default unless target\n target = safe_redirect(target)\n session[:return_to] = nil\n return target if options[:find_target_only]\n redirect_to(target)\n end",
"def redirect_back_or_default(default)\n\t\tredirect_to(session[:return_to] || default)\n\t\tsession[:return_to] = nil\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default )\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url]||default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def store_location\n \t\tsession[:forwarding_url] = request.original_url if request.get?\n \tend",
"def redirect_back_or_default(default)\n if session[:return_to].nil?\n redirect_to default\n else\n redirect_to session[:return_to]\n session[:return_to] = nil\n end\n end",
"def redirect_back_or_default(default)\n if session[:return_to].nil?\n redirect_to default\n else\n redirect_to session[:return_to]\n session[:return_to] = nil\n end\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default)\n session.delete(:forwarind_url)\n end",
"def set_redirect\n @redirect = params[:origin_url] == nil ? bookmarks_path : params[:origin_url]\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || default )\n session.delete(:forwarding_url)\n end",
"def redirect_back_or_default(default)\n session[:return_to] ? redirect_to(session[:return_to]) : redirect_to(default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n session[:return_to] ? redirect_to(session[:return_to]) : redirect_to(default)\n session[:return_to] = nil\n end",
"def redirect_back_or_default(default)\n session[:return_to] ? redirect_to(session[:return_to]) : redirect_to(default)\n session[:return_to] = nil\n end",
"def redirect_back_or( default )\n redirect_to( session[ :return_to ] || default )\n session.delete( :return_to )\n end",
"def redirect_back_or(default)\n redirect_to(session[:forwarding_url] || root_path)\n session.delete(:forwarding_url)\n end",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect_back_or(default)\n\t\tredirect_to(session[:forwarding_url] || default)\n\t\tsession.delete(:forwarding_url)\n\tend",
"def redirect(url)\n raise \"To be implemented by client application\"\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def redirect_back_or(default)\n \tredirect_to(session[:forwarding_url] || default)\n\t session.delete(:forwarding_url)\n\tend"
] | [
"0.7730111",
"0.7649159",
"0.704684",
"0.7029194",
"0.6981081",
"0.6871779",
"0.67809576",
"0.67569697",
"0.6699827",
"0.65908873",
"0.6580519",
"0.65731466",
"0.65681744",
"0.6567211",
"0.654002",
"0.653624",
"0.6530604",
"0.65075284",
"0.64961356",
"0.64893895",
"0.6443822",
"0.6438121",
"0.64144045",
"0.64038223",
"0.63955456",
"0.63915783",
"0.638389",
"0.63774705",
"0.6366385",
"0.6365043",
"0.6356526",
"0.63548374",
"0.6352605",
"0.63401383",
"0.633513",
"0.63308966",
"0.63308966",
"0.63304746",
"0.6327596",
"0.6324449",
"0.63240635",
"0.63172257",
"0.631491",
"0.63140327",
"0.63140327",
"0.63140327",
"0.63140327",
"0.63140327",
"0.6307154",
"0.6288226",
"0.6288226",
"0.6286348",
"0.628622",
"0.6282425",
"0.62797725",
"0.6279272",
"0.62750477",
"0.6270668",
"0.62699354",
"0.6269081",
"0.62617534",
"0.6260936",
"0.6243385",
"0.62430793",
"0.624299",
"0.624299",
"0.624299",
"0.624299",
"0.6242862",
"0.62418014",
"0.6233176",
"0.6231419",
"0.62295544",
"0.6228895",
"0.6228895",
"0.6228469",
"0.62256324",
"0.6223309",
"0.6220299",
"0.6220131",
"0.62192047",
"0.62185204",
"0.62185204",
"0.62183094",
"0.62165177",
"0.62163824",
"0.6214744",
"0.6214744",
"0.6214744",
"0.6214643",
"0.6213592",
"0.6211143",
"0.6211143",
"0.6211143",
"0.6211143",
"0.6211143",
"0.6211143",
"0.6211143",
"0.6209995",
"0.6208843",
"0.6204134"
] | 0.0 | -1 |
Stores the URL trying to be accessed. | def store_location
session[:forwarding_url] = request.url if request.get?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n session[:forwarding_url] = request.url if request.get?\n # Makes sure that the URL is saved only for a GET request because submitting\n # DELETE, PATCH or POST will raise errors when the URL is expecting\n # a GET request.\n end",
"def store_location\n # store last url as long as it isn't a /users path\n\tsession[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/ or request.fullpath =~ /\\/json/ or request.fullpath =~ /\\/static/\n\t\n end",
"def store_location\n\t\tif request.get?\n\t\t\tcookies[:previous_url] = request.url\n\t\tend\n\tend",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location!\n session[:\"#{scope}_return_to\"] = attempted_path if request.get? && !http_auth?\n end",
"def store_location\n # Store the URL only when the reqest was GET\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.url if request.get?\n end",
"def store_URL\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n\t\tsession[:forwarding_url] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.url if request.get?\n\tend",
"def store_url\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def url= new_url\n new_url = self.class.standardized_url new_url\n return if new_url == url\n super new_url # Heading for trouble if url wasn't unique\n @indexing_url = nil # Clear the memoized indexing_url\n self.http_status = nil # Reset the http_status\n # We do NOT build the associated site here, because we may be BUILDING the page_ref for a site, in\n # which case that site will assign itself to us. Instead, the site attribute is memoized, and if it\n # hasn't been built by the time that it is accessed, THEN we find or build an appropriate site\n self.site = SiteServices.find_or_build_for self\n self.kind = :site if site&.page_ref == self # Site may have failed to build\n # We trigger the site-adoption process if the existing site doesn't serve the new url\n # self.site = nil if site&.persisted? && (SiteServices.find_for(url) != site) # Gonna have to find another site\n request_attributes :url # Trigger gleaning and mercury_result to validate/modify url\n attrib_ready! :url # Has been requested but is currently ready\n end",
"def url=(_); end",
"def store_location!\n store_location_for(scope, attempted_path) if request.get? && !http_auth?\n end",
"def set_url\n @url = Url.find_by(key: params[:key])\n end",
"def store_location\n session[:forward_url] = request.url if request.get?\n end",
"def store_location\n\t\tsession[:forwarding_url]=request.original_url if request.get?\n\tend",
"def store_location\n\t\t# store last url - this is needed for post-login redirect to whatever the user last visited.\n\t\tif (request.fullpath != \"/users/sign_in\" &&\n\t\t\t\trequest.fullpath != \"/users/sign_up\" &&\n\t\t\t\trequest.fullpath != \"/users/password\" &&\n\t\t\t\trequest.fullpath != \"/users/sign_out\" &&\n\t\t\t\trequest.fullpath !~ /\\/users\\/confirmation/i &&\n\t\t\t\t!request.xhr?) # don't store ajax calls\n\t\t\tsession[:previous_url] = request.fullpath\n\t\tend\n\tend",
"def store_location\n # store last url - this is needed for post-login redirect to whatever the user last visited.\n return unless request.get? \n if (!request.fullpath.match(\"/users\") &&\n !request.xhr?) # don't store ajax calls\n session[\"user_return_to\"] = request.fullpath\n end\n end",
"def url_server\n\t\t\tunless @links_to_visit.empty?\n\t\t\t\t@url = @links_to_visit.pop\n\t\t\tend\n\t\tend",
"def store_location\n session[:forwarding_url] = request.url? if request.get?\n end",
"def store_location\n \tsession[:forwarding_url] = request.url if request.get?\n end",
"def store_location\n\t\tsession[ :forwarding_url ] = request.original_url if request.get?\n\tend",
"def store_location\n if request.get?\n session[:forwarding_url] = request.original_url\n end\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location \n\t\tsession[:forwarding_url] = request.url if request.get?\n\tend",
"def store_location\n\t # store last url - this is needed for post-login redirect to whatever the user last visited.\n\t if !devise_controller? && !request.xhr? # don't store ajax calls\n\t session[:previous_url] = request.fullpath \n\t end\n\tend",
"def url=(url)\n @@url = url\n end",
"def store_location\n session[ :return_to ] = request.url if request.get?\n end",
"def store_location\n # store last url - this is needed for post-login redirect to whatever the user last visited.\n if (request.path != \"/users/sign_in\" &&\n request.path != \"/users/sign_up\" &&\n request.path != \"/users/password/new\" &&\n request.path != \"/users/password/edit\" &&\n request.path != \"/users/confirmation\" &&\n request.path != \"/users/sign_out\" &&\n !request.fullpath.match(/\\/users\\/auth\\//) &&\n !request.xhr?) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location_url(url)\n session[:forwarding_url] = url\n end",
"def store_location\n session[:forwarding_url] = request.original_fullpath if request.get?\n end",
"def store_location\n \t\tsession[:forwarding_url] = request.original_url if request.get?\n \tend",
"def url=(url)\n @@url = url\n end",
"def store_location\n # session[:forwarding_url] = request.url if request.get?\n user_session[:forwarding_url] = request.referer if request.get? && request.referer\n end",
"def save_previous_url\n\t\t\tunless request.referer.include?('likes')\n\t\t\t\tsession[:previous_url] = URI(request.referrer).path\n\t\t\tend\n\t\tend",
"def store_location\n session[:forwarding_url] = request.url if request.get?\n end",
"def store_location\n\t\t#Store target location (only if request=get). (For example, if user request a page but\n\t\t# it's not signed in. It remembers the request)\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n session[:forwarding_url]=request.fullpath if request.get?\n end",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:last_page] = @request.request_uri\n\tend",
"def store_location\n\t session[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n if request.get?\n session[:return_to] = request.url\n end\n end",
"def store_location\n if request.get?\n session[:return_to] = request.url\n end\n end",
"def store_location\n if request.get?\n session[:return_to] = request.url\n end\n end",
"def store_location\n if request.get?\n session[:return_to] = request.url\n end\n end",
"def store_location\n \tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location(url = url_for(:controller => controller_name, :action => action_name))\n # It's possible to create a redirection attack with a redirect to data: protocol... and possibly others, so:\n # Whitelisting redirection to our own site and relative paths.\n url = nil unless url =~ /\\A([%2F\\/]|#{root_url})/\n session[:return_to] = url\n end",
"def store_location\n session[:forwarding_url] = request.url if request.get? # only for get requests. A user could technically delete their cookie then submit a form\n end",
"def store_forwarding_url\n session[:forwarding_url] = request.url if request.get?\n end",
"def store_location\n if ((!request.fullpath.match(\"/users\") && !request.fullpath.match(\"/admin\") && !request.fullpath.match(\"/admin/login\")) &&\n !request.xhr?) # don't store ajax calls\n# puts \"----------------------------\"\n# puts \"--not store--\"\n session[:previous_url] = request.fullpath\n else\n# puts \"----------------------------\"\n# puts \"--store--\"\n end\n end",
"def guardar_URL\n\t\tsession[:url_deseada] = request.original_url if request.get?\n\tend"
] | [
"0.6912814",
"0.6897356",
"0.688702",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6694544",
"0.66805685",
"0.66383713",
"0.6634571",
"0.6630931",
"0.6593764",
"0.6593764",
"0.6593764",
"0.6593764",
"0.6593677",
"0.65701944",
"0.65585965",
"0.6557071",
"0.655092",
"0.65458846",
"0.6495066",
"0.6492803",
"0.64884543",
"0.64841366",
"0.64692926",
"0.64670247",
"0.6462621",
"0.64622223",
"0.6461886",
"0.6461886",
"0.6459761",
"0.6457037",
"0.6444241",
"0.64190674",
"0.6404889",
"0.6394051",
"0.6394051",
"0.6394051",
"0.6394051",
"0.63932395",
"0.6390039",
"0.63803685",
"0.63747966",
"0.63697034",
"0.63678056",
"0.6352348",
"0.63515145",
"0.633886",
"0.63378155",
"0.63378155",
"0.63378155",
"0.63347703",
"0.63187176",
"0.6318029",
"0.6318029",
"0.6318029",
"0.6318029",
"0.63155544",
"0.6314164",
"0.6304329",
"0.630132",
"0.6292948",
"0.62913555"
] | 0.647905 | 55 |
Confirms a loggedin user. | def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please enter your worker ID to continue."
redirect_to start_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n end\n end",
"def confirm_logged_in\n \tunless session[:user_id]\n \t\tflash[:notice] = \"Please Log in.\"\n \t\tredirect_to(login_path)\n \tend\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n\t\t\tend\n\t\tend",
"def confirm\n if @user = UserConfirmsAccount.new(:token => params[:token]).call\n self.establish_session @user\n redirect_to profile_url, :notice => \"Thanks for confirming #{@user.email}\"\n else\n redirect_to profile_url, :notice => \"There was a problem confirming - try re-sending the email?\"\n end\n end",
"def confirm\n user = User.find(params[:id])\n authorize user\n if user.state != \"active\"\n user.confirm\n user.make_user_a_member\n\n # assume this type of user just activated someone from somewhere else in the app\n flash['notice'] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n unless @user == current_user\n flash[:danger] = 'You are not authorized to do that.'\n redirect_to(root_url)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n if @user != current_user\n flash[:alert] = \"Action not authorized\"\n redirect_to(root_url)\n end\n end",
"def correct_user\n unless helpers.current_user?(@user)\n flash[:danger] = \"You don't have permission to do that\"\n redirect_to root_path\n end\n end",
"def confirm_logged_in\n unless session[:user_id]\n redirect_to login_path, alert: \"Please log in\"\n end\n end",
"def confirm_user_logged_in\n unless logged_in?\n store_url # So that user is sent to the same URL after they log in\n flash[:danger] = \"Please log in.\"\n redirect_to root_url\n end\n end",
"def confirm_logged_in\n unless session[:user_id] != nil\n redirect_to root_path\n end\n end",
"def correct_user\n @user = User.find(params[:user_id])\n redirect_to('/unauthorized') unless current_user?(@user)\n end",
"def confirm\n if current_visitor && current_visitor.has_role?('admin', 'manager')\n user = User.find(params[:id]) unless params[:id].blank?\n if !params[:id].blank? && user && user.state != \"active\"\n user.confirm!\n user.make_user_a_member\n # assume this type of user just activated someone from somewhere else in the app\n flash[:notice] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n else\n flash[:notice] = \"Please login as an administrator.\"\n redirect_to(root_path)\n end\n end",
"def correct_user\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tredirect_to(root_url) unless @user == current_user\n\t\tend",
"def correct_user\n @user = User.find(params[:id])\n if current_user != @user\n flash[:danger] = \"You don't have permission for that\"\n redirect_to(root_url) unless current_user?(@user)\n end\n end",
"def appctrl_confirm_user\n redirect_to( signin_path() ) unless @current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n flash[:danger] = \"Sorry, you're aren't allowed to access that.\"\n redirect_to(\"/#flash\") \n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to root_path, alert: \"You do not have access to that page\" unless current_user == @user\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to root_path unless @user == current_user\n\tend",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n flash[:danger] = \"Admin Access Only.\"\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tif current_user != @user\n\t\t\t\tredirect_back(fallback_location: root_path)\n\t\t\tend\n\t\tend",
"def user_stray\n if !logged_in? || @user == nil\n flash[:alert] = \"You have been logged out of your session. Please log back in to continue.\"\n redirect \"/\"\n elsif @user.id != current_user.id\n flash[:alert] = \"You do not have permission to view or edit other users' content.\"\n redirect \"/\"\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n user = User.find(params[:id])\n unless current_user?(user) \n flash[:danger] = \"Uncorrect user.\"\n redirect_to(root_url) \n end\n end",
"def switch\n authorize!(:manage, :all)\n user = User.find_by(login: params[:login].upcase)\n if user\n session[:original_user_id] = session[:user_id]\n session[:user_id] = user.id\n redirect_to root_url, notice: \"Sie sind nun der Nutzer mit dem Login #{user.login}.\"\n else\n redirect_to root_url, notice: \"Der Nutzer existiert nicht im System.\"\n end\n end",
"def correct_user\n set_user\n unless current_user?(@user)\n flash[:danger] = 'This action is not permitted for this account since you are not the owner'\n redirect_to overview_user_path(current_user)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def confirm_user\n if session[:user_id]\n return true\n else\n flash[:notice] = \"please login\"\n redirect_to(:controller => 'manage', :action => 'login')\n return false\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user)\n flash[:danger] = \"Yikes. Sorry, but it doesn't look you have permission to do that 😬\"\n redirect_back(fallback_location: root_url)\n end\n end",
"def correct_user\n\t @user = User.find(params[:id])\n\t unless current_user?(@user)\n\t flash[:danger] = \"You don't have rights\"\n\t\t\tredirect_back_or(root_url)\n\t end\n\tend",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user === current_user\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tredirect_to(root_path) unless current_user?(@user)\n\t\tend",
"def confirm_logged_in\n unless session[:username]\n redirect_to authenticate_login_path\n else\n true\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to root_path unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user)\n flash[:danger] = \n \"You do not have permission to access #{@user.name}'s account.\"\n redirect_to(root_url)\n end\n end",
"def correct_user\n @course = Course.find(params[:id])\n @user = @course.users\n unless current_user == @user\n redirect_to(root_url) \n flash[:danger] = \"You are not the authorised user\"\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user # sauf si\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_path) unless current_user?(@user)\n\tend",
"def correct_user\n\t\tunless current_user == @univers.user\n\t\t\tflash[:danger] = \"You have no power there\"\n\t\t\tredirect_to universes_path\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) #checks if current_user == @user\n #current_user? defined in session helper\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n \n redirect_to(login_path) unless current_user?(@user)\n end",
"def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\n redirect_to root_path\n return false # halts the before_action\n else\n return true\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(user_root_path,:notice => 'You cannot access this page') unless current_user == @user\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def logged_in_user\n unless !current_user.nil?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n\n if @user != current_user\n redirect_to(root_path)\n else\n # nothing to do\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @question = Question.find(params[:id])\n redirect_to(root_url) unless current_user == @question.user\n end",
"def confirm_matching\n @user = User.find(params[:id])\n redirect_to root_path unless current_user? @user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless (current_user.id == @user.id)\n end",
"def correct_user\n @user = User.find(params[:id])\n # current_user?() is a sessions_helper method. The user of the params hash has\n # to match the current user or will be redirected to root\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n\t\t@user = User.find(params[ :id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end",
"def confirm_logged_in\r\n unless session[:username]\r\n redirect_to authenticate_index_path\r\n else\r\n true\r\n end\r\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) # current_user is method in sessions_helper.rb\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end"
] | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.6480418",
"0.6479267",
"0.64705276",
"0.64680994",
"0.64656436",
"0.6457351",
"0.64541256",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.6445996",
"0.6437721",
"0.64289176",
"0.64260334",
"0.6424799",
"0.6417934",
"0.64177954",
"0.64163303",
"0.6410097",
"0.6401843",
"0.63820904",
"0.63622755",
"0.63595843",
"0.6355515",
"0.635374",
"0.6351282",
"0.6350864",
"0.63502026",
"0.63502026",
"0.63502026",
"0.6347271",
"0.63426447",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.63400817",
"0.63345385",
"0.63329995",
"0.6331134",
"0.6330873",
"0.632984",
"0.6325074",
"0.63200074",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605"
] | 0.0 | -1 |
I worked on this challenge with: Jon Clayton. Your Solution Below | def leap_year? (year)
case
when year % 400 == 0
return true
when year % 100 == 0
return false
when year % 4 == 0
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def challenge; end",
"def decodeHalfway(input)\n sum = 0\n\n # Only have to loop through half the array since the numbers are being compared halfway around\n # Multiply each matching character by 2 to compensate for not looping through its pair\n input.chars[0..input.length/2 - 1].each_with_index do |char, i|\n sum += 2*char.to_i if char == input[i + input.length/2]\n end\n sum\nend",
"def isLucky(n)\r\nhalf1 = []\r\nhalf2 = []\r\nn_string = n.to_s\r\n\r\n\r\nfirsthalf = (n_string.length / 2) - 1\r\nsecondhalfstart = (n_string.length / 2)\r\nsecondhalfend = (n_string.length - 1)\r\n(0..firsthalf).each do |idx|\r\n half1 << n_string[idx].to_i\r\nend\r\n\r\n(secondhalfstart..secondhalfend).each do |idx|\r\n half2 << n_string[idx].to_i\r\nend\r\n\r\nreturn true if half1.inject(:+) == half2.inject(:+)\r\nreturn false\r\nend",
"def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend",
"def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend",
"def is_happy(n)\n i = 0\n r = false\n destination = []\n while r == false\n n.to_s.split(\"\").each do |x|\n destination << ((x.to_i * x.to_i))\n end\n i = i + 1\n n = destination.inject(&:+)\n r = true if n == 1\n destination = []\n break if i == 1000\n end\n if r == true\n p r\n else\n p false\n end\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def input_string\n result = \"73167176531330624919225119674426574742355349194934\"\n result += \"96983520312774506326239578318016984801869478851843\"\n result += \"85861560789112949495459501737958331952853208805511\"\n result += \"12540698747158523863050715693290963295227443043557\"\n result += \"66896648950445244523161731856403098711121722383113\"\n result += \"62229893423380308135336276614282806444486645238749\"\n result += \"30358907296290491560440772390713810515859307960866\"\n result += \"70172427121883998797908792274921901699720888093776\"\n result += \"65727333001053367881220235421809751254540594752243\"\n result += \"52584907711670556013604839586446706324415722155397\"\n result += \"53697817977846174064955149290862569321978468622482\"\n result += \"83972241375657056057490261407972968652414535100474\"\n result += \"82166370484403199890008895243450658541227588666881\"\n result += \"16427171479924442928230863465674813919123162824586\"\n result += \"17866458359124566529476545682848912883142607690042\"\n result += \"24219022671055626321111109370544217506941658960408\"\n result += \"07198403850962455444362981230987879927244284909188\"\n result += \"84580156166097919133875499200524063689912560717606\"\n result += \"05886116467109405077541002256983155200055935729725\"\n result += \"71636269561882670428252483600823257530420752963450\"\n\n result\nend",
"def solution(s)\n if s.length.odd?\n center = s.length / 2\n if s[0...center] == s[center + 1..s.length].reverse\n return center \n end\n end\n -1\nend",
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend",
"def solution(n)\n n.to_s.split(//).inject(1) { |a,d| a + d.to_i }\nend",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"def theLoveLetterMystery(s)\n chars = s.chars\n size = chars.length\n sum = 0\n ((size+1)/2..(size -1)).each do |i|\n num = chars[i].ord\n target_num = chars[size-1-i].ord\n sum += (num - target_num).abs\n end\n sum\nend",
"def solve(input)\n data = input.chars\n buckets = []\n current = []\n data.each_with_index do |c, i|\n n = data[i + 1]\n current << c\n unless n == c\n buckets << current\n current = []\n end\n break if n.nil?\n end\n\n ret = ''\n buckets.each do |b|\n ret += b.count.to_s\n ret += b.first\n end\n ret\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend",
"def isLucky(n)\n new_array = n.to_s.split(\"\")\n new_length = new_array.length\n\n a, b = [], []\n\n (0...new_length / 2).each { |x| a.push(new_array[x].to_i) }\n (new_length / 2...new_length).each { |y| b.push(new_array[y].to_i) }\n\n if a.inject(:+) == b.inject(:+)\n return true\n else\n false\n end\n\nend",
"def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def solution\n (2..(9**5 * 6)).select do |n|\n n.to_s.split(//).map do |d|\n d.to_i ** 5\n end.reduce(:+) == n\n end.reduce(:+)\nend",
"def solution(n)\n n.to_s(2).reverse.to_i.to_s.split('1').map(&:length).max || 0\nend",
"def isLucky(n)\n sum, sum2 = 0, 0\n arr = n.to_s.split(\"\")\n \n first_half = arr.take(arr.size / 2) \n second_half = arr.drop((arr.size / 2))\n first_half.each { |x| sum += x.to_i }\n second_half.each {|x| sum2 += x.to_i}\n \n sum == sum2\nend",
"def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend",
"def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend",
"def solution(n)\n # write your code in Ruby 2.2\n a = n.to_s(2)\n arr = []\n if a[-1] == '1'\n arr = a.split('1')\n else\n arr = a.split('1')\n arr.pop\n end\n if arr.max.nil?\n 0\n else\n arr.max.length\n end\nend",
"def solution(a, b)\n if a.length > b.length\n return (b + a + b).to_s\n else\n return (a + b + a).to_s\n end\nend",
"def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend",
"def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend",
"def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend",
"def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend",
"def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend",
"def captcha(input)\n sum = 0\n 0.upto(input.length - 1) do |i|\n sum += input[i].to_i if input[i] == input[(i+1) % input.length]\n end\n sum\nend",
"def solution(roman)\n split = roman.split(\"\")\n last_value = 0\n split.reduce(0) do |final, char|\n current = CONVERSION[char.upcase]\n binding.pry\n if current >= last_value\n final += current\n else\n final -= current\n end\n binding.pry\n last_value = current\n final\n end\nend",
"def num_decodings(s)\n\n decode = ('A'..'Z').to_a\n number_of_prev_ended_singly = 1\n\n ways_count = 1\n number_of_prev_ended_singly = 1\n\n s.chars[1..-1].each_with_index do |ch, idx|\n if s[idx - 1].to_i == 1 ||\n s[idx - 1] == 2.to_i && ch.to_i.between?(1,6)\n\n numbers_added_this_time = ways_count - number_of_prev_ended_singly\n ways_count += numbers_added_this_time\n number_of_prev_ended_singly = numbers_added_this_time\n else\n number_of_prev_ended_singly = 0\n end\n end\n\n ways_count\n\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def solution(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\nend",
"def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def isLucky(n)\n a = n.to_s.split(\"\")\n full = a.count - 1\n half = a.count/2 - 1\n \n total_1 = 0\n total_2 = 0\n \n for i in 0..full\n if i > half\n total_2 += a[i].to_i\n else\n total_1 += a[i].to_i\n end\n end\n \n if total_1 == total_2\n true\n else\n false\n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def solution(a)\n cars_going_east = [0]\n\n a.each do |direction|\n next_counter = direction.zero? ? cars_going_east.last + 1 : cars_going_east.last\n cars_going_east << next_counter\n end\n\n passings = 0\n a.each_with_index do |direction, index|\n passings += cars_going_east[index] if direction == 1\n end\n\n return -1 if passings > 1000000000\n passings\nend",
"def solution(n)\n # write your code in Ruby 2.2\n a = Math.sqrt(n).floor\n a -= 1 while n % a != 0\n b = n / a\n (a + b) * 2\nend",
"def solution1(seeds)\n turn_map = {}\n seeds.each_with_index { |n, turn| turn_map[n] = [1, turn + 1, turn + 1] }\n last_number = seeds.last\n\n ((seeds.length+1)..2020).each do |turn|\n last_stats = turn_map[last_number]\n if last_stats[TIMES_SPOKEN] == 1\n zero = turn_map[0] || [0, turn, turn]\n zero[TIMES_SPOKEN] += 1\n zero[FIRST_SPOKEN] = zero[LAST_SPOKEN]\n zero[LAST_SPOKEN] = turn\n \n turn_map[0] = zero\n last_number = 0\n else\n age = last_stats[LAST_SPOKEN] - last_stats[FIRST_SPOKEN]\n\n num = turn_map[age] || [0, turn, turn]\n num[TIMES_SPOKEN] += 1\n num[FIRST_SPOKEN] = num[LAST_SPOKEN]\n num[LAST_SPOKEN] = turn\n \n turn_map[age] = num\n last_number = age\n end\n end\n\n last_number\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def solution(a)\n ans = 0\n for i in 1 .. (a.length - 1)\n ans += a[i]\n end \n ans\nend",
"def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend",
"def day_2_part_2\n noun = 0\n verb = 0\n\n while noun < 100\n while verb < 100\n if compute(noun, verb) == 19690720\n return (100 * noun) + verb\n end\n verb += 1\n end\n noun += 1\n verb = 0\n end\nend",
"def solution(k, a)\n count = 0\n current = 0\n a.each { |length| \n current += length\n if current >= k\n current = 0\n count += 1\n end\n }\n count\nend",
"def hard(input)\n to = input / 10\n houses = Array.new(to, 0)\n (1..to).each do |n|\n count = 0\n n.step(by: n, to: to - 1) do |i|\n houses[i] += 11 * n\n count += 1\n break if count == 50\n end\n end\n houses.index { |count| count >= input }\nend",
"def correct(element)\n result = nil\n element.downto(0).each do |j|\n i = element - j\n if j == element && j % 3 == 0\n result = Array.new(j, 5)\n elsif i % 5 == 0 && j % 3 == 0\n result = Array.new(j, 5) + Array.new(i, 3)\n elsif i == element && i % 5 == 0\n result = Array.new(i, 3)\n end\n\n break if result\n end\n\n if result.nil?\n puts -1\n else\n puts result.join()\n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def hackerrankInString(str)\n expected_chars = %w[h a c k e r r a n k]\n input_chars = str.chars\n\n str.chars.each do |char|\n # Thought so, apparently not: Edge case: there should be no more chars after the last 'k' in hackerrank.\n # break if expected_chars.empty?\n\n input_chars.shift\n expected_chars.shift if char == expected_chars[0]\n end\n\n expected_chars.empty? && input_chars.empty? ? 'YES' : 'NO'\nend",
"def solution(a)\n # write your code in Ruby 2.2\n\n # sort a\n a = a.sort\n odd = 0\n\n # loop over the array\n (0..(a.length-1)).step(2) do |i|\n if((i+1 >= a.length) || ((i+1 < a.length) && (a[i] != a[i+1])))\n odd = a[i]\n break\n end\n end\n\n odd\nend",
"def alg; end",
"def isLucky(n)\n n = n.to_s.split('').map(&:to_i)\n n.shift(n.size/2).reduce(:+) == n.reduce(:+)\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def goodVsEvil(good, evil)\n # good_power, evil_power = 0, 0\n # good.split.each_with_index do |num, i|\n # if i < 3\n # good_power += num.to_i * (i + 1)\n # elsif i < 5\n # good_power += num.to_i * i\n # elsif i == 5\n # good_power += num.to_i * 2 * i\n # end\n # end\n god = good.split.each_with_index.inject(0) do |sum, (num, i)|\n if i < 3\n sum + num.to_i * (i + 1)\n elsif i < 5\n sum + num.to_i * i\n elsif i == 5\n sum + num.to_i * 2 * i\n end\n end\n \n \n evl = evil.split.each_with_index.inject(0) do |sum, (num, i)|\n case i\n when 0\n sum + num.to_i * (i + 1)\n when 1, 2, 3\n sum + num.to_i * 2\n when 4\n sum + num.to_i * (i - 1)\n when 5\n sum + num.to_i * i\n when 6\n sum + num.to_i * (i + 4) \n end\n end\n \n if evl > god\n str = \"Evil eradicates all trace of Good\"\n elsif evl < god\n str = \"Good triumphs over Evil\"\n else\n str = \"No victor on this battle field\"\n end\n \n \"Battle Result: #{str}\"\nend",
"def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (expected_sum - real_sum).to_i\nend",
"def main\n max = 10 ** 9 + 7\n all = 1\n zero = 1\n nine = 1\n zn = 1\n N.times.each do\n all = all * 10 % max\n zero = zero * 9 % max\n nine = nine * 9 % max\n zn = zn * 8 % max\n end\n return (all - zero - nine + zn) % max\nend",
"def solve(s)\n answer = \"\"\n arr = s.split('')\n hash = Hash.new(0)\n arr.each_with_index do |el, idx|\n if el.to_i >= 1\n if arr[idx + 1] == \"(\"\n el.to_i.times do \n if arr[idx + 2].to_i >= 1\n if arr[idx + 3] == \"(\"\n arr[idx + 2].to_i.times do \n answer += (arr[(idx + 4)...arr.index(\")\")].join(''))\n end\n end\n end\n answer += (arr[(idx + 2)...arr.index(\")\")].join(''))\n end\n \n # hash[arr[idx + 1]] += 1\n end\n end\n \n end\n return answer\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def solve(nums)\n count = 0\n nums.each do |num|\n if num.to_s.length % 2 != 0\n count += 1\n end\n end\n return count\nend",
"def solution(a)\n # write your code in Ruby 2.2\n counts = {}\n missing = -1\n\n a.each do |a_i|\n counts[a_i] = counts[a_i].to_i + 1\n end\n\n (1..a.length).each do |i|\n if(counts[i].nil?)\n missing = i\n break\n end\n end\n\n if(missing == -1)\n missing = a.length + 1\n end\n\n missing\nend",
"def solution(a)\n return 0 if a.length < 3\n a.sort!\n\n for i in 0..(a.length - 3)\n return 1 if a[i] + a[i + 1] > a[i + 2]\n end\n return 0\nend",
"def is_armstrong(n)\n n_str=n.to_s()\n char_list=n_str.split(//)\n int_list=char_list.map {|x| (x.to_i())**(n_str.length()) }\n mysum = int_list.reduce(0) { |sum, num| sum + num }\n return (mysum==n)\nend",
"def isHappy? n\n acc = {}\n acc[n] = true\n begin\n sum = 0\n n.to_s.split(\"\").map {|i| sum += i.to_i**2}\n\n if sum == 1 then return true\n elsif acc.has_key?(sum) then return false\n else acc[sum] = true end\n\n n = sum\n end while sum != 1\nend",
"def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend",
"def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend",
"def strong_num(n)\n array = n.to_s.chars.map(&:to_i)\n sumarray = []\n array.each do |number|\n sum = (1..number).inject(:*) || 1\n sumarray << sum\n end\n sumarray.sum == n ? \"STRONG!!!!\" : \"Not Strong !!\"\nend",
"def Lexicographic(myString)\n\n origArray = myString.split(//)\n newArr = origArray.permutation.to_a\n counter = 1\n newArr.each do |x|\n if counter == 1000000\n print counter, \"--> \", x.join, \"\\n\"\n break\n else\n counter = counter + 1\n end\n end\nend",
"def odds_and_evens(string, return_odds)\n# Creates new method with two arguments, 'string' and 'return_odds' boolean.\n\n to_return = \"\"\n# Creates new variable and assigns it an empty string.\n\n string.size.times do |index|\n# First applies the .size method to the string to calculate the size of the string and return the resulting number. E.g. if the string is \"Rare\", .size will applied to the string returns 4 because \"Rare\" has 4 letters.\n\n# Second applies the .times to the number returned after calculating the string size. E.g. if the string is \"Rare\", .times will execute the following loop x4 times.\n\n# Third the \"| index |\" means do for each indexed character the following steps. A string has an index, e.g. [[0, r], [1, a], [2, r], [3, e]], where the first character is the index number and the second is the corresponding character. Note '0' is considered an even number for coding purposes.\n\n next if return_odds && index.even?\n # First iteration iterates over index[0], i.e. \"r'.\n # => next if false && r.even?\n # => next if false && true\n # => next if false\n # => therefore tells ruby don't skip \"r\" and instead move on to complete next step using the return value of index[0].\n\n # Second iteration iterates over index[1], i.e. 'a'.\n # => next if false && a.even?\n # => next if false && false\n # => next if false\n # => therefore tells ruby don't skip \"a\" and instead move on to complete next step using the return value of index[1].\n\n # Third iteration iterates over index[2], i.e. the second letter \"r\".\n # => next if false && r.even?\n # => next if false && true\n # => next if false\n # => therefore tells ruby don't skip \"r\" and instead move on to complete next step using the return value of index[2].\n\n # Fourth iteration iterates over index[3], i.e. \"e\".\n # => next if false && e.even?\n # => next if false && false\n # => next if false\n # => therefore tells ruby don't skip \"e\" and instead move on to complete next step using the return value of index[2].\n\n puts index\n\n # First iteration puts value of index[0] to screen.\n\n # Second iteration puts value of index[1] to screen.\n\n # Third iteration puts value of index[2] to screen.\n\n # Fourth iteration puts value of index[3] to screen.\n\n next if !return_odds && index.odd?\n # First iteration continues to iterate this step over index[0], i.e. \"r\".\n # => next if true && r.odd?\n # => next if true && false\n # => next if false\n # => therefore tells ruby don't skip \"r\" and instead move on to complete the next steps using index[0] as return value.\n\n # Second iteration continues to iterate this step over index[1], i.e. \"a\".\n # => next if true && a.odd?\n # => next if true && true\n # => next if true\n # => therefore tells ruby to skip \"a\" and ignore the next steps.\n\n # Third iteration continues to iterate this step over index[2], i.e. \"r\".\n # => next if true && r.odd?\n # => next if true && false\n # => next if false\n # => therefore tells ruby don't skip \"r\" and instead move on to complete the next steps using index[2] as return value.\n\n # Second iteration continues to iterate this step over index[3], i.e. \"e\".\n # => next if true && e.odd?\n # => next if true && true\n # => next if true\n # => therefore tells ruby to skip \"e\" and ignore the next steps.\n\n puts \"#{index}+x\"\n\n # First iteration puts value of \"index[0]+x\" to screen, i.e. \"0+x\".\n\n # Third iteration puts value of \"index[2]+x\" to screen, i.e. \"2+x\".\n\n to_return << string[index]\n # First iteration continues to iterate this step over index[0], i.e. \"r\".\n # => \"\" << string[0]\n # => \"\" << \"r\"\n # => to_return = \"r\"\n # In other words, ruby adds the current return value, index[0] (i.e. \"r\"), to the variable \"to_return\".\n\n # Second iteration continues to iterate this step over index[2], i.e. \"r\".\n # => \"r\" << string[2]\n # => \"r\" << \"r\"\n # => to_return = \"rr\"\n # In other words, ruby adds the current return value, index[2] (i.e. \"r\"), to the variable \"to_return\".\n\n end\n\n to_return\n# Return the final value of to_return after iterating each character in the chosen string. This does not get returned until the above loop has completed.\n\nend",
"def solution(a)\n # write your code in Ruby 2.2\n return 0 unless a[0]\n necklaces = create_necklaces(a)\n \n \n size = necklaces.length\n index = 0\n max = necklaces[index].length\n \n while index < size\n if necklaces[index].length > max\n max = necklaces[index].length\n end\n index += 1\n end\n \n return max\nend",
"def funny string\n arr = string.chars\n count = 0\n arr.each_with_index do |x,xi|\n if xi > 0\n s1 = (x.ord - arr[xi-1].ord).abs\n s2 = (arr[-(xi+1)].ord - arr[-xi].ord).abs\n s1 == s2 ? count +=1 : break\n end\n end\n puts count == arr.size-1 ? 'Funny' : 'Not Funny'\nend",
"def formingMagicSquare(s)\r\n out = 100\r\n for i in 0...8 do\r\n cost = 0\r\n for j in 0...3 do\r\n for k in 0...3 do\r\n cost += ($magic_square[i][j][k] - s[j][k]).abs\r\n end\r\n end\r\n puts cost\r\n out = [out, cost].min\r\n end \r\n out\r\nend",
"def solution(number)\n sum = 0\n Array(1..number-1).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend",
"def solve(n, s, d, m)\n # Complete this function\n records = s;\n\n (1...n).each do |i|\n records[i] += records[i-1]\n end\n\n numberOfWays = (m <= n && records[m - 1] == d) ? 1 : 0;\n\n (m...n).each do |i|\n if records[i] - records[i - m] == d\n numberOfWays += 1\n end\n end\n\n numberOfWays\n\nend",
"def happy? n\n visited = []\n until n == 1 || visited.include?(n)\n visited << n\n n = n.to_s.chars.map{ |x| x.to_i * x.to_i }.inject{ |sum, x| sum + x }\n end\n n == 1\nend",
"def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend",
"def is_happy(n)\n return false if n < 10 && n % 2 == 0\n return false if n < 1 \n return true if n == 1\n \n sum = 0\n\n nsplit = n.to_s.split(\"\")\n nsplit.each do |i|\n sum += (i.to_i * i.to_i)\n end\n\n return is_happy(sum)\n \nend",
"def clumsy(n)\n a = (1..n).to_a.reverse\n \n result = [a[0]]\n \n a[1..a.size - 1].each_with_index do |num, index|\n if index % 4 == 0\n result << '*'\n elsif index % 4 == 1 \n result << '/'\n elsif index % 4 == 2\n result << '+'\n else\n result << '-'\n end\n \n result << num\n end\n \n result = multiply_and_divide_all_results(result)\n \n add_and_subtract_all_results(result)\nend",
"def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend",
"def problem18(r) \n h = r.length\n sum = 0\n for i in 0..h-1 \n \n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend",
"def f_1_4tel_rek(n)\r\n if !n.integer? || n < 1\r\n return false\r\n end\r\n\r\n def end_rek(i, s)\r\n if i > 0\r\n end_rek(i - 1, (1.0 / (i * (i + 1.0) * (i + 2.0))) + s)\r\n else\r\n return s\r\n end\r\n end\r\n return end_rek(n, 0)\r\nend",
"def decent_number(n)\n\tleft = 0\n\tright = 0\n\t(n+1).times do |i|\n\t\tleft = n - i \n\t\tright = n - left\n\t#\tputs \"#{left}%3 = #{left%3} | #{right}%5 = #{right%5}\"\n\t\tbreak if left % 3 == 0 && right % 5 == 0\n\tend\n\t#puts \"**l = #{left} r = #{right}\"\n\n\tif left % 3 == 0 && right % 5 == 0\n\t\tfives = \"5\"*left\n\t\tthrees = \"3\"*right\n\t\tputs fives+threes\n\telse\n\t\tputs -1\n\tend\nend",
"def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend",
"def brut_force_solution\n (1...1000).inject(0){|sum, digit| ((digit % 3 == 0) || (digit % 5 == 0)) ? sum += digit : sum}\nend",
"def solution(a)\n candidate = a[0]\n count = 0\n index = 0\n a.each_with_index do |d, idx|\n count = candidate == d ? count += 1 : count -= 1\n if count == 0\n candidate = d\n count = 1\n index = idx\n end\n end\n a.count { |d| d == candidate } * 2 > a.length ? index : -1\nend",
"def pzoe\n sum = 0\n (0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |e|\n (0..9).each do |f|\n (0..9).each do |g|\n sum += a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g if a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g == a ** 5 + b ** 5 + c ** 5 + e ** 5 + f ** 5 + g ** 5\n end\n end\n end\n end\n end\n end\n sum - 1\nend",
"def part2(program)\n special = 19690720\n (0..99).to_a.repeated_permutation(2).each do |noun, verb|\n input = program.dup\n input[1] = noun\n input[2] = verb\n\n output = run(input)\n puts \"noun = #{noun}, verb = #{verb}, output = #{output[0]}\"\n if output[0] == special\n return [noun, verb]\n end\n end\n puts \"fuck\"\n return [-1, -1]\nend",
"def find_missing_letter(arr)\n #your code here\n result = 0\n base_arr = arr.join().codepoints\n base_arr.each_with_index do |item,index|\n if base_arr[index+1] != item + 1\n result = item + 1\n break\n end\n end\n result.chr\nend",
"def solution a\n a.sort!\n until a.empty?\n answer = a.pop\n return answer if a.pop != answer\n end\nend",
"def solve\n 1.upto(100).inject(:*).to_s.split('').map{|x| x.to_i}.inject(:+)\nend",
"def compute\n perimeter = 1000\n (1..(perimeter+ 1)).each do |a|\n ((a + 1)..(perimeter + 1)).each do |b|\n c = perimeter - a - b\n return (a * b * c).to_s if (a * a + b * b == c * c)\n end\n end\nend",
"def solution(digits)\n result = 0\n digits.size.times do |n|\n new_number = digits[n...(n + 5)].to_i\n result = new_number if new_number > result\n end\n result\nend",
"def part_two(input)\n found = false\n cleaned = input.each_with_index.map { |v, i| [v, i] unless v == 'x' }.compact\n iter = cleaned.map(&:first).max\n index = cleaned.map(&:first).find_index(iter)\n t = iter\n until found\n t += iter\n puts \"#{t}\"\n found = true\n v = t - index\n cleaned.each do |bus, i|\n if (v + i) % bus != 0\n found = false\n break\n end\n end\n end\n t\nend"
] | [
"0.6426526",
"0.6196587",
"0.6143841",
"0.60725206",
"0.60663986",
"0.60514444",
"0.6044827",
"0.60304916",
"0.60167587",
"0.59670925",
"0.59660167",
"0.5930118",
"0.5916622",
"0.5908013",
"0.5902738",
"0.5890668",
"0.5882447",
"0.5870266",
"0.5864797",
"0.586191",
"0.5860125",
"0.5854231",
"0.5853529",
"0.5845457",
"0.5843166",
"0.58418006",
"0.5826551",
"0.5813903",
"0.5804976",
"0.5800246",
"0.5798661",
"0.57807326",
"0.5767266",
"0.5765492",
"0.5761783",
"0.5754697",
"0.57498765",
"0.5748685",
"0.5742788",
"0.57339054",
"0.57213557",
"0.57180685",
"0.5706615",
"0.5704251",
"0.5702108",
"0.5700464",
"0.5700321",
"0.56914973",
"0.5690511",
"0.5687178",
"0.5685812",
"0.5684718",
"0.56805074",
"0.568026",
"0.5676355",
"0.5674976",
"0.56730014",
"0.56640285",
"0.56558913",
"0.56465095",
"0.5644003",
"0.5643173",
"0.5642629",
"0.56403023",
"0.56337196",
"0.5629039",
"0.56256676",
"0.56235045",
"0.5618923",
"0.56161416",
"0.56126493",
"0.56104714",
"0.56025416",
"0.56001353",
"0.55993783",
"0.5595219",
"0.55952126",
"0.55918276",
"0.5587841",
"0.55849665",
"0.5583667",
"0.55796427",
"0.5576227",
"0.5575724",
"0.55748755",
"0.5574349",
"0.55706024",
"0.5564179",
"0.556181",
"0.5550908",
"0.554988",
"0.5548414",
"0.55455494",
"0.5545014",
"0.5544324",
"0.5543917",
"0.5543872",
"0.55431724",
"0.55404335",
"0.55397487",
"0.5538874"
] | 0.0 | -1 |
GET /property_between_floor_slaps GET /property_between_floor_slaps.json | def index
@property_between_floor_slaps = PropertyBetweenFloorSlap.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | ["def set_property_between_floor_slap\n @property_between_floor_slap = PropertyBetweenFloorSlap(...TRUNCATED) | ["0.69060063","0.61157036","0.5888169","0.5649257","0.5491359","0.5422482","0.5376796","0.5331189","(...TRUNCATED) | 0.78588855 | 0 |
GET /property_between_floor_slaps/1 GET /property_between_floor_slaps/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | ["def index\n @property_between_floor_slaps = PropertyBetweenFloorSlap.all\n end","def set_prope(...TRUNCATED) | ["0.7740396","0.69099206","0.60001385","0.59754264","0.5973053","0.54860026","0.54810286","0.5468160(...TRUNCATED) | 0.0 | -1 |
End of preview. Expand
in Dataset Viewer.
No dataset card yet
- Downloads last month
- 27