query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
DELETE /imageforhomes/1 DELETE /imageforhomes/1.json
def destroy @imageforhome.destroy respond_to do |format| format.html { redirect_to imageforhomes_url, notice: 'Imageforhome was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n output = \"oneimage delete #{resource[:name]} \", self.class.login\n `#{output}`\n end", "def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n #Finds selected image\n @image = Image.find(params[:id])\n ...
[ "0.75402725", "0.74729395", "0.74680614", "0.74440664", "0.73822355", "0.73060095", "0.72856456", "0.72658706", "0.72658706", "0.72658706", "0.72658706", "0.72658706", "0.72658706", "0.7233257", "0.72328866", "0.7225285", "0.72231036", "0.72231036", "0.72231036", "0.72231036", ...
0.7373246
5
Use callbacks to share common setup or constraints between actions.
def set_imageforhome @imageforhome = Imageforhome.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def imageforhome_params params.require(:imageforhome).permit(:image_name, :description, :image) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.629...
0.0
-1
returns a textual description of the contents of the filename argument
def file(filename) check_cookie raise FFIFileMagicError, Native::magic_error(@cookie) if (result = Native::magic_file(@cookie, filename)) == nil result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_description\n @descriptive_detail.file_description\n end", "def filename\n return @args[:fname]\n end", "def file_desc\n \"Files (#{file_ext(',')})\"\n end", "def inspect\n \"File: #{@name} #{@ext}\"\n end", "def name() @filename end", "def filename\n return @args[\"fn...
[ "0.7381508", "0.7371384", "0.73641795", "0.7219316", "0.7217067", "0.7209319", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7014493", "0.7010419", ...
0.0
-1
returns a textual description of the contents of the string argument
def buffer(string) check_cookie raise FFIFileMagicError, Native::magic_error(@cookie) if (result = Native::magic_buffer(@cookie, string, string.length)) == nil result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def description(arg=nil)\n\t\t\t\tset_or_return(:description, arg, :kind_of => String)\n\t\t\tend", "def getDescription _args\n \"getDescription _args;\" \n end", "def description(arg=nil)\n set_or_return(:description, arg, :kind_of => String)\n end", "def description=(_arg0...
[ "0.736452", "0.7228621", "0.7173369", "0.6997034", "0.6997034", "0.6997034", "0.6945595", "0.672627", "0.6665593", "0.6660044", "0.6629805", "0.6602993", "0.6602993", "0.655022", "0.6544636", "0.653764", "0.65226156", "0.65226156", "0.65226156", "0.65226156", "0.6517646", "...
0.0
-1
checks the validity of entries in the colon separated database files passed in as filename
def check(filename) check_cookie Native::magic_check(@cookie, filename); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_database\n db = @database_path\n raise \"bad mode of #{db}\" unless File.world_readable?(db).nil?\n end", "def validate_import_file(data)\n\t\tbegin\n\t\t\timport_filetype_detect(data)\n\t\trescue DBImportError\n\t\t\treturn false\n\t\tend\n\t\treturn true\n\tend", "def check_file(fil...
[ "0.65670455", "0.64841056", "0.6175077", "0.6123672", "0.6111108", "0.61102784", "0.6100597", "0.60540646", "0.5980632", "0.5973574", "0.5952475", "0.5947379", "0.59438825", "0.5937843", "0.5912444", "0.5893909", "0.5829681", "0.5820112", "0.57644814", "0.57295734", "0.572944...
0.0
-1
compile the the colon separated list of database files passed in as filename
def compile(filename) check_cookie Native::magic_compile(@cookie, filename); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_blastdbs! fnames, cpus=4\n suffix = BLAST_DB_SUFFIX\n outfiles = fnames.map { |fname| fname + suffix }\n\n Parallel.each(fnames, in_processes: cpus) do |fname|\n cmd = \"diamond makedb --threads 1 --in #{fname} \" +\n \"--db #{fname}#{BLAST_DB_SUFFIX}\"\n\n Process.run_and_ti...
[ "0.5973546", "0.59536064", "0.5787073", "0.5738127", "0.56871104", "0.5652371", "0.5649693", "0.5584352", "0.5576789", "0.5561944", "0.55112416", "0.5500045", "0.54985654", "0.5497376", "0.5473765", "0.5445157", "0.54446405", "0.54435027", "0.5436382", "0.54292357", "0.536372...
0.4978246
71
closes the magic database and frees any memory allocated. if memory is a concern, use this.
def close check_cookie Native::magic_close(@cookie); @cookie = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_database\n @database = nil\n @writable_database = nil\n GC.start\n end", "def close_database\n @database = nil\n @writable_database = nil\n GC.start\n end", "def close\n @dbman.close\n @dbprot.clear\n end", "def close\n @database.c...
[ "0.79866314", "0.79866314", "0.78934795", "0.76967514", "0.76967514", "0.76115763", "0.7557412", "0.7365296", "0.73310995", "0.7139703", "0.70662695", "0.70028746", "0.69884795", "0.6962065", "0.6929257", "0.6901373", "0.675829", "0.675829", "0.675829", "0.675829", "0.6756179...
0.0
-1
Attempts to find story ID's from PR metadata.
def find_pivotal_stories(key: nil, search_title: true, search_commits: true) keys = key.kind_of?(Array) ? key.join(" |") : key story_key_regex_string = /(#{keys} )#(\d{6,})/i regexp = Regexp.new(/#{story_key_regex_string}/) matching_stories = [] if search_title github.pr_title.gs...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_story_id(text)\n find_story_ids(text).first\n end", "def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end", "def find_story_by_id(story_id)\n #TODO: navigate @project_ids and @projects array to find a project that contains the given story. \n @project_ids.each do |proj_id...
[ "0.6266594", "0.6203475", "0.59880865", "0.5539522", "0.5464059", "0.5448256", "0.543928", "0.54388094", "0.54378754", "0.54330754", "0.5432475", "0.53807044", "0.53434855", "0.52947193", "0.52632505", "0.5230398", "0.5176991", "0.51769364", "0.5165928", "0.50888014", "0.5080...
0.5855453
3
Extracts all numbers from a given string.
def extract_id(str) str.to_s.scan(/\d+/) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_numbers(str)\n str.scan(/\\d+/)\n end", "def extract_digits(string)\n string.gsub(/\\D/, '').to_i\n end", "def get_number_from_string(s)\n s.scan(/\\d/).map(&:to_i).join.to_i\nend", "def extract_multiple_numbers(str)\n return [] if str == '' || str.nil?\n str.scan(STDNUMPAT_MUL...
[ "0.8556037", "0.79588056", "0.75078106", "0.7425106", "0.72978467", "0.7227994", "0.7087201", "0.70849806", "0.7058458", "0.70441675", "0.70363206", "0.6769238", "0.67282784", "0.65771884", "0.649056", "0.64678526", "0.6452343", "0.64521813", "0.6422151", "0.64132255", "0.640...
0.62092876
32
Adds a slash at the end of the url if needed.
def ensure_url_ends_with_slash(url) return "#{url}/" unless url.end_with?("/") return url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def omit_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def without_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def slashless_url(url)\n url.chomp('/')\n end", "def force_trailing_slash\n force_slash :slash\n end", "def traili...
[ "0.736739", "0.7088262", "0.7031538", "0.6958999", "0.6923271", "0.6903882", "0.6830825", "0.67556405", "0.67013556", "0.6688781", "0.66792464", "0.65645725", "0.65207374", "0.6483492", "0.64822626", "0.6380648", "0.63593245", "0.63290673", "0.61952806", "0.6155687", "0.61066...
0.8078745
0
Creates an HTML string to post to the PR comments.
def link(href: nil, issue: nil) return "<a href='#{href}#{issue}'>#{issue}</a>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_text\n \"<p class='story-comment-text'>\" + self.text.split(\"\\n\").join(\"</p><p class='story-comment-text'>\") + \"</p>\"\n end", "def format_article_comment(comment)\n str = String.new\n date_format = '%B %d, %Y'\n unless(comment.new_record? or comment.comment_date.nil?)\n date = c...
[ "0.65572023", "0.6234751", "0.61727595", "0.6155645", "0.61076057", "0.60983473", "0.60682184", "0.60556525", "0.6039236", "0.6038487", "0.59971297", "0.5964691", "0.58974797", "0.58679414", "0.58397734", "0.58397734", "0.58196396", "0.5814993", "0.5807628", "0.5807628", "0.5...
0.0
-1
default username for this platform's ami
def username "administrator" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username\n if @username.nil?\n if os_type(:nice, :not_extended) == 'Solaris'\n @username = @platform.exec(\"/usr/ucb/whoami\").strip\n else\n @username = @platform.exec(\"whoami\").strip\n end\n end\n \n @username\n end", "def username\n self['default_rhlogin']\...
[ "0.7463755", "0.72105104", "0.71567994", "0.70248777", "0.69345987", "0.6888925", "0.68232334", "0.67616683", "0.67604846", "0.67509246", "0.66984344", "0.66596085", "0.6628307", "0.66081816", "0.65896165", "0.6570039", "0.6564236", "0.6544227", "0.6536525", "0.6519568", "0.6...
0.6732916
10
Figure out the right set of names to search for: "windows" > [nil, nil, nil] Windows_ServerR_RTM, Windows_ServerR_SP, Windows_ServerRTM, Windows_ServerSP, Windows_Server "windows2012" > [2012, 0, nil] Windows_Server2012RTM, Windows_Server2012SP "windows2012r2" > [2012, 2, nil] Windows_Server2012R2_RTM, Windows_Server20...
def image_search search = { "owner-alias" => "amazon", "name" => windows_name_filter, } search["architecture"] = architecture if architecture search end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_names(logins)\n logins.select { |x| x[0].end_with?(\"_\")}\nend", "def os_windows_2k12\n\t\t\t\t\twhere(\"os LIKE '%Windows Server 2012%'\")\n\t\t\t\tend", "def names\n platforms.map { |m| m.realname }\n end", "def os_windows_2k3\n\t\t\t\t\twhere(\"os LIKE '%Windows Server 2003%'\")\n\t\t\t\t...
[ "0.61115354", "0.58239746", "0.5786319", "0.5711915", "0.5689002", "0.5632714", "0.5487238", "0.5474504", "0.54307485", "0.53562677", "0.53486985", "0.5270642", "0.52460027", "0.5243248", "0.5221119", "0.5179798", "0.5175206", "0.5162832", "0.5161429", "0.5160704", "0.5151676...
0.0
-1
Turn windows version into [ major, revision, service_pack ] nil > [ nil, nil, nil ] 2012 > [ 2012, 0, nil ] 2012r2 > [ 2012, 2, nil ] 2012r2sp4 > [ 2012, 2, 4 ] 2012sp4 > [ 2012, 0, 4 ] 2012rtm > [ 2012, 0, 0 ] 2016 > [ 2016, 0, nil ] 2019 > [ 2019, 0, nil ] 1709 > [ 1709, 0, nil ] 1803 > [ 1803, 0, nil ]
def windows_version_parts version = self.version if version # windows-server-* -> windows-* if version.split("-", 2)[0] == "server" version = version.split("-", 2)[1] end if version =~ /^(\d+)(r\d+)?(sp\d+|rtm)?$/i ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetVersionParts(versionStr)\n version_vals = versionStr.split('-')\n major, minor, patch = version_vals[0].split('.')\n build = version_vals[1]\n return major, minor, patch, build\n end", "def deconstruct_version_string(version)\n match = version.match(/^(\\d+)\\...
[ "0.6276623", "0.62140214", "0.61852986", "0.61407435", "0.60821414", "0.6003351", "0.5983", "0.5967896", "0.5934641", "0.59234756", "0.58559686", "0.582492", "0.5807043", "0.5744371", "0.5727183", "0.5720341", "0.5703424", "0.5696688", "0.5668924", "0.5663006", "0.56520385", ...
0.8254703
0
Write a function "print_stairs(n, str)" which takes string input and an integer n and outputs a series of n strings in a geometric pattern resembling a staircase. example: print_stairs(5, "aa") => aa => aaaa => aaaaaa => aaaaaaaa => aaaaaaaaaa
def print_stairs n, str s = str; n.times {|n| puts s; s += str} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stairs(n)\n\ttext_to_print = \"\"\n\tn.times do |line|\n\t\ttext_to_print += (\" \" * (n-1)) + (\"*\" * (n-(n-1))) \n\t\ttext_to_print << \"\\n\"\n\t\tn -= 1\n\tend\n\ttext_to_print.split(\"\\n\").each{|line| puts line}\nend", "def staircase(n)\n (1..n).each { |i|\n print(\" \"*(n-i) + \"#\"*i + \"\\n\")...
[ "0.8125025", "0.726448", "0.71566844", "0.7091582", "0.7076546", "0.70094943", "0.69917303", "0.6987135", "0.69855493", "0.6846073", "0.675762", "0.661351", "0.65830314", "0.64302784", "0.64048076", "0.6330576", "0.6326213", "0.62814975", "0.6178731", "0.6164063", "0.61616284...
0.8640379
0
(3) Create a function that returns true when num1 is equal to num2; otherwise return false
def is_same_num(num1, num2) num1 == num2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amicable?(num1, num2)\n\tnum1 != num2 && proper_divisors(num1).inject(:+) == num2 && proper_divisors(num2).inject(:+) == num1\nend", "def CheckNums(num1, num2)\n\n if num2 > num1\n return true\n elsif num2 == num1\n return '-1'\n else\n return false\n end\nend", "def check_nums(num1, num2)\r\n...
[ "0.7105084", "0.7054718", "0.694795", "0.6890001", "0.68732494", "0.68002", "0.6783468", "0.674746", "0.66761506", "0.6537335", "0.6459752", "0.63697743", "0.6334353", "0.63099045", "0.6303214", "0.62982565", "0.6274551", "0.62637824", "0.62562126", "0.6255708", "0.6245802", ...
0.83128804
0
(4) Create a function that returns the product of all odd integers in an array.
def odd_product(arr) arr.filter! { |i| (i % 2 != 0) } x = arr.inject(:*) return x end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def odd_product(arr)\n product=1\n arr.each do |a|\n if a.odd?\n product=product*a\n end\n end\n return product\nend", "def odd_product(arr)\n sum = 1\n for i in arr\n if i.odd?\n sum *= i\n end\n end\n sum\nend", "def calculate_product_odd(arr)\n product = []\n arr.each { |x| x...
[ "0.84215224", "0.84032774", "0.8236971", "0.74259764", "0.74194", "0.7397541", "0.72673166", "0.7237911", "0.7190817", "0.7173074", "0.7167337", "0.7143426", "0.70973366", "0.70531666", "0.7022333", "0.7012205", "0.6992893", "0.6989264", "0.6976902", "0.69514453", "0.69479024...
0.8585168
0
(5) Create a function that takes a string and returns a string in which each character is repeated once.
def double_char(str) arr = str.split('') new_arr = [] arr.each do |i| 2.times {new_arr.push(i)} end str = new_arr.join() return str; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend", "def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend", "def repeater(string)\n string.chars.map do ...
[ "0.81611276", "0.802892", "0.7935647", "0.7911335", "0.7860838", "0.7829385", "0.770093", "0.76971865", "0.7693503", "0.76877457", "0.76877457", "0.76492995", "0.761652", "0.7609238", "0.7609238", "0.7609238", "0.7609238", "0.7609238", "0.7599146", "0.75884616", "0.75842667",...
0.0
-1
(6) Write a function that returns true if a hash contains the specified key, and false otherwise
def has_key(hash, key) hash.has_key? key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_has_key?(hash, key)\r\n hash.key?(key) # Determines if hash has key with the argument of key.\r\nend", "def has_key?(key); end", "def has_key?(key); end", "def has_key?(key)\n @hash.has_key?(key)\n end", "def includes? hash\n hash.each_pair do |key, value|\n return fals...
[ "0.8286095", "0.7889898", "0.7889898", "0.7641211", "0.75492764", "0.75405884", "0.75320226", "0.7476511", "0.74605334", "0.7447674", "0.7415264", "0.73832893", "0.73706394", "0.7300355", "0.72497594", "0.71957606", "0.71957606", "0.7188874", "0.7180452", "0.7139267", "0.7120...
0.81373346
1
(7) Computer the factorial of an integer
def factorial(int) (1..int).inject(:*) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial(number)\r\ntotal = 1\t\r\n\twhile number != 0\r\n\t\ttotal *= number\r\n\t\tnumber = number -1\r\n\tend\r\n\ttotal\r\nend", "def factorial(number)\n if number <= 1\n 1\n else\n number.downto(1).reduce(:*)\n end\nend", "def factorial(number)\n result=1\n if number == 0\n return 1\n else...
[ "0.81981844", "0.81980747", "0.81885344", "0.81789976", "0.81440574", "0.81428444", "0.8141547", "0.8123821", "0.81221247", "0.8102896", "0.80986965", "0.8098185", "0.8089133", "0.8084901", "0.80783045", "0.8077122", "0.8077122", "0.80758274", "0.8074576", "0.80697536", "0.80...
0.7935971
72
(8) Create a function that takes a string and returns the number (count) of vowels contained within it.
def count_vowels(s) p s.count('aeiou') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def VowelCount(str)\n str.count \"aeiou\" \nend", "def count_vowels(str)\n str.count(\"aeoui\")\nend", "def vowel_count(string)\n\t\n\tstring.downcase.count \"aeiou\"\n\t\nend", "def vowel_count(str)\n str.downcase.count('aeiou')\nend", "def num_vowels(str)\n str.count(VOWELS)\nend", "def num_...
[ "0.8940371", "0.8895809", "0.8844986", "0.8785566", "0.87779444", "0.8770829", "0.87431586", "0.872233", "0.86978745", "0.8654997", "0.86335284", "0.8613755", "0.8610205", "0.8597339", "0.85951006", "0.8582457", "0.8549126", "0.8521081", "0.8519452", "0.8519452", "0.85053515"...
0.86084735
13
(9) Create a function that takes an array of names and returns an array with only the first letter capitalized.
def cap_me(arr) arr.map { |i| i.capitalize} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cap_me(arr)\n arr.map(&:downcase).map(&:capitalize)\nend", "def cap_me(array)\n array.map! {|x| x.capitalize}\nend", "def capitalize_array(arr)\n arr.map {|name| name = name.capitalize}\nend", "def capitalize_array(arr_capital)\n #Empty array\n capital = []\n #iterate into how word and capitalize i...
[ "0.82867134", "0.82291913", "0.803201", "0.7714578", "0.7692055", "0.76815367", "0.75392777", "0.7215916", "0.7196896", "0.71347183", "0.7118172", "0.70906657", "0.7064951", "0.7021623", "0.69965374", "0.69956225", "0.6991669", "0.696476", "0.6941457", "0.69392884", "0.690938...
0.82983977
0
(10) Create a function that takes an array as an argument and returns true or false depending on whether the average of all elements in the array is a whole number or not.
def is_avg_whole?(arr) sum = arr.sum avg_i = sum / arr.count avg_f = sum / arr.count.to_f avg_i == avg_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_avg_whole?(arr)\n sum_of_arr = arr.inject(0) {|sum,x| sum + x }\n\treturn (sum_of_arr / arr.length.to_f)%1==0 ? true : false\nend", "def is_avg_whole?(arr)\n arr.reduce(&:+) % arr.length == 0\nend", "def average_array(array)\n array.each do |ele|\n raise \"All member must be numbers\" if !...
[ "0.8381813", "0.8177022", "0.72817165", "0.69102955", "0.69016063", "0.6808245", "0.6722183", "0.6715138", "0.671263", "0.6705991", "0.67022103", "0.6648548", "0.66384834", "0.6623003", "0.6616276", "0.6611932", "0.6593958", "0.65934503", "0.6592348", "0.6592293", "0.6576521"...
0.8412832
0
(11) A syllable is defined as a repetitive sequence containing a vowel ex: lalala contains three syllables count the syllables in a given string
def count_syllables(str) str = str.downcase arr = str.split('') sentry = arr[0] syllable = arr[0] arr.shift arr.each do |n| if n == sentry break else syllable += n end end str.scan(syllable).size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def syllable_count(word)\n word = word.downcase\n return 1 if word.length <= 3\n word.sub!(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '')\n word.sub!(/^y/, '')\n word.scan(/[aeiouy]{1,2}/).size\nend", "def syllables_in word\n word.downcase.gsub!(/[^a-z]/, '')\n\n return 1 if word.length <= 3\n ...
[ "0.82218516", "0.7851664", "0.7743124", "0.74824363", "0.7383905", "0.7245258", "0.71945554", "0.70219105", "0.69879675", "0.6588228", "0.6496219", "0.62602246", "0.6251025", "0.61571264", "0.61261946", "0.6109441", "0.6103652", "0.60791963", "0.60014665", "0.59858865", "0.59...
0.79914176
1
(12) Format a given string of ten numbers such that it resembles a phone number: (xxx) xxxxxxx
def format_phone_number(arr) phone_num = "(" 3.times {phone_num += arr.shift.to_s} phone_num += ") " 3.times {phone_num += arr.shift.to_s} phone_num += "-" 4.times {phone_num += arr.shift.to_s} phone_num end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_phone(number)\n result = number.gsub(/[^\\d]/, '')\n if result.length == 10\n \"(#{result[0..2]}) #{result[3..5]}-#{result[6..10]}\"\n else\n number\n end\n end", "def format_phone_number(num)\n num = num.delete(' ')\n return \"#{num[0..2]}-#{num[3..6]}\" if num.size == 7\n r...
[ "0.83401346", "0.82318866", "0.8145442", "0.81306946", "0.80803007", "0.80736035", "0.7984125", "0.7807689", "0.78025526", "0.7721549", "0.7688499", "0.7644156", "0.7531973", "0.7511154", "0.74903977", "0.7484726", "0.74315494", "0.7427726", "0.7381586", "0.73719805", "0.7344...
0.7499479
14
(13) Given an array of drinknames, return an array that does not contain 'cola' or 'fanta'
def skip_the_sugar(drinks) too_much = ['cola', 'fanta'] drinks.select! { |n| !too_much.include? n} drinks end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ignore_theater name\n list = ['INDRP - El Campanil Theatre - Antioch, CA',\n 'PE - El Rey Theatre - Chico, CA',\n 'Castro',\n 'INDLF',\n 'EXSV - Highland Park 3 - Highland Park, CA',\n 'CFMY - Cinefamily@The Silent Movie Theatre - Los Angeles, CA',\n 'REL - Reel Cinema - Wofford Heights, CA',\n ...
[ "0.64558613", "0.5977116", "0.5955702", "0.5754235", "0.5734422", "0.57262576", "0.5716293", "0.57141876", "0.56884825", "0.5656279", "0.56060785", "0.55831254", "0.5527149", "0.5515337", "0.5505207", "0.5494673", "0.5489639", "0.5481595", "0.54737353", "0.5461538", "0.544709...
0.71155345
0
(14) Create a function that outputs true if a number is prime, and false otherwise.
def isPrime num if num == 1 return false end stop = num - 1 (2..stop).each do |n| if (num % n) == 0 return false end end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prime?(number)\n (2...number).each do |x|\n return false if (number % x).zero?\n end\n true\n end", "def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend", "def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| ...
[ "0.8538033", "0.85047925", "0.84789205", "0.8447941", "0.8423717", "0.84229946", "0.84186155", "0.8399256", "0.8376854", "0.83680874", "0.8353648", "0.8337903", "0.83364654", "0.83233446", "0.8320792", "0.8320596", "0.8319894", "0.8317123", "0.831141", "0.8304816", "0.8303184...
0.0
-1
(15) Write a function that takes three arguments (x, y, z) and returns an array containing x subarrays (e.g. [[], [], []]), each containing y number of item z. x Number of subarrays contained within the main array. y Number of items contained within each subarray. z Item contained within each subarray.
def matrix(x, y, z) sub_array = [] y.times do sub_array.push(z); end #sub_array array = []; x.times do array.push(sub_array) end array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sub_arrays(arr)\n sub_arr = []\n i_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sub_arr << i_arr\n end\n i_arr = []\n arr.shift\n end\n sub_arr\nend", "def build_array(x, y, z)\n array = []\n array.push(x, y, z)\nend", "def multidimArray\n # fil...
[ "0.67652696", "0.6345496", "0.62079436", "0.62039006", "0.6150346", "0.61274755", "0.6105516", "0.60737646", "0.60629374", "0.6045641", "0.60191685", "0.6005431", "0.59900206", "0.59865636", "0.59553605", "0.59254414", "0.5915705", "0.5906398", "0.5900688", "0.5899516", "0.58...
0.7061395
0
(17) add the consecutive integers up and including the input. eg, add_up(5) = 16
def add_up(num) sum = 0; (1..num).each { |x| sum += x } sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_up(num)\n return (1..num).inject(:+)\nend", "def add_up(i)\n sum = 0\n for i in 1..i do\n puts sum = i + sum\n i += 1\n end\n return sum\n end", "def add_up(integer)\n x = 0\n for i in 1..integer\n x+=i\n end \n puts x\n return x\nend", "def a...
[ "0.7705821", "0.7427202", "0.7193752", "0.7083712", "0.6973179", "0.6797298", "0.6726498", "0.6724943", "0.67172647", "0.67059714", "0.66221756", "0.6615582", "0.66042507", "0.6581605", "0.6522995", "0.6464279", "0.6461476", "0.64601165", "0.6456453", "0.64436144", "0.6431604...
0.7608368
1
(18) return the smaller of two integers, but do not convert from string to integer unless necessary
def smaller_num(n1, n2) if n1.length > n2.length n2 elsif n2.length > n1.length n1 else n1.to_i > n2.to_i ? n2 : n1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_int(val1, val2)\n check_pre((\n (val1.int?) and\n (val2.int?)\n ))\n\n val1 < val2 ? val1 :val2\nend", "def min_int(in_first, in_second)\n\tcheck_pre(((in_first.int?) and (in_second.int?)))\n\t(in_first > in_second ? in_second : in_first)\nend", "def smallest_number num1, num2 \n\tif num1 ...
[ "0.7787582", "0.7683774", "0.7349217", "0.73435223", "0.71959376", "0.7126354", "0.70872873", "0.7060615", "0.7038435", "0.70367885", "0.7013115", "0.6994306", "0.6977432", "0.6943383", "0.69250673", "0.6923742", "0.6915676", "0.6910087", "0.6907312", "0.687571", "0.6837542",...
0.7324996
4
(19) return pi to n decimal places
def my_pi(n) #p Math::PI Math::PI.round(n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_pi(n)\n\treturn Math::PI.round(n)\nend", "def compute_pi(digits: 15)\n precision = digits\n result = BigMath.PI(precision)\n result = result.truncate(precision).to_s\n result = result[2..-1] # Remove '0.'\n result = result.split('e').first # Remove 'e1'\n result.insert(1, '.'...
[ "0.82051957", "0.7973697", "0.6783888", "0.6716503", "0.6577655", "0.65432525", "0.6534272", "0.65114605", "0.65026003", "0.646959", "0.6442175", "0.6310737", "0.62946427", "0.6276013", "0.62684625", "0.6244479", "0.6223754", "0.62053376", "0.61969906", "0.6130335", "0.612821...
0.7916399
2
(20) sum all even integers within a range of two numbers, the sum should be inclusive of both the first and last even number in the rangea
def sum_even_nums_in_range(start, stop) sum = 0; a = (start..stop).select { |n| n.even? } sum = a.sum sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_even_nums_in_range(start, stop)\n sum = 0\n for i in start..stop\n if i.even?\n sum += i\n end\n end\n sum\nend", "def get_sum(a,b)\n\trange = b..a\n\trange = a..b if b > a\n\trange.inject(&:+)\nend", "def get_sum(a, b)\n a < b ? (a..b).sum : (b..a).sum\nend", "def get_sum(a,b)\n a <...
[ "0.77192664", "0.7559814", "0.7349993", "0.7295423", "0.72755903", "0.7229309", "0.72271776", "0.7212565", "0.72100604", "0.7209047", "0.7202895", "0.719196", "0.71884835", "0.71859723", "0.7170204", "0.7136996", "0.7116711", "0.7101122", "0.7091347", "0.70735", "0.70703506",...
0.7846207
0
(21) find the maximum of the frist n elements of an array of numbers
def max_total(nums, n) nums.sort! nums.reverse! sum = 0; n -= 1; (0..n).each{|n| sum += nums[n]} sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_max_value(array)\nx = 0 \n array.length.times { |index|\n if array[index] > x \n x = array[index]\n end\n }\n x\n end", "def find_max_value(array)\n max_element = 0\n array.length.times { |index|\n if max_element < array[index]\n max_element = array[index]\n end\n }\n return max_element\...
[ "0.78675073", "0.7817154", "0.78015053", "0.77021456", "0.76955825", "0.7693082", "0.76790535", "0.7668098", "0.7650792", "0.76434046", "0.7640686", "0.76000375", "0.75697565", "0.75641173", "0.75221545", "0.7500557", "0.7486452", "0.7462121", "0.74393165", "0.7428096", "0.74...
0.0
-1
(22) Determine if two strings are anagrams of each other
def is_anagram(s1, s2) s1 = s1.downcase.split('').sort s2 = s2.downcase.split('').sort s1 == s2 ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def are_anagrams?( s1, s2 )\r\n\ttransformS1 = s1.downcase.split('').sort.join('')\r\n\ttransformS2 = s2.downcase.split('').sort.join('')\r\n\treturn transformS1 == transformS2\r\nend", "def anagrams_maybe_better(string1, string2)\n return true if string1.chars.sort == string2.chars.sort\n false\nend", "def ...
[ "0.8911348", "0.8871215", "0.8785012", "0.87758064", "0.87270504", "0.8717893", "0.8637356", "0.86330444", "0.8611223", "0.85432994", "0.85404384", "0.8535408", "0.85286534", "0.8491884", "0.8480144", "0.8462898", "0.84556216", "0.8447709", "0.84440506", "0.8411218", "0.83926...
0.8250027
40
(23) Determine if all numbers in an array are even and return true or false
def checkAllEven(arr) return arr.all?{|num| num.even?} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_odd?(array)\n\t\n\tif array.all? {|i| i % 2 != 0} \n\t puts \"true\"\n else\n \tputs \"false\"\n end\nend", "def all_numbers_even?(nums)\n nums.all { |num| num.even? }\n end", "def all_numbers_even?(nums)\n nums.each do |num|\n return false if num % 2 != 0\n end\n\n true...
[ "0.849972", "0.8367152", "0.82246184", "0.82147545", "0.8197097", "0.8152936", "0.80778", "0.80303633", "0.7941686", "0.7656763", "0.75743246", "0.7430807", "0.73659486", "0.73289037", "0.7285958", "0.7283722", "0.7266685", "0.7248387", "0.72250867", "0.71968937", "0.7158306"...
0.8564488
0
(24) Sum the absolute values of the elements in an array
def get_abs_sum(arr) sum = 0; arr.each { |n| sum += n.abs} sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def abs_sum()\n self.abs().sum()\n end", "def positive_sum(arr)\r\n sum = 0\r\n arr.each do |number|\r\n if number > 0\r\n sum += number\r\n end\r\n end\r\n sum\r\n end", "def array_sum(arr)\n return arr.reduce(0, :+)\nend", "def array_sum(arr)\n arr.reduce(0, :+)\...
[ "0.7669547", "0.71546423", "0.69505674", "0.6935507", "0.6935507", "0.6935507", "0.68970996", "0.68838155", "0.68785775", "0.68420047", "0.68375593", "0.6837186", "0.6832365", "0.682119", "0.6814339", "0.6789899", "0.67867255", "0.67740154", "0.67733026", "0.6765864", "0.6765...
0.85072196
0
(25) return "true" if "Frodo" and "Sam" are adjacent elements in a string array
def middle_earth(arr) #arr = arr.sort start = 0 finish = arr.length - 2 truthy = false (start..finish).each do |n| if (arr[n] == "Frodo" and arr[n + 1] == "Sam") truthy = true end if (arr[n] == "Sam" and arr[n + 1] == "Frodo") truthy = true end end truthy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arr_in_phrase? (arr, string)\n\t#might be unefficient to recreate the reg each time, maybe better to return a regex?\n\treg = arr.map {|str| Regexp.escape(str)}\n\treg = /#{arr.join(\"|\")}/ \n\treturn reg === string\nend", "def mutation(array)\n p first_word = array[0].downcase.chars.sort.join(\" \")\n p ...
[ "0.7077255", "0.67894506", "0.67463255", "0.6720778", "0.6685911", "0.6683571", "0.6671175", "0.6651469", "0.65749085", "0.65593714", "0.6535667", "0.6535479", "0.6518655", "0.65066946", "0.65061915", "0.64853513", "0.6465754", "0.6441488", "0.6437051", "0.6434132", "0.640752...
0.65625185
9
(26) Create a function that takes a string as the first argument, and a (string) specification as a second argument. If the specification is "word", return a string with each word reversed while maintaining their original order. If the specification is "sentence", reverse the order of the words in the string, while kee...
def flip(str, spec) if spec == 'word' s = str.split(' ') #split str into words s1 = [] s.each {|n| s1.push(n.reverse)} s1.join ' ' elsif spec == 'sentence' s = str.split(' ') #split str into words s1 = [] s.each {|n| s1.unshift(n)} s1.join ' ' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_sentence(my_sentence)\r\n reverse_words(my_sentence)\r\n string_reverse(my_sentence)\r\nend", "def reverse_sentence(my_sentence)\r\n my_sentence = reverse_words(my_sentence)\r\n my_sentence = string_reverse(my_sentence)\r\nend", "def reverse_sentence(sentence)\n p sentence # String ...
[ "0.7949166", "0.7720206", "0.7400787", "0.7354036", "0.7328533", "0.7299188", "0.7291899", "0.7268181", "0.72231567", "0.72231567", "0.72114956", "0.72067976", "0.719029", "0.71831864", "0.71831155", "0.7177657", "0.7177344", "0.71692115", "0.7154385", "0.71501064", "0.714518...
0.76220185
2
(27) Create a function that returns the minimum number of removals to make the sum of all elements in an array even.
def minimum_removals(arr) sum = 0; arr.each {|n| sum += n} if sum.even? return 0 end count = 0; if sum.odd? arr.each do |n| if n.odd? count += 1 end end end if count == arr.length nil else 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_2_sum(array)\n res= array.max.to_i\n (array.delete(array.max))\n res+=array.max.to_i\nend", "def sum_not_two(arr)\n arr.reduce(0) { |accum, num| num != 2 ? accum += num : accum }\nend", "def max_2_sum arr\n return 0 if arr.empty?\n return arr.first if arr.size == 1\n arr.sort.pop(2).inject(:+)\n...
[ "0.6701789", "0.6594748", "0.65388715", "0.65118676", "0.65014243", "0.6477915", "0.6466223", "0.64556134", "0.64552814", "0.64341694", "0.6420873", "0.6397287", "0.6355857", "0.63491553", "0.63366854", "0.6323005", "0.63130236", "0.63052315", "0.62950295", "0.6294639", "0.62...
0.78238183
0
(28) Create a function that takes in year and month as input, then return what year it would be after nmonths has elapsed.
def after_n_months(year, month) if year == nil "year missing" elsif month == nil "month missing" else (year + month/12).to_i end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def years_to_months(years)\n #some code here\nend", "def get_months(years, months)\n if years > 0\n (years * 12) + months\n elsif years > 0 && months == 0\n years * 12\n else\n months\n end\nend", "def months_in_year\n 12\nend", "def years_to_month(years)\n years * 12.0\nend", "def a_year()...
[ "0.7488566", "0.73822093", "0.7346129", "0.733507", "0.7073715", "0.6968967", "0.68535954", "0.67401266", "0.671508", "0.6704383", "0.66883165", "0.66880435", "0.6657084", "0.65948755", "0.6523761", "0.65138996", "0.65120775", "0.6473546", "0.64722836", "0.64687943", "0.64424...
0.75501937
0
(29) Create a function that takes two strings as arguments and returns the number of times the first string (the single character) is found in the second string.
def char_count(str1, str2) s = str2.split('').select {|n| n == str1} s.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def char_count(str1, str2)\n\treturn str2.scan(str1).count\nend", "def find_number_of_first_chars(string1=\"First string\", string2=\"Second string\")\n arr1 = string1.split('')\n arr2 = string2.split('')\n counter = 0\n arr1.each_with_index do |el, i|\n if arr1[i] == arr2[i]\n counter +=1\n els...
[ "0.8073293", "0.79303974", "0.77641374", "0.7698311", "0.7644411", "0.7548408", "0.74377835", "0.7354016", "0.7338575", "0.7254047", "0.72316915", "0.72163767", "0.72072893", "0.72034055", "0.71874917", "0.7165895", "0.7153749", "0.71445495", "0.7144119", "0.7140212", "0.7130...
0.82767445
0
(30) Per 6 coffee cups I buy, I get a 7th cup free. In total, I get 7 cups. Create a function that takes n cups bought and return the total number of cups I would get.
def total_cups(n) total = (n / 6).to_i + n end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chocolateFeast(n, c, m)\n answer = 0\n purchase = n / c \n answer += purchase\n free = purchase / m\n \n while free > 0 do\n answer += free\n wrappers = free * m\n purchase -= wrappers\n purchase += free\n free = purchase / m\n end\n answer\nend", "...
[ "0.6861946", "0.68168706", "0.6668243", "0.6612732", "0.6601187", "0.6557592", "0.6502474", "0.6480434", "0.6409265", "0.6386579", "0.6384019", "0.63837224", "0.6360633", "0.6298308", "0.6296754", "0.62793773", "0.6263867", "0.62508494", "0.6247709", "0.62264776", "0.6224705"...
0.8125063
0
(31) A number is narcissistic when the sum of its digits, with each digit raised to the power of digits quantity, is equal to the number itself.
def is_narc n x = n.to_s.split('') x = x.map { |x| x.to_i } exp = x.length #p exp x = x.map { |x| x**exp } x = x.sum x == n ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def narcissistic?(num)\n digits = num.to_s.chars.map(&:to_i)\n pwrs = digits.map! { |digit| digit**digits.size }\n pwrs.reduce(:+) == num\nend", "def armstrong? num\n n = num.length\n num.chars.inject(0) { |sum,d| sum + (d.to_i ** n) } == num.to_i\nend", "def number_joy(n)\na = n.to_s.chars.map(&:to_i).re...
[ "0.7334684", "0.7148773", "0.70699686", "0.7026815", "0.69994074", "0.68992364", "0.68564874", "0.6840071", "0.68177867", "0.6785127", "0.67845356", "0.6754737", "0.6674602", "0.66626954", "0.66507006", "0.66368204", "0.66335124", "0.66213065", "0.6612913", "0.65933794", "0.6...
0.6713643
12
(32) counts the number of 1's in a 2d matrix
def count_ones(matrix) count = 0; matrix.each do |sub_matrix| sub_matrix.each {|x| x == 1 ? count += 1 : nil} end count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_islands(matrix)\n rows = matrix.length\n cols = matrix[0].length\n visited = Array.new(rows) { Array.new(cols) }\n\n # Initialize count as 0 and traverse through all\n # cells of the given matrix\n count = 0\n (0...rows).each do |row|\n (0...cols).each do |col|\n\n # If a cell with a true ...
[ "0.705422", "0.7031569", "0.7012102", "0.6958668", "0.6947563", "0.68933904", "0.6562036", "0.6552943", "0.6552916", "0.6503522", "0.6460473", "0.6309006", "0.6300222", "0.62879014", "0.6277695", "0.6219949", "0.617729", "0.61683995", "0.61542344", "0.6136015", "0.61114454", ...
0.83974904
0
(33) Create a function that takes a string and returns true or false, depending on whether the characters are in order or not.
def is_in_order(str) str = str.split '' x = str[0].ord str.shift str.each do |c| if x > c.ord return false else x = c.ord end end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alphabetical_order?(word)\n (0..word.length-2).each { |num| return false if word[num] > word[num+1] }\n true\nend", "def alphabetic(s)\n s.chars.sort.join == s\nend", "def ordered_word? (str)\n i = 0\n while i < str.size - 1\n if str[i] > str[i+1]\n return false\n else\n i += 1\n en...
[ "0.73206896", "0.7084697", "0.703287", "0.69916356", "0.68738306", "0.6867272", "0.6827388", "0.6819577", "0.681004", "0.67679065", "0.6721452", "0.67064166", "0.66765845", "0.66709787", "0.6662576", "0.6634804", "0.66252345", "0.6619326", "0.6589085", "0.6557473", "0.6549905...
0.7817401
0
(34) Your job is to make a "Twitter link" regular expression rx.
def tweet(str) arr = [] scans = str.scan(/(@\w+)|(#\w+)/) scans.each do |x| x.each do |y| if y arr.push y end end end arr.join ' ' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_regexp_TIDYLINK target\n text = target.text\n\n return text unless text =~ /\\{(.*?)\\}\\[(.*?)\\]/ or text =~ /(\\S+)\\[(.*?)\\]/\n\n $1\n end", "def parse_tweet(t)\n URI.extract(t, %w[ http https ftp ]).each do |url|\n t.gsub!(url, \"<a href=\\\"#{url}\\\">#{url}</a>\")\n end\n ...
[ "0.6365935", "0.62515354", "0.62512857", "0.6232892", "0.61925966", "0.61519164", "0.6031789", "0.6030534", "0.60302496", "0.6017679", "0.5995135", "0.59759194", "0.5953798", "0.5923417", "0.5879851", "0.5844218", "0.57812256", "0.5779047", "0.56832975", "0.56676024", "0.5667...
0.53229886
50
(36) Given two integers, a and b, return true if a can be divided evenly by b. Return false otherwise. Notice how the ternary operator is used: no "if" is required since the mod returns a value
def divides_evenly(a, b) a % b == 0 ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def divides?(a,b)\n return b%a == 0\nend", "def divisable_by_given?(number, given)\n number % given == 0\n end", "def divisible_by(number, div_by)\n number % div_by == 0\nend", "def divisible_by number, divisor\n number % divisor == 0\n end", "def my_remainder(a, b)\n\treturn nil if a ...
[ "0.7941517", "0.75311244", "0.74645656", "0.7448812", "0.73222303", "0.7303778", "0.7277336", "0.72635376", "0.7225537", "0.7218359", "0.7212246", "0.72012573", "0.7168474", "0.714607", "0.71269953", "0.7124062", "0.712176", "0.711491", "0.7106626", "0.7076236", "0.7057519", ...
0.8445875
0
(37) Create a function that takes two arguments (item, times). The first argument (item) is the item that needs repeating while the second argument is the number of times the item is to be repeated. Notices that "times" is a method of integers as well as a variable name.
def repeat(item, times) return_array = [] times.times { return_array.push(item) } return_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeat(item, times)\n\tarr = []; arr += [item] * times; return arr\nend", "def repeater(repeats=1, &proc)\n repeats.times {proc.call}\nend", "def times(*args)\n\t\t\t\t\trepeat *args\n\t\t\t\tend", "def repeat(param_integer, param_string)\n param_integer.times do\n puts \"param_string\"\n end\nend"...
[ "0.7646676", "0.7519726", "0.7306261", "0.72091883", "0.7103786", "0.7053177", "0.7037975", "0.7031681", "0.69922614", "0.699031", "0.6988218", "0.69567955", "0.69540554", "0.69363075", "0.6897765", "0.68627244", "0.68584394", "0.68487716", "0.68391114", "0.6835518", "0.68355...
0.77294123
0
(38) A number is narcissistic when the sum of its digits, with each digit raised to the power of digits quantity, is equal to the number itself. Given a positive integer n, implement a function that returns true if the number is narcissistic, and false if it's not.
def is_narcissistic(n) list = n.to_s.split '' power = list.length list.map! {|x| x.to_i} sum = list.inject(0) { |sum, x| sum += x ** power} sum == n ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def narcissistic?(num)\n digits = num.to_s.chars.map(&:to_i)\n pwrs = digits.map! { |digit| digit**digits.size }\n pwrs.reduce(:+) == num\nend", "def narcissistic?(value)\n digit_count = value.digits.length\n return value == value.digits.map! { |d| d**digit_count }.reduce(:+)\nend", "def is_narc n\n ...
[ "0.82723564", "0.78811514", "0.7562135", "0.7448966", "0.73480415", "0.73015016", "0.7235045", "0.7156148", "0.714919", "0.6952047", "0.6907301", "0.68977314", "0.68881947", "0.68801033", "0.6855106", "0.6836222", "0.68144673", "0.68099207", "0.67973936", "0.67929846", "0.678...
0.84836924
0
(39) In this challenge, you have to establish if a number is apocalyptic. A positive integer n greater than 0 is apocalyptic when 2 elevated to n contains one or more occurrences of 666 into it. Given an integer n, implement a function that returns: "Safe" if n is not apocalyptic. "Single" if into 2^n there's a single ...
def is_apocalyptic(number) num_str = (2**number).to_s array_of_instances = num_str.scan /666/ times = array_of_instances.length case times when 0 "Safe" when 1 "Single" when 2 "Double" when 3 "Triple" else "Fucked" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_abundant?(n)\n return false if n<2\n\n s = 1\n 2.upto(Math.sqrt(n).to_i) do |i|\n if ((n % i) == 0 )\n s += i\n s += (n/i) unless (n/i == i)\n\n return true if s > n\n end\n end\n return false\nend", "def narcissistic?(num)\n digits = num.to_s.chars.map(&:to_i)\n pwrs = digits....
[ "0.7271772", "0.70082885", "0.69954526", "0.6978554", "0.69523644", "0.69201607", "0.689775", "0.689775", "0.6846852", "0.682473", "0.6814209", "0.6766354", "0.6765182", "0.67534685", "0.67236483", "0.6656727", "0.6632007", "0.66241086", "0.6607041", "0.6603829", "0.6602041",...
0.74913013
0
(40) Write a function to reverse an array.
def reverse(arr) output = [] arr.reverse_each {|x| output.push x} output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_array(array)\n\tarray.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(arr)\n arr.reverse\nend", "def rever...
[ "0.8749987", "0.8743192", "0.8743192", "0.8743192", "0.8735059", "0.87228364", "0.87161636", "0.8702231", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", "0.8680624", ...
0.0
-1
(43) Remove duplicates from array
def remove_dups(arr) new_arr = [] arr.each do |x| unless new_arr.include? x new_arr.push x end end new_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_duplicates(array)\nend", "def remove_dups(arr)\n\treturn arr.uniq()\nend", "def remove_duplicates(array)\n uniq_array = []\n array.each {|value| uniq_array << value unless uniq_array.include?(value) }\n return uniq_array\nend", "def array_uniq!(a)\n a.uniq!\n end", "def duplic...
[ "0.8789905", "0.8537292", "0.82753223", "0.8044745", "0.8035307", "0.79906636", "0.7892266", "0.7873166", "0.78689617", "0.7830392", "0.7823365", "0.7771789", "0.7732712", "0.7731776", "0.7729469", "0.769468", "0.76862806", "0.7673823", "0.7673823", "0.7664172", "0.76503205",...
0.8203045
3
(50) Implement a function that returns an array containing all the consecutive numbers in ascendant order from the given value low up to the given value high (bounds included).
def get_sequence(low, high) (low..high).to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeArrayConsecutive2(statues)\n max_value = statues.max\n min_value = statues.min\n result_array = []\n\n if min_value == max_value\n 0\n else\n for i in range(min_value, max_value)\n result_array.append(i)\n end\n end\n result_array.size - statues.size\nend", "def range(min, max) # tak...
[ "0.719795", "0.68956715", "0.68344826", "0.678634", "0.6760763", "0.67538184", "0.6714378", "0.6680341", "0.66673553", "0.6665418", "0.6657258", "0.66444343", "0.662774", "0.65932363", "0.6590746", "0.65656525", "0.6563546", "0.65623647", "0.6534452", "0.6527117", "0.6518639"...
0.77980715
0
INIT WITH NO JOURNEY
def initialize(journey_class = nil) @journey_class = journey_class @journeys = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init\n end", "def init\n end", "def init\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize(uri)\n @uri = uri\n# create_database_if_missing!\n end", "def initialize\n # Create temporary data directory\n create_data_dir\n\n ...
[ "0.6774775", "0.6774775", "0.6774775", "0.6762228", "0.6762228", "0.6762228", "0.6762228", "0.67426115", "0.6629637", "0.65490586", "0.653938", "0.6513553", "0.651051", "0.64550257", "0.64550257", "0.64550257", "0.6385739", "0.6385606", "0.6375136", "0.6375136", "0.6368119", ...
0.0
-1
START JOURNEY AND FINISH JOURNEY
def start(entry_station, zone) @journey_class = Journey.new(entry_station, zone) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n start\n jetty.join\n end", "def begin!\n start_server\n end", "def start\n _connect\n sleep 1\n end", "def start_run; end", "def start()\n\n\t\tend", "def autostart; end", "def startRun\n db_cached_connect\n\n @dbh.do(\"BEGIN TRANSACTION;\")\n @dbh.do(\"SE...
[ "0.65445566", "0.62825525", "0.60970443", "0.6014099", "0.59179235", "0.59078294", "0.58906615", "0.5890306", "0.587448", "0.58554566", "0.58543986", "0.5803951", "0.5793123", "0.57893634", "0.5742588", "0.5738365", "0.5713303", "0.5713303", "0.5713303", "0.5713303", "0.57133...
0.0
-1
Checks if journey already exists; creates standin to allow for penalty when no touch in.
def current_journey @journey_class ||= Journey.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def touch_in(station, journey = Journey.new)\n raise 'Balance is insuffcient' if insufficient?\n @current_journey = journey\n @current_journey.add_entry_journey(station)\n end", "def start_journey(station)\n raise 'Already in journey' if in_journey?\n @journey = @journey_class.new(station)\n s...
[ "0.6234312", "0.62289953", "0.6082653", "0.6021983", "0.5842537", "0.5831981", "0.5725486", "0.569016", "0.567064", "0.5598749", "0.5584471", "0.5558336", "0.5530986", "0.5505412", "0.53845346", "0.53744125", "0.5373188", "0.53599185", "0.53361475", "0.5335485", "0.53306955",...
0.4845848
67
Creates a new Source
def initialize(config) @config = config @matchers = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @source = Source.new\n\n end", "def create\n @source = Source.new\n create_or_update\n end", "def create name, object_type, config={}\n klass = @@sources[[name, object_type]]\n raise \"No Source registered with name #{name} and type #{object_type}.\" unless klass\n klass.new...
[ "0.797678", "0.7307123", "0.7089442", "0.6983186", "0.68556374", "0.68556374", "0.6836732", "0.68185294", "0.68068606", "0.66301584", "0.6629992", "0.66087884", "0.6466745", "0.6436294", "0.64304084", "0.63824975", "0.6355941", "0.63434994", "0.63277584", "0.62082314", "0.618...
0.0
-1
Collects or generates metrics and returns a potentially updated metrics map.
def collect(metrics) metrics end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metrics\n @metrics ||= collect_metrics\n end", "def collect(metrics)\n metrics[:polled_total] = rand(100)\n metrics\n end", "def collect_metrics(*)\n raise NotImplementedError, 'Must implement collect_metrics'\n end", "def build_metrics\n {}\n end", "def m...
[ "0.7444272", "0.636709", "0.63530195", "0.63264483", "0.6276773", "0.62216985", "0.61358964", "0.605267", "0.60263896", "0.60263896", "0.59445894", "0.5900837", "0.5855013", "0.582906", "0.5817395", "0.5815917", "0.57855916", "0.57724386", "0.5696201", "0.56838435", "0.564034...
0.70655346
1
Declares a matcher for a single line of input.
def match(pattern, options={}, &block) raise "pattern must be provided" if pattern.nil? commands = 0 commands += 1 if options[:record] commands += 1 if block_given? raise "Must specify :record or provide a block to execute" if commands == 0 raise "Only one of :record or a block should be provid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match(line)\n regex = self.to_regexp\n regex.match(line.value)\n end", "def has(line, opt = {})\n @matchers << [line, opt]\n end", "def valid_line_for line, regexp\n @has_id_col = nil\n @line_id = nil\n return nil unless line_match = line.match(regexp)\n return nil if @o...
[ "0.68971825", "0.6430498", "0.6361582", "0.62419826", "0.6158691", "0.6123593", "0.6103177", "0.6064089", "0.6049597", "0.6049597", "0.60354334", "0.59791017", "0.5933727", "0.5873101", "0.58633757", "0.5853575", "0.5817466", "0.5816174", "0.57863134", "0.57811856", "0.577002...
0.0
-1
Method to create a new datarow in Transporttable
def create_transports @transport = Transport.new(strong_params_transports) @transport.value = calculate_transport_emissions @transport.user = @user @transport.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_row(options = nil)\n require_relative 'datarow'\n DataRow.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/rows\", options))\n end", "def create(data_={})\n Table.new(self, data_)\n end", "def init_row_by_id(id)\n require_relative 'datarow'\n return...
[ "0.6611977", "0.64781106", "0.63709176", "0.63423157", "0.6161357", "0.61395496", "0.5816652", "0.58035976", "0.5768249", "0.56977147", "0.56886077", "0.5686057", "0.56845975", "0.5678681", "0.5677715", "0.56711006", "0.566822", "0.56109303", "0.55657715", "0.5537211", "0.552...
0.0
-1
Method to create a new datarow in Foodtable
def create_foods @food = Food.new(strong_params_foods) @food.value = calculate_emissions @food.user = @user @food.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_basic_food(row)\n BasicFood.new(row[0], row[2])\n end", "def create(data_={})\n Table.new(self, data_)\n end", "def create_row(options = nil)\n require_relative 'datarow'\n DataRow.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/rows\", options))\n end", "...
[ "0.7088662", "0.66724384", "0.6311719", "0.61996907", "0.6122831", "0.59594893", "0.5918735", "0.59055567", "0.5902916", "0.5737812", "0.571014", "0.5703518", "0.56989765", "0.5659012", "0.5659012", "0.5646104", "0.56407547", "0.5608881", "0.560419", "0.5593646", "0.55872685"...
0.0
-1
Method to create a new datarow in Housingtable
def create_housings @housing = Housing.new(strong_params_housing) @housing.value = calculate_housing_emissions @housing.user = @user @housing.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(data_={})\n Table.new(self, data_)\n end", "def create_row(options = nil)\n require_relative 'datarow'\n DataRow.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/rows\", options))\n end", "def make_table(options={})\n get_table(options).rows\n end", "def ro...
[ "0.67190814", "0.6473672", "0.6460823", "0.6441574", "0.64360946", "0.6415268", "0.6326261", "0.6315543", "0.628707", "0.61273193", "0.6095636", "0.6028135", "0.60233045", "0.5976083", "0.59259105", "0.5900301", "0.58824444", "0.5866044", "0.5865787", "0.58618885", "0.5808729...
0.0
-1
Method to create a new datarow in Housingtable
def create_showers @shower = Shower.new(strong_params_shower) @shower.value = calculate_shower_emissions @shower.user = @user @shower.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(data_={})\n Table.new(self, data_)\n end", "def create_row(options = nil)\n require_relative 'datarow'\n DataRow.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/rows\", options))\n end", "def make_table(options={})\n get_table(options).rows\n end", "def ro...
[ "0.6721781", "0.6472653", "0.64619267", "0.64410925", "0.6435822", "0.6414872", "0.6327177", "0.63170594", "0.6289995", "0.61296266", "0.60975057", "0.602941", "0.6021596", "0.59795696", "0.59263855", "0.5898869", "0.5881011", "0.58662724", "0.5864894", "0.5863105", "0.581085...
0.0
-1
TODO: Create method to erase file from remote host on destroy
def extract_preview_img #strings needed for readability attach_name = "preview.png" # the file name in the zip and when on the server zip_name = self.zip.instance[:zip_file_name] # full remote path/ name.zip img_path = zip_name.chomp(".zip") + "/preview.png" # full path within zip to image zip_dir =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove!\n FileUtils.rm(File.join(remote_path, remote_file))\n end", "def remove!\n begin\n connection.sync_clock\n connection.delete_object(bucket, File.join(remote_path, remote_file))\n rescue Excon::Errors::SocketError; end\n end", "def destroy(remote_path...
[ "0.7770388", "0.7630072", "0.76202095", "0.7584982", "0.71500736", "0.71339005", "0.71022177", "0.69655067", "0.68909514", "0.688678", "0.6852819", "0.6834942", "0.6834942", "0.68113655", "0.68113655", "0.676534", "0.6763154", "0.672579", "0.67052835", "0.66118556", "0.657632...
0.0
-1
The below method look for the associated course bbefore deleting the record record can be deleted only when the assocoated course tranfered to other coach
def destroy coach = Coach.find_by(id: params[:id]) if coach.course.present? course_transfered, course = coach.transfer_coach if course_transfered coach.delete render json: { status: :ok, message: 'successfully deleted the coach and tranfered the course', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_student(person)\n c = CoursePerson.first(:person_id => person.id, :course_id => self.id)\n # puts c.inspect\n if c \n c.destroy!\n self.save\n else\n puts \"wasn't a member\"\n end \n end", "def deleteTA\n\tTeachingAssistant.where(...
[ "0.6407051", "0.6132879", "0.610357", "0.6007764", "0.5999285", "0.5925484", "0.5915208", "0.5875393", "0.58570504", "0.5832204", "0.58230007", "0.5814851", "0.58131874", "0.57920456", "0.579159", "0.5779882", "0.57779115", "0.57586884", "0.57464564", "0.5731642", "0.57049346...
0.6743538
0
Returns inbound guidance for a list of items by Seller SKU
def get_inbound_guidance_for_sku(marketplace_id, *seller_sku_list) operation('GetInboundGuidanceForSKU') .add('MarketplaceId' => marketplace_id, 'SellerSKUList' => seller_sku_list) .structure!('SellerSKUList', 'Id') run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_skus\n line_items.map(&:sku).join(', ')\n end", "def sku\n item_hash.deep_find(:sku)\n end", "def get_sku_sales(sku_item)\n total_sales = []\n sku_values = @rows.values_at(\"sku\").flatten\n amount_values = @rows.values_at(\"amount\").flatten\n sku_values.each_with_inde...
[ "0.65951246", "0.6194691", "0.61129045", "0.6082215", "0.6032899", "0.595831", "0.59425443", "0.5931448", "0.5894216", "0.5840219", "0.57371426", "0.5602261", "0.5582085", "0.5505609", "0.54972285", "0.5476877", "0.54331297", "0.54312336", "0.5417212", "0.54036915", "0.539051...
0.7489573
0
Returns inbound guidance for a list of items by ASIN
def get_inbound_guidance_for_asin(marketplace_id, *asin_list) operation('GetInboundGuidanceForASIN') .add('MarketplaceId' => marketplace_id, 'ASINList' => asin_list) .structure!('ASINList', 'Id') run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_inbound_guidance_for_sku(marketplace_id, *seller_sku_list)\n operation('GetInboundGuidanceForSKU')\n .add('MarketplaceId' => marketplace_id,\n 'SellerSKUList' => seller_sku_list)\n .structure!('SellerSKUList', 'Id')\n\n run\n end", "def asin\n @as...
[ "0.5831807", "0.57005894", "0.568102", "0.5648384", "0.5640575", "0.54893374", "0.5474378", "0.53129077", "0.5285715", "0.52685773", "0.51527417", "0.5071194", "0.5063217", "0.50462484", "0.49896228", "0.49621093", "0.49239984", "0.49116164", "0.48922536", "0.4860149", "0.485...
0.7393351
0
Returns the information required to create an inbound shipment
def create_inbound_shipment_plan(ship_from_address, inbound_shipment_plan_request_items, opts = {}) operation('CreateInboundShipmentPlan') .add(opts) .add('ShipFromAddress' => ship_from_address, 'Inb...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n shipment_args = params[:shipment].clone\n \n Shipment.prepare_industry(shipment_args)\n \n # unless Industry.exists?(shipment_args[:industry_id])\n # shipment_args[:new_industry_name] = shipment_args[:industry_id]\n # shipment_args[:industry_id] = nil\n # end\n\n shipmen...
[ "0.62293726", "0.6229127", "0.61933064", "0.6185962", "0.6152349", "0.6077906", "0.606477", "0.60386956", "0.60301846", "0.6021545", "0.60075426", "0.59654635", "0.59628636", "0.5942216", "0.5936025", "0.5924897", "0.58976036", "0.58839023", "0.58650714", "0.5857762", "0.5842...
0.5495344
75
Creates an inbound shipment
def create_inbound_shipment(shipment_id, inbound_shipment_header, inbound_shipment_items) build_inbound_shipment_operation('CreateInboundShipment', shipment_id, inbound_shipment_header, inbound_sh...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_inbound_shipment_plan(ship_from_address,\n inbound_shipment_plan_request_items,\n opts = {})\n operation('CreateInboundShipmentPlan')\n .add(opts)\n .add('ShipFromAddress' => ship_from_address,\n ...
[ "0.6869611", "0.6504866", "0.63890433", "0.6364285", "0.6241653", "0.6233789", "0.62320286", "0.60672253", "0.5964523", "0.5964342", "0.59629273", "0.5928589", "0.59263426", "0.5902573", "0.58799756", "0.58695835", "0.5867557", "0.585748", "0.58331144", "0.58331144", "0.58205...
0.7451501
0
Updates an existing inbound shipment
def update_inbound_shipment(shipment_id, inbound_shipment_header, inbound_shipment_items) build_inbound_shipment_operation('UpdateInboundShipment', shipment_id, inbound_shipment_header, inbound_sh...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @inventorship = Inventorship.find(params[:id])\n\n respond_to do |format|\n if @inventorship.update_attributes(params[:inventorship])\n flash[:notice] = 'Inventorship was successfully updated.'\n format.html { redirect_to(@inventorship) }\n format.xml { head :ok }\n ...
[ "0.67313176", "0.6651427", "0.66141415", "0.65837073", "0.65281117", "0.6504508", "0.6496533", "0.6488609", "0.6432114", "0.6428948", "0.6414026", "0.6390927", "0.6378845", "0.6361273", "0.6356554", "0.6349952", "0.6335999", "0.6335486", "0.6335486", "0.63300836", "0.6309473"...
0.74951106
0
Returns preorder information, including dates
def get_preorder_info(shipment_id) operation('GetPreorderInfo') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre\n @pre ||= _to_a[3]\n end", "def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end", "def pre_order_traversal(tree=root, ordering=[])\n end", "def back_order_date\n hash[\"BackOrderDate\...
[ "0.57939076", "0.5766239", "0.576585", "0.5721952", "0.5716685", "0.5703587", "0.56846553", "0.5678171", "0.56757104", "0.5671222", "0.5668389", "0.56679004", "0.5662854", "0.5647682", "0.5623722", "0.56111115", "0.5601981", "0.55901945", "0.5560099", "0.5558246", "0.5558246"...
0.6007398
0
Confirms a shipment for preorder
def confirm_preorder(shipment_id, need_by_date) operation('ConfirmPreorder') .add('ShipmentId' => shipment_id, 'NeedByDate' => need_by_date) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order_shipped\n @order = order\n\n mail :to => \"sandra_sovane@inbox.lv\", :subject => 'Pragmatic Store Order Shipped'\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, ...
[ "0.68605196", "0.6852809", "0.6818658", "0.6716836", "0.669913", "0.6675757", "0.6649557", "0.6634516", "0.6629863", "0.66288364", "0.66186196", "0.66163576", "0.65995646", "0.6583613", "0.6577752", "0.65764844", "0.65598136", "0.6546157", "0.6542449", "0.6527633", "0.6503271...
0.70892376
0
Returns labeling requirements and item preparation instructions to help you prepare items for an inbound shipment
def get_prep_instructions_for_sku(ship_to_country_code, *seller_sku_list) operation('GetPrepInstructionsForSKU') .add('SellerSKUList' => seller_sku_list, 'ShipToCountryCode' => ship_to_country_code) .structure!('SellerSKUList', 'Id') run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_delivery_instructions(input)\n begin\n incorrect_input = check_for_incorrect_input(input)\n\n # return early if there is incorrect input\n if (!incorrect_input.nil? && incorrect_input.gsub(\" \", \"\").length > 0)\n return \"Input contained the following incorrect items: #{incorrect_input}...
[ "0.56513536", "0.56323314", "0.5601904", "0.5479336", "0.53744674", "0.53728503", "0.53228843", "0.52602226", "0.52444273", "0.522555", "0.52166724", "0.52065474", "0.51737255", "0.51724905", "0.51642334", "0.5145767", "0.5121038", "0.5085908", "0.5081766", "0.5075753", "0.50...
0.51921487
12
Returns item preparation instructions to help with item sourcing decisions
def get_prep_instructions_for_asin(ship_to_country_code, *asin_list) operation('GetPrepInstructionsForASIN') .add('ASINList' => asin_list, 'ShipToCountryCode' => ship_to_country_code) .structure!('ASINList', 'Id') run # Work around a bug upstream # #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare(item)\n stringify_on_conflict_hash(item)\n add_lock_type(item)\n add_lock_timeout(item)\n add_lock_ttl(item)\n add_digest(item)\n end", "def prepare(preparers)\n preparers.each do |prepaper|\n case prepaper\n when Mechanic\n prepaper.prepare_bicycles(bi...
[ "0.58837813", "0.5806885", "0.5792909", "0.57662904", "0.5639067", "0.5612603", "0.5556818", "0.5548487", "0.5548487", "0.5516017", "0.5476062", "0.54524416", "0.54417443", "0.5375112", "0.5372782", "0.53381294", "0.5321367", "0.5309063", "0.53068346", "0.52969205", "0.528849...
0.0
-1
Sends transportation information to Amazon about an inbound shipment
def put_transport_content(shipment_id, is_partnered, shipment_type, transport_details) operation('PutTransportContent') .add('ShipmentId' => shipment_id, 'IsPartnered' => is_partnered, 'ShipmentType' => shipment_type, 'TransportDetails' => ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipped\n OrderinshopMailer.shipped\n end", "def shipped\n OrderNitifierMailer.shipped\n end", "def live_send(destinations,body,clientmessagereference,options = {})\n @options[:method] = 'sendsms'\n @options[:destinations] = to_csv(destinations) \n @options[:clientmessagereference] = clien...
[ "0.59989953", "0.5946801", "0.5928391", "0.59127855", "0.58667004", "0.58667004", "0.58493465", "0.5829645", "0.5814973", "0.579145", "0.5790894", "0.5769163", "0.5763227", "0.57629806", "0.5753728", "0.5751292", "0.57399285", "0.5725101", "0.5719811", "0.57114387", "0.570984...
0.0
-1
Requests an estimate of the shipping cost for an inbound shipment
def estimate_transport_request(shipment_id) operation('EstimateTransportRequest') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipping_cost(direction = nil)\n if self.qualifies_for_free_shipping?\n cost = BigDecimal.new(\"0.0\")\n else\n sc = ShippingCalculator.get_default\n sc.calculate_for(self)\n cost = sc.cost\n end\n return cost\n end", "def shipping_cost_based_on_weight\n shipping_weight_...
[ "0.72171867", "0.7036308", "0.6894739", "0.67903477", "0.6761129", "0.67188144", "0.67188144", "0.66577667", "0.65597457", "0.651096", "0.645238", "0.6449473", "0.639734", "0.6373297", "0.6370183", "0.63387454", "0.6293131", "0.6286208", "0.62673056", "0.6260118", "0.6215321"...
0.0
-1
Returns current transportation information about an inbound shipment
def get_transport_content(shipment_id) operation('GetTransportContent') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delivery\n source_node[:delivery]\n end", "def shipping\n adjustments.find { |a| a.type == \"shipping-method\" }\n end", "def shipping\n @data[:shipping]\n end", "def shipment\n @shipment ||= shipments.first\n end", "def shipment\n @shipment ||= shipments.last\n end", ...
[ "0.59497833", "0.5897705", "0.5891626", "0.5866047", "0.57601815", "0.57601815", "0.5725058", "0.56839174", "0.56429815", "0.56389296", "0.5558033", "0.54959965", "0.5428441", "0.5407616", "0.54012764", "0.5377629", "0.53343207", "0.5311247", "0.5281056", "0.52625364", "0.526...
0.0
-1
Confirms that you accept the Amazonpartnered shipping estimate and you request that the Amazonpartnered carrier ship your inbound shipment
def confirm_transport_request(shipment_id) operation('ConfirmTransportRequest') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_shipping_fee\n\t\t@reward = Reward.find(@reward_receiver.reward_id)\n\t\t#Select shipping amount based on different situiations\n\t\tif @reward.shippings.where(country: @reward_receiver.shipping_address.country).first\n\t\t\t@amount = @reward.shippings.where(country: @reward_receiver.shipping_address.c...
[ "0.6400391", "0.6110201", "0.60576427", "0.60386175", "0.6033333", "0.6032983", "0.6027133", "0.6006179", "0.600588", "0.59933305", "0.59764355", "0.59331495", "0.5919115", "0.5903759", "0.5901072", "0.58933663", "0.588154", "0.58640754", "0.5850893", "0.5837202", "0.5837202"...
0.0
-1
Voids a previouslyconfirmed request to ship your inbound shipment using an Amazonpartnered carrier
def void_transport_request(shipment_id) operation('VoidTransportRequest') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel(_response_code)\n active_merchant_response(true, 'PayUIn will automatically capture the amount after creating a shipment.')\n end", "def cancel_saferpay_payment\n return unless transaction_id = saferpay_payment.transaction_id\n\n gateway.void(transaction_id)\n end", "def c...
[ "0.700518", "0.61712766", "0.611457", "0.60905975", "0.60905975", "0.6055896", "0.6035651", "0.6017785", "0.5987993", "0.5983851", "0.5983011", "0.594869", "0.594354", "0.59250164", "0.59046066", "0.5903416", "0.5900417", "0.5884661", "0.58441734", "0.5819717", "0.5796615", ...
0.61400896
2
Returns PDF document data for printing package labels for an inbound shipment
def get_package_labels(shipment_id, page_type, opts = {}) operation('GetPackageLabels') .add(opts) .add('ShipmentId' => shipment_id, 'PageType' => page_type) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_labels_pdf\n if @body['response']['data_stream']\n pdf = Tempfile.new('labels.pdf')\n File.open(pdf.path.to_s, 'wb') do |f|\n f.write(Base64.decode64(@body['response']['data_stream']))\n end\n pdf\n else\n raise PdfDataStreamError.new(\"No data stream i...
[ "0.67381334", "0.6558818", "0.64245903", "0.6393231", "0.6392981", "0.62994385", "0.6295631", "0.62490624", "0.61865276", "0.6093921", "0.60714966", "0.60612905", "0.60434556", "0.5984792", "0.5982943", "0.59480345", "0.5928258", "0.5895485", "0.58837223", "0.5870387", "0.586...
0.0
-1
Returns unique package labels for faster and more accurate shipment processing at the Amazon fulfillment centre
def get_unique_package_labels(shipment_id, page_type, package_labels_to_print) operation('GetUniquePackageLabels') .add('ShipmentId' => shipment_id, 'PageType' => page_type, 'PackageLabelsToPrint' => package_labels_to_print) .structure!('Pac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def package_names_for_targets\n package_names_for_targets = []\n target_version_array.each_with_index do |target_version, i|\n if !target_version.nil?\n package_name = package_name_array[i]\n package_names_for_targets.push(package_name)\n else\n pack...
[ "0.60546184", "0.58746827", "0.57705426", "0.5761488", "0.5744684", "0.57245946", "0.5683819", "0.5673254", "0.5668173", "0.56463087", "0.5588032", "0.5530988", "0.5506137", "0.5487568", "0.5480962", "0.54231936", "0.5408011", "0.53710926", "0.53672487", "0.53648055", "0.5340...
0.68759507
0
Returns PDF document data for printing a bill of lading for an inbound shipment
def get_bill_of_lading(shipment_id) operation('GetBillOfLading') .add('ShipmentId' => shipment_id) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def biller_contract_pdf\n # Search invoice & items\n @biller_printer = Bill.find(params[:id])\n # Generate barcode\n _code = \"code=EANUCC128\"\n _data = \"data=\" + @biller_printer.barcode\n _format_image = \"imagetype=Png\"\n\n _bar_code = _code + \"&\" + _data + \"&\" + _forma...
[ "0.7165363", "0.6981291", "0.687979", "0.6871751", "0.6766131", "0.66606957", "0.6630232", "0.66289806", "0.656633", "0.654643", "0.6519136", "0.6486287", "0.6477935", "0.6476168", "0.64680827", "0.646126", "0.64565074", "0.64555746", "0.64504135", "0.6449788", "0.64453655", ...
0.0
-1
Returns a list of inbound shipments based on criteria that you specify
def list_inbound_shipments(opts = {}) operation('ListInboundShipments') .add(opts) .structure!('ShipmentStatusList', 'member') .structure!('ShipmentIdList', 'member') run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_inbound_shipment_items(opts = {})\n operation('ListInboundShipmentItems')\n .add(opts)\n\n run\n end", "def shipments\n ret = []\n elements = @document.search self.shipments_found_in\n elements.each do |element| \n li = Shipment.new\n li.document ...
[ "0.6794919", "0.6538148", "0.6169913", "0.58314514", "0.58212304", "0.5694029", "0.55631226", "0.5501964", "0.5485393", "0.53916", "0.5349595", "0.53309625", "0.52915186", "0.52442104", "0.52442104", "0.523945", "0.52227926", "0.51935077", "0.5167555", "0.5157036", "0.5148459...
0.7291758
0
Returns the next page of inbound shipments
def list_inbound_shipments_by_next_token(next_token) operation('ListInboundShipmentsByNextToken') .add('NextToken' => next_token) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n return @page + 1\n end", "def calculate_next\n n = @current_page + 1\n n > @total_pages || n <= 0 ? nil : n\n end", "def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n e...
[ "0.68868124", "0.67766285", "0.6776153", "0.6768956", "0.6711756", "0.6662091", "0.6655326", "0.6595966", "0.65931755", "0.6580567", "0.6558315", "0.654752", "0.65440756", "0.6540458", "0.65165365", "0.6493228", "0.64875555", "0.6464368", "0.64577633", "0.64438295", "0.644382...
0.6489665
16
Returns a list of items in a specified inbound shipment, or a list of items that were updated within a specified time frame
def list_inbound_shipment_items(opts = {}) operation('ListInboundShipmentItems') .add(opts) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_inbound_shipments(opts = {})\n operation('ListInboundShipments')\n .add(opts)\n .structure!('ShipmentStatusList', 'member')\n .structure!('ShipmentIdList', 'member')\n\n run\n end", "def list_inbound_shipment_items_by_next_token(next_token)\n operatio...
[ "0.60112065", "0.5599968", "0.54961216", "0.54036474", "0.5383095", "0.53152496", "0.5295628", "0.5282744", "0.52130115", "0.51521474", "0.5104511", "0.5098712", "0.5097203", "0.50852555", "0.50656956", "0.50507647", "0.5036139", "0.5030361", "0.5020721", "0.50013804", "0.499...
0.6332267
0
Returns the next page of inbound shipment items
def list_inbound_shipment_items_by_next_token(next_token) operation('ListInboundShipmentItemsByNextToken') .add('NextToken' => next_token) run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_page(params = {})\n @items = load_page(params)\n end", "def next\n return @page + 1\n end", "def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n end", "def next_page\n @ral...
[ "0.6914616", "0.6835226", "0.67201376", "0.67084044", "0.6668197", "0.6664444", "0.66632694", "0.6623458", "0.6623458", "0.65624344", "0.655555", "0.6547019", "0.65168", "0.649224", "0.64886945", "0.6484899", "0.64628756", "0.6461", "0.64522696", "0.6417314", "0.6409758", "...
0.6662685
7
Gets the operational status of the API
def get_service_status operation('GetServiceStatus') run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n o = @api.status\n OpenStruct.new o\n end", "def status\n service.get(\"\")\n end", "def status\n debug { \"status\" }\n verify_response { Remote.get('/status', :api_key => api_key ) }\n end", "def status_info\n current_path = '/api/v1/status'\n @conn.get(c...
[ "0.77605975", "0.7724885", "0.77098316", "0.7483329", "0.7475699", "0.7411753", "0.7327202", "0.7267653", "0.7140418", "0.71357405", "0.7083868", "0.7071613", "0.70393723", "0.7018599", "0.7001714", "0.69778055", "0.6952146", "0.69159913", "0.68464315", "0.6833988", "0.681419...
0.7382892
14
Posts the last three beers of a user, or the last day's worth, whichever is more
def last_checkins(response) user = response.matches.first.first || response.user.name if redis.sismember('users', user) log.debug("#{user} looks like an Untappd user") untappd_user = user else # look up the Untappd user for this chat user log.debug("#{use...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recent_five(company, user)\n if !user.auditor?\n if user.owner?\n includes(:user).where(:company_id => company.id).limit(5).order(\" action_time DESC\")\n elsif user.on_branch?\n includes(:user).where(:company_id => company.id, :user_id => user.id, :branch_id => user.branch_id).limi...
[ "0.5960635", "0.5843784", "0.5800947", "0.55998445", "0.5568129", "0.5492271", "0.5470735", "0.5463347", "0.5434419", "0.5410301", "0.53806794", "0.5357598", "0.5356233", "0.5318228", "0.52992755", "0.5261439", "0.5251633", "0.5238747", "0.5238697", "0.5209575", "0.5199456", ...
0.6218302
0
def authenticate_user development if Rails.env == "development" if cookies[:dev_user] then
def authorize_user_for_course @course = Course.find(params[:course_id] || params[:id]) unless @course flash[:error] = "Course #{params[:course]} does not exist!" redirect_to controller: :home, action: :error and return end # set course logger begin COURSE_LOGGER.setCourse(@course)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def development_auth\n @user = User.from_params(development_user_params)\n check_invite(@user)\n handle_sign_in(@user, \"development\")\n end", "def authenticate!\n :authenticate_developer! || :authenticate_charity!\n current_user = developer_signed_in? ? current_developer : current_charity\n en...
[ "0.7702335", "0.7377479", "0.6953116", "0.6925075", "0.6896564", "0.6806158", "0.6806158", "0.6803285", "0.679978", "0.6798842", "0.672518", "0.6654314", "0.6635248", "0.66311264", "0.6628837", "0.6610496", "0.6608097", "0.65835184", "0.6578087", "0.65633786", "0.6559297", ...
0.0
-1
called on Exceptions. Shows a stack trace to course assistants, and above. Shows good ol' Donkey Kong to students
def render_error(exception) # use the exception_notifier gem to send out an e-mail to the notification list specified in config/environment.rb ExceptionNotifier.notify_exception(exception) #TODO: hide stack traces from students after the beta. leave @error undefined to hide stack traces @error = excep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stacktrace; end", "def show_detailed_exceptions?; end", "def stack_trace; end", "def backtrace; end", "def show_backtraces=(_arg0); end", "def full_backtrace; end", "def backtrace\n end", "def skip_backtrace; end", "def long_display\n backtrace = filter_backtrace(@exception.backtrace).joi...
[ "0.6684028", "0.65882236", "0.64231396", "0.6358107", "0.6324457", "0.6150224", "0.6118112", "0.6111531", "0.60641885", "0.6029183", "0.5989136", "0.59364295", "0.591348", "0.5907903", "0.58681387", "0.5860299", "0.5851597", "0.58456826", "0.58261186", "0.5769798", "0.5755761...
0.52765524
97
called on ActiveRecord::RecordNotFound exception. Redirect user to the 404 page without error notification
def render_404 render file: "public/404.html", layout: false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def catch_not_found\n yield\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, :flash => { :error => \"Record not found.\" }\n end", "def catch_not_found\n yield\n\n rescue ActiveRecord::RecordNotFound\n redirect_to root_path\n end", "def catch_not_found\n yield\n rescue ...
[ "0.8218532", "0.82166296", "0.81530315", "0.81077874", "0.80668765", "0.80664116", "0.80293065", "0.8010768", "0.7991368", "0.794746", "0.794746", "0.794746", "0.7940436", "0.79387385", "0.79241663", "0.7902909", "0.7862809", "0.78435206", "0.78426176", "0.78426176", "0.78426...
0.0
-1
Set configuration options using a block
def configure yield self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure(&block)\n @configure_blocks ||= []\n @configure_blocks << block\n end", "def configure(&block)\n raise ArgumentError, \"Block is required.\" unless block_given?\n yield @options\n end", "def configure( &block )\n @configuration = block\n end", "def configure_with_blo...
[ "0.80940044", "0.80690116", "0.78518605", "0.7828946", "0.7828946", "0.7710325", "0.77009004", "0.76383597", "0.7631674", "0.7628846", "0.76173306", "0.76173306", "0.7604457", "0.7604457", "0.75997895", "0.75772715", "0.75576085", "0.7548551", "0.7535454", "0.7509773", "0.750...
0.0
-1
Reset configuration options to default values
def reset! Foxkit::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Foxkit::Default.options[key]) end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset!\n @options = defaults\n end", "def reset!\n @options = defaults\n end", "def reset\n @options = VALID_OPTIONS_KEYS.inject({}) do |opts, k|\n default_option = OnTheSnow::Config.const_get(\"DEFAULT_#{k.upcase}\")\n self.send(\"#{k}=\", default_option)\n opts[k...
[ "0.8494143", "0.8494143", "0.837553", "0.82768005", "0.8269498", "0.8010427", "0.7951364", "0.7947709", "0.7928181", "0.79072756", "0.7889995", "0.7860083", "0.7829693", "0.7709086", "0.7668939", "0.75494516", "0.75440854", "0.75315976", "0.7517629", "0.7414505", "0.7401739",...
0.71106964
33
import any school records that aren't currently in our db
def import_all data_in_batches do |batch| Bookings::Data::SchoolMassImporter.new(batch, email_override).import end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_from_sv\n Federation.load_from_sv\n schools = self.api.paginate(filter: 'enabled')\n schools.each do |school|\n local_school = School.find_by_nucleo_id(school.id)\n if local_school.nil?\n local_fed = Federation.find_by_nucleo_id(school.federation_id)\n School...
[ "0.63715506", "0.5979577", "0.59442043", "0.59346175", "0.57617444", "0.5610596", "0.5594293", "0.55117655", "0.5461978", "0.54227126", "0.53754634", "0.53334785", "0.530357", "0.5290886", "0.52899766", "0.52781445", "0.527654", "0.52684337", "0.52629167", "0.52529496", "0.52...
0.6238714
1
update any school records that differ from edubase source
def update_all data_in_batches do |batch| Bookings::Data::SchoolUpdater.new(batch).update end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_schools_with_district_id(district_id, schools_in_this_district)\n # check in elementary, middle, and high schools\n [\"elementary\", \"middle\", \"high\"].each do |type|\n @world[type].each do |edOrg|\n next if edOrg[\"parent\"] != nil\n edOrg[\"parent\"] = district_id if schools_i...
[ "0.63337165", "0.6138826", "0.61095417", "0.6083707", "0.60260093", "0.5998444", "0.59925413", "0.5951853", "0.5926851", "0.5926072", "0.5923192", "0.5908781", "0.5893165", "0.5823051", "0.57979935", "0.5785801", "0.5759767", "0.5751209", "0.57387495", "0.5734307", "0.5732155...
0.547667
60
If there's any, list magic index in an array. 1. Sorted Array with Distinct Numbers 2. Sorted Array with nondistinct Numbers Questions Assume every element of array is not empty? (not nil?) find one instance of magic index 1. Sorted and Distinct [2,4,5,8] [1,3,4,5] [0,1,1,3] smaller case, numbers not distinct [0,1,2,4]...
def ifind_magic(arr) return false if arr.size == 0 s = arr[0] e = arr[-1] magic_arr = [] i = 0 while s < e return magic_arr if arr[i] != i if arr[i] == i magic_arr[i] = i end i += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dupe_indices(arr)\n idxs = Hash.new { |h, k| h[k] = [] }\n \n arr.each_with_index do |ele, i|\n idxs[ele] << i\n end\n\n return idxs.select { |ele, arr| arr.length > 1 }\nend", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n ...
[ "0.6692489", "0.6685237", "0.66248506", "0.66061646", "0.65871185", "0.6516033", "0.64979625", "0.64678544", "0.64381903", "0.6395468", "0.6368799", "0.6337675", "0.6324906", "0.62715274", "0.6270623", "0.6269349", "0.6262012", "0.62616175", "0.6247058", "0.6236036", "0.62218...
0.7051654
0
O(n), n being size of arr Binary Search (it's SORTED!!)
def bsfind_magic(arr) size = arr.size return false if size == 0 mid_index = (size/2).floor # edge case # check if start or end of array is magic_index or not if size == 1 if mid_index == arr[mid_index] return mid_index else return false end end # compare index and element of arra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bin_search(d, arr)\n middle = arr.length / 2\n i = 0\n j = arr.length - 1\n \n while i < j\n if arr[middle] == d\n return true\n elsif arr[middle] < d\n i = middle + 1\n middle = i + j / 2\n else\n j = middle - 1\n middle = i + j / 2\n end\n ...
[ "0.73537356", "0.73448235", "0.7282803", "0.7251809", "0.72323143", "0.7180561", "0.7179875", "0.7159658", "0.71515447", "0.7147415", "0.7146408", "0.71416587", "0.7134218", "0.7126212", "0.71243435", "0.7110693", "0.7104866", "0.7094903", "0.7092323", "0.70884246", "0.708315...
0.0
-1
Numbers not distinct (still sorted) previous soln does not work magic index could be on either side of array should search both left and right
def bsfind_magic_nd(arr, s, e) if e < s || s < 0 || e >= arr.size return -1 end mid_index = ((s+e)/2).floor mid_value = arr[mid_index] if mid_index == mid_value return mid_index end # search_left left_index = [mid_index-1, mid_value].min left = bsfind_magic_nd(arr, s, left_index) if left ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_unsorted_subarray2(nums)\n sort_nums = nums.sort\n\n left = nums.length\n right = 0\n\n sort_nums.each_with_index do |num, index|\n if num != nums[index]\n left = [index, left].min\n right = [index, right].max\n end\n end\n\n right >= left ? right - left + 1 : 0\nend", "def solutio...
[ "0.6740512", "0.65377635", "0.6482093", "0.64504087", "0.6438286", "0.63886046", "0.63658684", "0.6363309", "0.63377416", "0.6331498", "0.6329622", "0.6285641", "0.62685794", "0.6268335", "0.62381804", "0.6235492", "0.6233981", "0.6225852", "0.62188673", "0.6213672", "0.61852...
0.0
-1
Have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm. Replace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return this mod...
def letter_changes(str) str.each_char.with_index do |char, idx| if char =~ /[A-Za-z]/ if char =~ /[Zz]/ str[idx] = 'a' else str[idx] = (char.ord + 1).chr end end end str.each_char.with_index do |char, idx| str[idx] = char.upcase if char =~ /[aeiou]/ end str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LetterChanges(str)\n str = str.split(\"\")\n \n str.each do |c|\n c.next! if c =~ /[a-z]/\n c.upcase! if c =~ /[aeiou]/\n end\n \n return str.join\nend", "def LetterChanges(str)\n\n str=str.tr('a-y','b-z')\n str=str.tr('aeiou','AEIOU')\n return str \n \nend", "def L...
[ "0.8514498", "0.8481187", "0.8463846", "0.8178411", "0.8041672", "0.770666", "0.7693526", "0.7546845", "0.7449901", "0.7395493", "0.73795503", "0.7376874", "0.73234046", "0.73196954", "0.72943336", "0.7246648", "0.72285634", "0.72079176", "0.71793795", "0.7164592", "0.7148252...
0.858844
0