blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
4
137
path
stringlengths
2
355
src_encoding
stringclasses
31 values
length_bytes
int64
11
3.9M
score
float64
2.52
5.47
int_score
int64
3
5
detected_licenses
listlengths
0
49
license_type
stringclasses
2 values
text
stringlengths
11
3.93M
download_success
bool
1 class
ce2a2cce8e6ccaa30a05ab8f21f98ad9474a6199
Ruby
bkleinen/bkleinen.github.io
/bin/hugo_migration/rewrite_front_matter.rb
UTF-8
1,511
2.671875
3
[]
no_license
require_relative './lib/defined_course_navs.rb' require_relative './lib/generate_course_navigation_front_matter.rb' defined_coursenavs = get_all_course_navs cn = Dir.glob("_includes/classes/*/*.md").reject{ |n| /lectures.md/.match(n) }.map{|s| s.gsub("_includes/","") } missing = cn.difference(defined_coursenavs) p...
true
edffef28fa4bb4ba21d7899cab037ca6b860ca50
Ruby
KSriki/programming_languages-prework
/programming_languages.rb
UTF-8
635
2.828125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry-byebug' def reformat_languages(languages) # your code here new_hash = {} languages.each do |style,langs| langs.each do |lang, prop| # binding.pry # prop.key = type typeof, value = prop.first # [ruby] = oo if !new_hash.has_key?(lang) ...
true
56b83598610b729ef628ea6078ec46af7582e291
Ruby
dockit0/Programming_Foundations
/Small_Problems/Easy1/Easy1-6.rb
UTF-8
608
4.4375
4
[]
no_license
=begin Easy1-6 Reverse it (part 2) Write a method that takes one argument, a string containing one or more words, and returns the given string with all five or more letter words reversed. Each string will consist of only letters and spaces. Spaces should be included only when more than one word is present. =end d...
true
74225ed6883d3efa4fda5e87255b99b63c18090c
Ruby
Gleoman/GildedRose-Refactoring-Kata
/spec/standard_stock_spec.rb
UTF-8
984
2.890625
3
[ "MIT" ]
permissive
require 'gilded_rose.rb' require 'items.rb' require 'standardstock.rb' describe "when updating standard stock" do it "reduces the quality of the item by 1" do std_items = [StandardStock.new("Standard stock", 10, 10)] GildedRose.new(std_items).update_quality expect(std_items[0].quality).to eq 9 end ...
true
fdb122470a4703d7e70d507bb4084b0f53045e4b
Ruby
pete3249/programming-univbasics-4-basic-hashes-lab-atl01-seng-ft-051120
/lib/intro_to_ruby_hashes_lab.rb
UTF-8
267
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def new_hash new_hash = {} end def my_hash my_hash = { :libero => "Jenna", :setter => "Coba", :right_side => "Ali" } end def pioneer pioneer = { :name => 'Grace Hopper' } end pioneer[:name] def id_hash_generator(number) {:id => number} end
true
7c0f8dc81c989415301b7cefd3aa965ca3433a95
Ruby
tjroeder/enigma
/lib/decrypt.rb
UTF-8
262
2.5625
3
[]
no_license
require_relative './enigma' enigma = Enigma.new enigma.cli_user_input(ARGV) decrypted_hash = enigma.decrypt(enigma.cli_message, enigma.cli_key, enigma.cli_date) enigma.file_write(enigma.cli_write_path, decrypted_hash[:decryption]) puts enigma.cli_print_message
true
cef5f3de9d901fbce2efbab2cd7a5311a5ade42f
Ruby
deeqoo/learning_to_program_chirs_pine
/Class/basic_class.rb
UTF-8
248
3.28125
3
[]
no_license
a = Array.new + [12345] b = String.new + "hello" c = Time.new puts "a = " +a.to_s puts "b ="+b.to_s puts "c = ".+c.to_s time = Time.new time2 = time + 60 puts time puts time2 puts Time.mktime(2000,1,1) # y2k puts Time.mktime(1976,8,3,10,11)
true
4397bf1abd0cd536bb85e31c346d952f6587aa38
Ruby
tylyon/subway_station_reviews
/spec/features/user_deletes_a_review_spec.rb
UTF-8
1,836
2.5625
3
[]
no_license
require "rails_helper" feature "user deletes review", %{ As a registered user I want to delete my own review So that I can take back my review Acceptance Criteria: [ ] I must be logged in [ ] Next to each of my reviews on a station page I see a link to delete my review [ ] If I click on this link ...
true
e1f21af093f920b828c7e3e22ba78a9a286b497f
Ruby
ChaimaBenmakhlouf/ruby-course
/Ruby cheat sheets/13 - Functions.rb
UTF-8
1,091
4.125
4
[]
no_license
def greeting(name = 'John') # = default argument value "Hello #{name}" # implicit return end puts greeting('Paul Atreïde') # Hello Paul Atreïde # variable number of arguments (name will be an array) # google : single splat operator def print_phrases(main_phrase, *phrases) puts "This is main phrase: #{main_phras...
true
3b7f07df38c5223380a08d0e8b8e90c05e505d8c
Ruby
Ricartho/mass-assignment-noukod-000
/lib/person.rb
UTF-8
858
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Person #your code here attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, :complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width def initialize(name:, birthday:, hair_color:,eye_color:,height:,weight:,handed:,complexion:,t_shirt_size:,wrist_size:,gl...
true
587597d922915fe17c658994a1ccdf69f65d91d2
Ruby
LipeiYang/demo2
/app/models/customer.rb
UTF-8
866
2.515625
3
[]
no_license
class Customer < ActiveRecord::Base has_many :orders has_many :receivables validates_length_of :seq, :name, :maximum => 20 validates_presence_of :name, :cutoff_date validates_uniqueness_of :name validates_numericality_of :inreceive_amount MIN_SINK = 100 IDLE_PERIOD = 2.months def unsettle_...
true
a61dc21ecaa2c5971ff0f529b0a4ddd37e564250
Ruby
cindyvandooren/app_academy_prepwork
/w1/w1d1/array.rb
UTF-8
1,542
4.15625
4
[]
no_license
def my_uniq(arr) uniq_arr = [] arr.each_with_index do |element, index| if arr.index(element) == index uniq_arr << element end end uniq_arr end class Array def my_uniq uniq_arr = [] self.each_with_index do |element, index| if self.index(element) == index uniq_arr << element end end uniq_a...
true
04eed8c1725e046b01c33b63d35b6f513121e919
Ruby
cpanderson/FileQuest
/lib/filequest/helpers.rb
UTF-8
1,329
2.84375
3
[ "MIT" ]
permissive
module FileQuestHelper # omit x levels of directory starting from the base # ie. fq_omit_dir_levels("/Base/Dir 1/Dir 2/Dir 3", 2) => "/Dir 2/Dir 3" def fq_omit_dir_levels(dir, levels) dirs = dir.split('/') fullpath = "" dirs[(1 + levels)..dirs.size].each do |d| fullpath += "/" + d end ...
true
934934fdd9b59282953153b3ac884a3f637142c1
Ruby
hassanss1/today-I-learned
/back_end-related/MVC_Sessions/01-Food-Delivery/app/models/order.rb
UTF-8
382
3.0625
3
[ "MIT" ]
permissive
class Order attr_accessor :id, :employee attr_reader :meal, :customer def initialize(attributes = {}) @id = attributes[:id] @meal = attributes[:meal] @customer = attributes[:customer] @employee = attributes[:employee] @delivered = attributes[:delivered] || false end def delivered? @de...
true
087003a82bdb043f76cda75fc3067eaf2e077a87
Ruby
Nikoliki/masha
/app/service/authentificator.rb
UTF-8
2,124
2.671875
3
[]
no_license
# Auth Hash Schema # https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema # class Authentificator attr_accessor :auth_hash, :user def self.authentificate(auth_hash) new(auth_hash).authentificate end def initialize(_auth_hash) @auth_hash = _auth_hash @user = nil end def authentificate ...
true
62663e2711355549e6b8057ed0d22404ac98c12d
Ruby
davidmorrison1981/week_2_partner_project
/specs/game_spec.rb
UTF-8
1,017
2.875
3
[]
no_license
require("minitest/autorun") require("pry-byebug") require_relative("../game") require_relative("../board") require_relative("../ships") require("minitest/rg") class GameTest <MiniTest::Test def setup @board = GameBoard.new @ships=Ships.new @game=Game.new("Emma", "David", "A1", "D5", @board, @ships) e...
true
3f49daf65caa60b0f82192365ff51bf0c67c60fe
Ruby
rbembleton/Chess
/chess.rb
UTF-8
3,616
3.65625
4
[]
no_license
require_relative "required" class Game attr_reader :board, :player_one, :player_two, :display, :current_player def initialize(player_one, player_two) @player_one = player_one @player_two = player_two @board = Board.new @display = Display.new(@board) @current_player = @player_one end def ...
true
81f0cbb88ae5046db9fbf8ad7664cdfbee037872
Ruby
arbind/hover_craft_service
/app/services/job_queue/twitter_jobs.rb
UTF-8
5,071
2.59375
3
[]
no_license
# # assumes all friends of a TweetStreamer are verified TwitterCrafts # class TwitterJobs < JobServiceBase # GROUP = :twitter # def self.pull_twitter_crafts_from_all_streamers # TweetStreamer.all.each do |tweet_streamer| # pull_twitter_crafts_from_streamer tweet_streamer # end # end # def self.pu...
true
a98512fd27c9f5da2ff2c6e14bd03c7924fb8fdb
Ruby
csipsz/programming-univbasics-4-simple-looping-lab-atl01-seng-ft-051120
/lib/simple_loops.rb
UTF-8
487
3.78125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def loop_message_five_times(message) 5.times do puts message end end def loop_message_n_times(message, int) n = int n.times do puts message end end def output_array(array) i = 0 while i < array.count do puts array[i] i += 1 end end def return_string_array(array) array_of_st...
true
d237333fbb9073cd7adb021f7e8a2e35179be1e7
Ruby
Keranw/architecture_design_project
/Prototype/onlineShopping/app/models/order.rb
UTF-8
1,042
2.875
3
[]
no_license
class Order < ActiveRecord::Base #update the info of purchased items def self.purchase(list, quantity) result = [] list.each do |item_id| aim_item = Item.find(item_id.to_i) session_temp = nil quantity.each do |item_quantity| if item_id.to_i.eql?(item_quantity["item_buy"].to_i) ...
true
b9e3f9506504aca2002d84ce7a5e39cd1703152c
Ruby
hitomi4vv/aizu-online-judge
/introduction/ITP1_10_D-Distance II.rb
UTF-8
150
3.046875
3
[]
no_license
gets d = gets.split.map(&:to_f).zip(gets.split.map(&:to_f)).map{|x, y|(x-y).abs} (1..3).each{|p| puts d.map{|v| v**p}.reduce(:+)**(1.0/p)} puts d.max
true
91a07e6b77ed82d8466d6ca86ac6bde1b4e4d71e
Ruby
hpkelley/TTS
/grade.rb
UTF-8
254
4.03125
4
[]
no_license
#OBJ - Write a program that asks for a score (an integer), and assigns a letter grade based on the score. puts "Enter your test score" answer = gets.chomp.to_i if answer <= 100 puts "You passed!" else puts "You have to take the class again..." end
true
3015710b62d0eb2cc6b69a3463d1c2dcc1d5ed23
Ruby
muntaza/Catatan-Muntaza
/ruby/if2.rb
UTF-8
110
3.3125
3
[]
no_license
#!/usr/bin/ruby a = 3 if a > 7 puts "Greater than 7" if a < 42 puts "Between 7 and 42" end end
true
49d21a8ab2e84106fc24a3eb970c0f4f630e2a05
Ruby
songgz/wiz_med
/app/models/book.rb
UTF-8
282
2.75
3
[]
no_license
# encoding: utf-8 class Book < Chapter field :year, type: Integer field :dynasty, type: String class << self def gen(*arrts, &block) book = Book.create(*arrts) block.arity<1 ? book.instance_eval(&block) : block.call(book) if block_given? end end end
true
f36b64df6691b4d8ac2f2a482dde0893f4eb3a56
Ruby
darionmh/Projects
/Rhythm Gen/RythmnGen.rb
UTF-8
1,958
3.078125
3
[]
no_license
require 'chunky_png' notes = ['whole', 'half', 'quarter', 'eighth', 'sixteenth'] noteValue = [1, 0.5, 0.25, 1.0/8, 1.0/16] notePics = puts "Enter the time signiture: (format- 4 4 or 3 4 or 6 8 etc)" timeSigInput = gets.chomp.split(" ") timeSig = timeSigInput[0].to_f/timeSigInput[1].to_f puts "How many measures?: " ...
true
6e43deb38e15c5616373a4f869cf695fcb49bca0
Ruby
audramatar/dungeon
/lib/game/combat/combat_instance.rb
UTF-8
2,190
3.53125
4
[]
no_license
require_relative '../../file_helper.rb' require_relative '../../UI/combat_ui.rb' # A class to generate an instance of combat class CombatInstance include CombatUI attr_reader :grid def initialize(pc_party, enemy_party, encounter_type, location) @pc_party = pc_party @enemy_party = enemy_party @encou...
true
5a6770f22f4c515e34f60c981a5e62106a405930
Ruby
kstephens/tredmill
/doc/data_structure.rb
UTF-8
8,103
2.703125
3
[]
no_license
#!/usr/bin/env ruby class DataStruct EMPTY_STRING = ''.freeze attr_accessor :name, :slots, :memory attr_accessor :color, :data attr_accessor :links def initialize @slots = [ ] @slot_by_name = { } @links = [ ] end def data! @data ||= DataStruct::Memory.new end def color= c ...
true
19cf7037589cead2bf5cb3592e5aecff3f3279af
Ruby
AlexisAuriac/201yams_2018
/combinaisons.rb
UTF-8
2,838
3.796875
4
[]
no_license
require "./utilities.rb" PA = 1.0 / 6.0 NB_DICE = 5 def get_prob(nb_dice, nb_roll) prob = 0 for i in nb_roll...(nb_dice + 1) nb_comb = Utilities.combinations(nb_dice, i) p1 = PA ** i p2 = (1 - PA) ** (nb_dice - i) prob += nb_comb * p1 * p2 end return prob end def get_...
true
489ac2596514304e357243c45235126c61fe46c1
Ruby
Brunomm/br_boleto
/test/br_boleto/remessa/cnab240/bradesco_test.rb
UTF-8
6,721
2.53125
3
[ "MIT" ]
permissive
require 'test_helper' describe BrBoleto::Remessa::Cnab240::Bradesco do subject { FactoryGirl.build(:remessa_cnab240_bradesco, lotes: lote) } let(:pagamento) { FactoryGirl.build(:remessa_pagamento, valor_documento: 879.66) } let(:lote) { FactoryGirl.build(:remessa_lote, pagamentos: pagamento) } it "deve herdar d...
true
4c2d260f029462af3efec204009b42806c30aec0
Ruby
evserykh/toy_robot
/spec/lib/command/place_spec.rb
UTF-8
995
2.53125
3
[]
no_license
require 'spec_helper' require File.expand_path('../../../lib/command', __dir__) require File.expand_path('../../../lib/command/place', __dir__) require File.expand_path('../../../lib/toy_robot', __dir__) describe Command::Place do let(:table) { double('table') } let(:robot) { ToyRobot.new } subject { described_...
true
5cb61c6982c34bcef0aa6de58a1fde5d95efd702
Ruby
jgeorgex/mastery-curriculum
/pairing_practice_is_number_even.rb
UTF-8
350
4
4
[]
no_license
def is_even?(int) if int % 2 == 1 false else true end end p is_even?(3) #p is_even?(3) #=> false p is_even?(4) #p is_even?(4) #=> true =begin define a method that takes an argument use a method to identify if argument is even or odd if argument is even return true if argument is odd return false close method...
true
4f58bb9896f935b4cdccaea175b487c98a9ab6da
Ruby
TyriekBarker/tic-tac-toe-rb-cb-000
/lib/tic_tac_toe.rb
UTF-8
2,682
4.40625
4
[]
no_license
def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end def move(array, index, character) array[index] = character array end def input_to_index(...
true
cd9b066729c2f3bbb8ac0385d6cfa9eb171ec272
Ruby
noel1uk/GildedRose-Refactoring-Kata
/lib/type_checker.rb
UTF-8
423
3.125
3
[]
no_license
class TypeChecker attr_accessor :type def initialize(item_name) @item_name = item_name end def check() if @item_name == 'Aged Brie' 'cheese' elsif @item_name == 'Backstage passes to a TAFKAL80ETC concert' 'ticket' elsif @item_name == 'Sulfuras, Hand of Ragnaros' 'legendary' ...
true
b2dfca277c0195b4cb51133bda69ff05b2879359
Ruby
jack-spy-me-3/cookbook-app
/app/models/recipe.rb
UTF-8
510
2.6875
3
[]
no_license
class Recipe < ApplicationRecord belongs_to :user def ingredients_list ingredients.split(", ") end def directions_list directions.split(", ") end def friendly_time created_at.strftime("%b %d, %Y") end def friendly_prep_time if prep_time hours = prep_time / 60 minutes = pr...
true
d73ab5abdd601181d7d7f8cc57dd35b0a872ddaa
Ruby
HakubJozak/pcdir-duben-2017
/course/6-methods.rb
UTF-8
588
3.75
4
[]
no_license
# coding: utf-8 * Metody - definice ** Vsechny vyrazy v Ruby 'maji hodnotu'! def hello_world(name = 'World') return unless name puts "Hello #{name}!" end hello_world "John" hello_world nil hello_world ** parameter s defaultni hodnotou def b(a = "No value!") puts a end ** kazda metoda muze mit blok jako par...
true
07d0520aee7bd85ebcfcb81cd5cca215bd814ce6
Ruby
selivanov-d/ror-basics-course
/Lesson_5/passenger_train.rb
UTF-8
300
2.5625
3
[]
no_license
class PassengerTrain < Train TYPE = 'Пассажирский' def add_carriage(carriage) abort 'К пассажирскому поезду можно прицепить только пассажирские вагоны!' unless carriage.instance_of? PassengerCarriage super end end
true
01edb733b11e3e6098b6f2f167be2c4994abe4c3
Ruby
Tolotra0977/spreadsheet_scrapper
/lib/scrapper.rb
UTF-8
1,946
3.078125
3
[]
no_license
#!/usr/bin/env ruby class Scrapper # Definition de la méthode get_townhall_email(townhall_url) #stockage des emails dans un hash email_array def get_townhall_email(townhall_url) page = Nokogiri::HTML(open(townhall_url)) email_array = [] email = page.xpath('//*[contains(text(), "@")]').te...
true
6f40a79ff439bd72d524277de451426e2849f67f
Ruby
kjakub/rapportive
/lib/rapportive/rapportive_api.rb
UTF-8
5,106
2.53125
3
[ "MIT" ]
permissive
require 'httparty' module Rapportive class RapportiveApi def query_multi_proxy(first_name= "", last_name= "", middle_name= "", domain, options) puts 'multiproxy' proxies = options[:proxy_list] begin proxy = proxies.first raise Rapportive::HttpError, '429 and no more ...
true
1a69c8a5acd455d6fd75e3ad6f53142f86da54ed
Ruby
gafrom/bzn
/app/services/daily_report/by_week_v2.rb
UTF-8
3,748
2.5625
3
[]
no_license
module DailyReport class ByWeekV2 < ByWeek COLOR_PICKER = { 0 => '900000', 1 => 'CB4B00', 2 => 'FF8900', 3 => 'FFBE24', 4 => 'FFE955', 5 => 'FCFF90', 6 => 'F1FFB5', 7 => nil }.freeze def store categories_by_groups.each do |name, categories| sp...
true
5d517f299a3c0502711f13753ae649158ddcd345
Ruby
yir17/ruby_training
/9_pitagoras.rb
UTF-8
214
2.96875
3
[]
no_license
puts 'cateto opuesto' cateto_opuesto opuesto = gets.to_i puts 'Cateto adyacente' catetoc= gets.to_i resultado = Math.sqrt(cateto_opuesto**2 + cateto_adyacente**2) puts "El valor de la hipotenusa es: #{resultado}"
true
2ee99e91a515d7a634e2ae5590ae50ca1887acb4
Ruby
judywu29/ruby_pj
/robot_moving_copy.rb
UTF-8
4,570
3.453125
3
[]
no_license
module Inputfilereading #store the args of PLACE args @@place_args = Array.new #store the cmds except PLACE @@cmdlist = Array.new #reading the input file which is supposed to be at the folder with this ruby file def readinginputfile() begin File.open("input.txt", "r") do |file| ...
true
d188f0413ec860e228e166a96214f6de7051d216
Ruby
cooperq/chars
/lib/chars/extensions/string.rb
UTF-8
932
2.84375
3
[ "MIT" ]
permissive
require 'chars/chars' class String def numeric? Chars::NUMERIC === self end def octal? Chars::OCTAL === self end def uppercase_hex? Chars::UPPERCASE_HEXADECIMAL === self end def lowercase_hex? Chars::LOWERCASE_HEXADECIMAL === self end def hex? Chars::HEXADECIMAL === self en...
true
b20bfc353f84516fc0719595542e963bc0a4b076
Ruby
tesarglynnis91/rma
/test/x86_64/functions.rb
UTF-8
1,770
2.875
3
[]
no_license
require 'macros/x86_64/basic' class RMA::X86_64::Test def test_call bin = assemble { m = addmacros BasicMacros m.entry(:main) call :foo m.sys_exit(rax) m.entry(:foo) m.return(5) } run_test bin, 5 end # http://en.wikibooks.org/wiki/Fibonacci_number_program#Arithmetic_version_2 def fib(n) ((((1+Mat...
true
8091d5e7ee46468ef3f1ed5149f48c7e1442af44
Ruby
jlemonier/utils
/win_utils/userlib_compare.rb
UTF-8
1,436
2.90625
3
[]
no_license
# Find missing jars based on user library files def standardize_jar_names (jar_list) # print "std: #{jar_list} \n" new_list = [] jar_list.each do |j| next if j == nil # or if j.to_s.size <= 1 # print " j: #{j} - #{j.class} BEFORE \n" tokens = ["\/release\/lib\/", "\/test\/lib\/", "\/server\/lib\/", "...
true
75a2fe0a1143c43453a01d772b939b3142d0db4c
Ruby
kiwiwin/GitScraper
/src/search_url.rb
UTF-8
364
2.8125
3
[]
no_license
class SearchURL def initialize(type, param) @type = type @param = param end def search_url "https://github.com/search?&q=#{criteria}&type=#{@type.to_s.capitalize}" end def single_page_url(page_index) search_url + "&start_value=#{page_index}" end def criteria @param.to_a.inject([]) { |res, pair| re...
true
1ddb2277c22055fcd1bee276bf4d58241fe2ca8e
Ruby
jespr/ruby-ray
/examples/colors.rb
UTF-8
217
2.515625
3
[ "MIT" ]
permissive
require_relative "../lib/ray" ray.new_screen('Colors') ray('this is green').green ray('this is orange').orange ray('this is red').red ray('this is purple').purple ray('this is blue').blue ray('this is gray').gray
true
6b12879b977a8ced43a42af5e7a7659c07fb33be
Ruby
jasonlally/hub
/_test/joiner_filter_private_pages_test.rb
UTF-8
2,000
2.59375
3
[ "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
require_relative "../_plugins/joiner" require_relative "page" require_relative "site" require "minitest/autorun" module Hub class FilterPrivatePagesTest < ::Minitest::Test def setup @site = DummyTestSite.new @all_page_names = [] @public_page_names = [] end def add_public_page(filename...
true
7f89eb3266d3e06fe44e645626d5b41a63f8dd64
Ruby
ellazee/google-shopping-ruby
/google_shopping.rb
UTF-8
1,731
3.671875
4
[]
no_license
#RUBY!! no more semi-colons... ever. require 'json' file = File.read("./products.json") #Welcome to RUBY we use snake case now #snake case word_word not camel case wordWord google_data = JSON.parse(file) data = google_data["items"] backorder = [] # outputs the full object #puts google_data.inspect # outputs the f...
true
56b6a01ff2291d1bf54f8d393933caf6d22dd90f
Ruby
yuqiqian/ruby-leetcode
/243_shortest_word_distance.rb
UTF-8
387
3.40625
3
[]
no_license
# @param {String[]} words # @param {String} word1 # @param {String} word2 # @return {Integer} def shortest_distance(words, word1, word2) dict = Hash.new(-1) dis = 2^31-1 words.each_with_index do |w, i| if [word1,word2].include? w dict[w] = i binding.pry if dict[word1]!= -1 && dict[word2]!= -1 dis = [...
true
2d00ff052dc9716c9ce6ea59ddfae41c2af74538
Ruby
mnhollandplum/black_thursday
/test/customer_repository_test.rb
UTF-8
2,386
3.046875
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/customer_repository' class CustomerRepositoryTest < Minitest::Test def test_it_exists cr = CustomerRepository.new('./data/customers.csv') assert_instance_of CustomerRepository, cr end def test_it_has_items cr = CustomerRepository.new('./data/c...
true
50a47a7c05e0b1ea32c013bf46e89383276b8f8c
Ruby
juanmaberrocal/game-scoreboard
/app/services/statistics_generators/player_statistics_service.rb
UTF-8
1,066
2.515625
3
[]
no_license
# frozen_string_literal: true module StatisticsGenerators class PlayerStatisticsService attr_reader :record def initialize(record) @record = record end def generate raw_statistics.each do |raw_statistic| statistics[:breakdown][raw_statistic.game_id] = { played: raw_sta...
true
5352f1b2579de1798a877e53504c5f80679096b0
Ruby
twarbelow/backend_module_0_capstone
/day_3/exercises/making_decisions.rb
UTF-8
2,105
3.890625
4
[]
no_license
puts "You enter a dark room with two doors. Do you go through door #1 or door #2?" print "> " door = $stdin.gets.chomp if door == "1" puts "There's a giant bear here eating a cheese cake. What do you do?" puts "1. Take the cake." puts "2. Scream at the bear." puts "3. Shove cake in bear's face and run past....
true
6d814b22d0c941d25f1795aad69df303057febcf
Ruby
Consoci8/jqmobile_helpers
/lib/jqmobile_helpers/toolbars_helper.rb
UTF-8
5,294
2.765625
3
[ "MIT" ]
permissive
module JqmobileHelpers # = JqmobileHelpers List View Helpers # Provides a set of methods for making toolbars views # for jquery-mobile markup module ToolbarsHelper # Header Bar Title # # === Examples # # => <%= header_toolbar_title('Put Title Here') %> # => <h1>Page Title</h1> ...
true
a1f5b4782c561ba141fcc4a3a3ae5854df4b1dcb
Ruby
isabella232/moqueue
/lib/moqueue/matchers.rb
UTF-8
2,186
2.640625
3
[]
no_license
module Moqueue module Matchers class HasReceived def initialize(expected_msg) @expected_msg = expected_msg end def matches?(queue) if queue.respond_to?(:received_message?) @queue = queue @queue.received_message?(@expected_msg) else ...
true
cb8de4f0973ab9db1182d6fc4567c44447611ed0
Ruby
Wigrovski/Ruby-Examples
/viselica/viselica.rb
UTF-8
603
3.140625
3
[]
no_license
require './methods.rb' cls latters = get_latters errors = 0 bad_latters = [] good_latters = [] puts "Игра виселица. Угадайте слово: " arg = ARGV[1] puts "Подсказка: " + arg while errors < 7 do print_latters(latters, good_latters, bad_latters, errors ) puts "\nвведите следующую букву" user_input = get_user_i...
true
34a1a5b7e8de271fafa480584e033a1c13187b22
Ruby
uqbar-project/ruby-stones
/lib/stones/gbb/gbb_writer.rb
UTF-8
850
3.125
3
[ "MIT" ]
permissive
module Stones module GbbWriter def self.write(board) "GBB/1.0\n" + "size #{board.size[0]} #{board.size[1]}\n" + "#{write_cells board}" + "head #{board.head_position[0]} #{board.head_position[1]}" end private def self.write_cells(board) cells_gbb = '' board.send :...
true
60af4ce994897248e11527461025dfee3cd81523
Ruby
amclelland/Ruby-Files
/2_Medium/primeTime.rb
UTF-8
341
4.375
4
[]
no_license
# For this challenge you will be determining if an argument is a prime number. puts "Enter an integer: " num = Integer(gets.chomp) if num == 2 puts "true" exit elsif num%2 == 0 puts "false" exit else (3..num-1).step(2) do |n| if num % n == 0 puts "false" exit end en...
true
37de1dfc8dff503b28d1dfbdd383da3f21ac6664
Ruby
jeremyhallr/tests-ruby
/lib/01_temperature.rb
UTF-8
150
3.34375
3
[]
no_license
def ftoc(temperature_in_f) return (temperature_in_f.to_f - 32) * 5/9 end def ctof(temperature_in_c) return (temperature_in_c.to_f * 9/5 + 32) end
true
a4c9359ce86e41523c3b90303d7d3038d87049ce
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/6aa7c364c61445d088c8c5a98fcd5675.rb
UTF-8
584
3.875
4
[]
no_license
class Bob def hey( input ) sentence = Sentence.new input case when sentence.shouting? 'Whoa, chill out!' when sentence.question? 'Sure.' when sentence.silence? 'Fine. Be that way!' else 'Whatever.' end end private class Sentence attr_reader :sentence ...
true
6af0226df5ce6447e69e90ba1843c13713fac62d
Ruby
BotBuddy/SDK-ruby
/lib/recastai/apis/train/models/synonym.rb
UTF-8
1,555
2.671875
3
[ "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
# encoding: utf-8 require_relative '../utils' require_relative 'language' module RecastAI class Synonym attr_accessor :id, :slug, :value, :language attr_accessor :gazette def initialize(response = nil, gazette = nil) @gazette = gazette @raw = response if response ...
true
0c0c92b0b0468d2872d3888cd8ed49c4c4cc9a00
Ruby
HaroonMohammadomar/RB101
/lesson_3/easy_1/question_1.rb
UTF-8
118
3.546875
4
[]
no_license
# "uniq" Returns a new array by removing duplicate values in self. numbers = [1, 2, 2, 3] numbers.uniq puts numbers
true
6e621fbd4e6f5b8fcdb842845300fa00730a9644
Ruby
solidkime/Thinknetica_Base
/car_example/joker.rb
UTF-8
541
3
3
[]
no_license
module Joker def self.included(base) #base.instance_variable_set :@instances, 0 base.extend ClassMethods base.include InstanceMethods end module ClassMethods attr_accessor :instances def set_default self.send(:instances=, 0) end private attr_writer :instances end mod...
true
d5cffde4b26a5bcc88dc237bb35d2cc58bfffb87
Ruby
BooDoo/olioetry
/api.rb
UTF-8
3,969
2.90625
3
[]
no_license
require 'json' require 'sinatra' require 'slim' require './poem' require './theme' THEMES, COMMON_THEME = Theme.loadAll("./wordlists") print THEMES require './dbmodels' initialize_models? POEMS = {} Db::Poem.all.each do |dbpoem| poem = Poem.depersist(dbpoem) POEMS[poem.id] = poem end HN_VI...
true
8fd75a53f4690315aab195726eafabe3802cef83
Ruby
ledleds/battle
/lib/game.rb
UTF-8
501
3.328125
3
[]
no_license
class Game attr_reader :player_1, :player_2, :current_player, :opponent def initialize(player_1, player_2) @player_1 = player_1 @player_2 = player_2 @current_player = player_1 @opponent = player_2 end def attack(attacked_player) attacked_player.take_damage end def change_player if ...
true
fec71ea05598cfa6e407aa52bce4a468114f9d35
Ruby
cored/http_log_monitor
/lib/http_log_monitor.rb
UTF-8
856
2.59375
3
[ "MIT" ]
permissive
require "http_log_monitor/version" require "dotenv" require_relative "./http_log_monitor/types" module HttpLogMonitor Dotenv.load def self.call(options:) monitor = Monitor.new(options) report = Report.new(monitor: monitor) file = build_file_for(monitor.file_path) process_report_with(report) p...
true
bc7dcc72245582c500945b9b369f9e125a608615
Ruby
stffnbrr/searchalgorithms
/field.rb
UTF-8
1,058
3.3125
3
[]
no_license
class Field include Node def self.createboard size_x, size_y @@board = Array.new size_x.times do |value_x| arr = Array.new size_y.times {|value_y| arr[value_y] = Random.new.rand 1..10} @@board[value_x] = arr end print "BOARD:" size_x.times{|value_x| print "\n" s...
true
bc989947cd4dc9637c160faee2b608b39add6b29
Ruby
avincentLoyco/yalty-backend
/app/use_cases/presence_policies/verify_employees_not_assigned.rb
UTF-8
1,016
2.578125
3
[]
no_license
module PresencePolicies class VerifyEmployeesNotAssigned include API::V1::Exceptions def call(resource:) @resource = resource return unless resource.respond_to?(:employees) && resource.employees.any? raise LockedError.new( type: resource_type, field: :employees, mes...
true
88809495c138f98425ce73b66a518e154e57d96e
Ruby
finicos/a14z8fy_pound2kg
/bin/a14z8fy_pound2kg
UTF-8
106
2.65625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'a14z8fy_pound2kg' lb = A14z8fyPound2kg::P2k.new puts lb.toKg(ARGV[0].to_f)
true
e35bfbf06b93b87e06633fe82d983203ce87e0ec
Ruby
cookiemccormick/sinatra-mvc-lab-online-web-sp-000
/models/piglatinizer.rb
UTF-8
359
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class PigLatinizer def piglatinize(text = nil) words = text.split(" ") words.map do |word| if /^[aeiou]/i.match(word) "#{word}way" else matches = /^([bcdfghjklmnpqrstvwxyz]+)(.*)/i.match(word) consonants = matches[1] rest = matches[2] "#{rest}#{consonants}ay...
true
f4abb2a77fe956b7f520ac9165b33a4b31cf5ba3
Ruby
pjlowry/blackjack
/lib/dealer.rb
UTF-8
191
2.828125
3
[]
no_license
class Dealer include Person attr_reader :hand def initialize(dealer) @dealer = dealer @hand = [] end def dealer_deal(cards) @hand += cards @hand[0] end end
true
c4b08e1e986665d5e2247024c34c1945ff2dc05a
Ruby
DOV3D/W3D3
/recursion_cw.rb
UTF-8
2,970
4.125
4
[]
no_license
require "byebug" def range(first_num, last_num) # if end < start return [] return [] if last_num < first_num || last_num == first_num # return [first_num] if last_num == first_num #return [start...end] range(first_num, last_num - 1) + [last_num - 1] end # p range(1, 1) # p range(2, 5) def s...
true
2ac8d4fe21cecb50a6b111e572f1048048a3eea3
Ruby
MElisabeth/basicruby
/lib/01_pyramid.rb
UTF-8
621
3.6875
4
[]
no_license
def validation puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?" print "> " n = gets.chomp.to_i if n.even? || n > 25 puts "Erreur" return 0 else return n end end def full_pyramid (n) ((n-1)/2).times do |i| print " " * ((n - 1)/2 - ...
true
51acf8d1881b85810839ac7c5e8a66365a110a9b
Ruby
dpoggi/hotshottt
/hotshottt.rb
UTF-8
3,562
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Controller/Routes class Hotshottt < Sinatra::Base # Configure Sinatra configure do disable :run set :haml, { format: :html5 } end # Neato helpers helpers do # Get [num] unique random numbers with min 1 and max (inclusive) [ceiling] def unique_randoms(num, ceiling) begin a...
true
2f6ce27977267440cc83b51db7f43c2870135f8c
Ruby
stevencch99/railsbook
/區域變數.rb
UTF-8
901
3.65625
4
[]
no_license
#2.3變數的作用域 def info name = "lxee" #在方法中宣告變數 puts name #輸出 end module Message name = "zhht" #在模組中宣告變數 puts name #輸出 end class Test name = "yound" #在類別中宣告變數 puts name end puts name #在作用域外部除存取變數,出現錯誤 #存取區域變數 class First info = "Ruby"; #定義區域變數 def showinfo puts info #在類別內部方法中存取區域變數,出錯 ...
true
f05be7392662f0e5ba1795bda0cfc7fa722861ce
Ruby
cmaxw/sudoku
/lib/sudoku/solver.rb
UTF-8
2,573
3.296875
3
[]
no_license
module Sudoku module Solver class InvalidRowError < ArgumentError; end class InvalidColumnError < ArgumentError; end class InvalidSquareError < ArgumentError; end class Board def initialize(board) if board.match(/.*\.txt$/) @board = File.open(board).read.split("\n").join('') ...
true
f519878ec774dfcfa0cbb5066b096d1f9f9d7b9f
Ruby
yhidetoshi/Ruby_Study
/chapter2/2-1-4.rb
UTF-8
53
3.1875
3
[]
no_license
def add(a, b) sum = a + b puts(sum) end add(1, 2)
true
227b675f0d5fc96b0e5c1db86a025b978a77f960
Ruby
katrinagarloff/wall-ball
/backend/app/controllers/api/v1/players_controller.rb
UTF-8
952
2.515625
3
[]
no_license
module Api module V1 class PlayersController < ApplicationController def index render json: Player.all end def create @player = Player.new(player_params) if @player.save render json: @player else render json: @player.errors, status: :unproces...
true
f88bdd75ec9f2a4d301b98377a833500b839e20f
Ruby
felixhornfeldt/skolarbete
/Skola/Programmering/Progtrammerings filer/Avstämning/avstämning_loopar_felix_hörnfeldt_factorial.rb
UTF-8
179
3.640625
4
[]
no_license
def factorial(from) output = 1 while from >= 1 output = output * from from = from - 1 end return output end from = gets.to_i puts factorial(from)
true
f59ba60fd915b1f11781d40248a7fcabcb57b59f
Ruby
dglunz/pragmatic-studio-ruby
/berserk_player_spec.rb
UTF-8
644
3.125
3
[]
no_license
require_relative 'berserk_player' describe BerserkPlayer do before do @initial_health = 150 @player = BerserkPlayer.new("berserker", @initial_health) end it "does not go berserk when healed up to 5 times" do 1.upto(5) { @player.heal } expect(@player.berserk?).to be_falsey end it "goes berserk when hea...
true
6c0060a3d77ab6672f8fba71463f84f1e1cb702e
Ruby
adriennedomingus/headcount
/lib/district_data_formatter.rb
UTF-8
2,489
2.984375
3
[]
no_license
require_relative 'enrollment_repository' require_relative 'economic_profile_repository' require_relative 'statewide_test_repository' require_relative 'district' require_relative 'data_utilities' class DistrictDataFormatter def read_district_files @contents = DataUtilities.open_csv("./data/Kindergartners in full...
true
aabd5aeaf0765911d4d4cb57d5b5fac3c0becfcd
Ruby
Emanao/tic-tac-toe-rb-v-000
/lib/tic_tac_toe.rb
UTF-8
2,972
4.34375
4
[]
no_license
# Define your WIN_COMBINATIONS constant # Array of the indexes of all possible winning combinations # for a given token WIN_COMBINATIONS = [ [0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6] ] # Define display_board that accepts a board and prints # out the current state. def displa...
true
5cd56ec185c1f627ae9531772141637214c28531
Ruby
aribyassine/Scrabble-Server-PC2R
/lib/pc2r/string.rb
UTF-8
977
2.984375
3
[]
no_license
require 'net/http' require 'json' require 'unidecoder' class String def exist_in_wiktionary? url = "https://fr.wiktionary.org/w/api.php?action=query&titles=#{self.downcase}&format=json" uri = URI(URI.encode(url)) response = Net::HTTP.get(uri) json = JSON.parse(response) !json['query']['pages'].m...
true
04d7e773e7b21f1fba8da6a18e3052f57f05b309
Ruby
lillers1122/grocery-store
/lib/online_order.rb
UTF-8
1,524
3.078125
3
[]
no_license
#Lily Sky Grocery Store - Online Order #Ada C9 require 'awesome_print' require 'csv' require_relative 'order' require_relative 'customer' module Grocery class OnlineOrder < Order attr_reader :customer, :status def initialize(id, products, customer, status) super(id, products) @customer = custom...
true
727240a6a6e27b5fd80b88bb3c832c8868386253
Ruby
romanroibu/RRG
/RRG.rb
UTF-8
2,328
2.65625
3
[]
no_license
#!/usr/bin/env ruby -W0 def show_help puts "Help:", "\n", "-h | -help | --help\t\t\tShow help", "-t | -title | --title [file]\t\tSpecify title page (.tex)", "-o | -output | --output [file]\t\tSpecify output filename (.pdf)", "\n", "All other arguments will be treated as report pa...
true
f6cea91c65d401f4eeee38d7e612d9648f6928ed
Ruby
aroberts/melon
/spec/melon/parsed_arguments_spec.rb
UTF-8
2,044
2.890625
3
[]
no_license
require 'melon/parsed_arguments' describe Melon::ParsedArguments, "when splitting valid arguments" do before do @args = Melon::ParsedArguments.new(%w(-t -b help plate /path/to/file -t 5)) end it "should correctly find the program arguments" do @args.program_arguments.should include("-t", "-b") @ar...
true
7e6a57113fe83741509eecfac7a1efada03a0158
Ruby
Thisforbliss/ruby-intro-to-arrays-lab-prework
/lib/intro_to_arrays.rb
UTF-8
620
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def instantiate_new_array array = [] end def array_with_two_elements building = ["park", "slope"] end def first_element(building) building[0] end def third_element(how) ["park", "slope", "bench"] how[2] end def last_element(chico) ["park", "slope", "bench"] ...
true
ee2b4668c1ff6addd47a4e905e84b83fb3b3783e
Ruby
edy477/ruby_json_bookmarks
/spec/book_spec.rb
UTF-8
1,565
2.828125
3
[]
no_license
# frozen_string_literal: true require 'rspec' require_relative '../lib/bookmark_analyzer' describe BookMarkAnalyzer do let(:bookmarks) { BookMarkAnalyzer.new } it 'should have elements' do size = bookmarks.bookmarks.length expect(size).not_to be(0) end it 'should have method most_bookmarked_projects'...
true
e9e27ac811b8c0f76c9196d77b7751b9ff1dbde0
Ruby
OlgaCoskun/super_viselitsa
/viselitsa.rb
UTF-8
1,013
2.671875
3
[ "MIT" ]
permissive
if Gem.win_platform? Encoding.default_external = Encoding.find(Encoding.locale_charmap) Encoding.default_internal = __ENCODING__ [STDIN, STDOUT].each do |io| io.set_encoding(Encoding.default_external, Encoding.default_internal) end end require_relative "viselitsa_methods" # require_relative "word_reader" ...
true
cebeb01d7ab1b261dea9e3ea85a8128a1c79157a
Ruby
garyferns/object_oriented_programming
/people.rb
UTF-8
764
4.375
4
[]
no_license
class Person attr_accessor :name def initialize(name) @name = name end def greeting puts "Hi, my name is #{@name}" end end class Student < Person def initialize(name, grade) super(name) # sends the initializer to the parent class. @grade = grade end def learn puts "I get it!...
true
7292af77e90e0125d7ebfd96dcc72b595231020d
Ruby
nayrk/CS183
/project2/create_user
UTF-8
2,193
2.703125
3
[]
no_license
#!/usr/bin/env ruby #Full path global variable $path = File.expand_path($0) #Remove filename from fullpath $path.gsub!(File.basename($0),"") #Define error with logging def usage(error,code) $stderr.puts "Error: #{error}" #Append to accounts.log time = Time.now File.open("#{$path}accounts.log","a") do |v| v <<...
true
b05a95e77bee737d4a0657a45db6a9175e8e789f
Ruby
iljas-galiev/ruby_practice
/trello2/app/models/task.rb
UTF-8
321
2.53125
3
[]
no_license
class Task < ApplicationRecord validates :title, presence: true, length: { maximum: 255 } validates :checked, numericality: { less_than_or_equal_to: 1, only_integer: true, greater_than_or_equal_to: 0 } scope :user, -> (user_id) { where("user_id = ?", user_id) } def is_checked self.checked > 0 end end...
true
83ae3f614e3dc3bc491f92df2f8110b66520234e
Ruby
MartinSalias/oca01
/app.rb
UTF-8
838
2.78125
3
[]
no_license
require 'sinatra' require "./lib/juego.rb" get '/' do @@resultado1 = "Posicion 0" @@resultado2 = "Posicion 0" @@game = Eljuego.new @@jugadorTurno = 1 @@dado = 0 erb :juego end post '/dado' do @flgGano = false if (@@jugadorTurno == 1) avanza = @@game.tirarDadoJugador1(4) @@dado = @@game.avanzaJ...
true
57d208e2399d91fa0a1357296bb88650e46af501
Ruby
soundmemes/bot-ruby
/lib/botan.rb
UTF-8
1,517
2.75
3
[]
no_license
module Botan require 'net/http' require 'net/https' require 'json' TRACK_URI_TEMPLATE = 'https://api.botan.io/track?token=%{token}&uid=%{uid}&name=%{name}'; SHORTENER_URI_TEMPLATE = 'https://api.botan.io/s/?token=%{token}&url=%{original_url}&user_ids=%{uid}' def self.track(uid, message, name = 'Message') ...
true
6776953c0c3506562149b6d18a71bbae0576ad62
Ruby
JsonApiClient/json_api_client
/lib/json_api_client/schema.rb
UTF-8
3,580
3.15625
3
[ "MIT" ]
permissive
require 'bigdecimal' module JsonApiClient class Schema module Types class Integer def self.cast(value, _) value.to_i end end class String def self.cast(value, _) value.to_s end end class Float def self.cast(value, _) ...
true
68e4075377c96cf7b001e0977b52dffc1d84f91d
Ruby
ctailor2/foodaAPIchallenge
/spec/factories/dishes.rb
UTF-8
2,216
2.78125
3
[]
no_license
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :dish do factory :fried_rice do association :restaurant, factory: :thai name 'Fried Rice' description 'Thai fried rice with egg, onion, and your choice of chicken or beef' end factory :kungpao_chi...
true
6a301904c764e86be4cdd54badcc33542761e5cd
Ruby
JonathanYiv/chess
/spec/rook_spec.rb
UTF-8
1,457
3.03125
3
[]
no_license
require 'pieces/rook' require 'game' describe Rook do let(:board) { Board.new(true) } let(:rook) { Rook.new([4, 4], true) } before do board.positions[4][4] = rook end context 'movement calculations' do it 'should move horizontally and vertically until the end of the board' do rook.find_possibl...
true
df89d7b547ffd4479b2d822fe96538cf5e2ac7a5
Ruby
cjbrock/playlister-rb
/Lib/Song.rb
UTF-8
432
3.1875
3
[]
no_license
require_relative 'Artist' require_relative 'Genre' class Song attr_accessor :songs, :name, :artist, :genre @@songs = [] def initialize @@songs << self end def self.all @@songs end def genre=(genre) @genre = genre genre.songs << self end def artist=(artist) @artist = artist ar...
true
64f9510757971d77e3d0df8a9056fc97ae1b05ec
Ruby
abchinguk/methods
/methods.rb
UTF-8
120
3.15625
3
[]
no_license
def say_hi (name) puts "Привет, #{name}, как твои дела?" end say_hi "Матвей" say_hi "Саша"
true
7185dfe1a4c0042a8db940018c83322e4cac3655
Ruby
elizavetamoh/task_for_Flatstack
/task.rb
UTF-8
615
3.578125
4
[]
no_license
k = gets.to_i def foo(num) count = 1 result='' for i in 0...num.length j = num[i] if i < num.length - 1 if j == num[i+1] count += 1 else result += count.to_s + num[i] count = 1 end else result += ...
true
0537007e41cf3f4e2baa264fe172f2c94c7b8fbc
Ruby
code-co-op/challenges
/cake_thief/robertwpaul/cake_thief_recursion.rb
UTF-8
546
3.0625
3
[]
no_license
Cake = Struct.new(:weight, :value) def pick_cakes(index, cakes, capacity) return 0 if index == cakes.length || capacity.zero? current_cake = cakes[index] return pick_cakes(index + 1, cakes, capacity) if current_cake.weight > capacity using_current = current_cake.value + pick_cakes(index, c...
true