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
16273bf45c3aa515175ed339690790395e2d7e70
Ruby
luciolang/lucio
/spec/times_spec.rb
UTF-8
943
2.953125
3
[ "MIT" ]
permissive
require 'spec_helper' describe Lucio do context 'times' do before :each do @lucio = Lucio.new end it 'without parameters should return zero' do @lucio.eval('(*)').should == 1 end it 'with one value should return that value' do @lucio.eval('(* 3)').should == 3 ...
true
b87251372c07a86bc15e725f7d926e42f725b1a9
Ruby
threeifbywhiskey/houston
/rb/10.rb
UTF-8
107
3
3
[]
no_license
require 'prime' gen = Prime.each sum = 0 while (n = gen.next) < 2e6 sum += n unless n > 2e6 end p sum
true
c6fcecd38afbad4abb4cd87e59f7474d964549c4
Ruby
ncalibey/Launch_School
/exercises/challenges/med_01/med_106.rb
UTF-8
306
3.671875
4
[]
no_license
# med_106.rb - Grade School class School def initialize @roster = Hash.new { |roster, grade| roster[grade] = [] } end def to_h @roster.sort.to_h end def add(name, grade) (@roster[grade] << name).sort! end def grade(grade) @roster[grade] || [] end end
true
659b32864275f3b7e901c3b80a3ceffca92ccc14
Ruby
AgileVentures/shf-project
/app/services/adapters/company_to_schema_local_business.rb
UTF-8
2,345
2.71875
3
[ "MIT" ]
permissive
#!/usr/bin/ruby require Rails.root.join( 'app/models/concerns/company_hmarkt_url_generator') module Adapters #-------------------------- # # @class Adapters::CompanyToSchemaLocalBusiness # # @desc Responsibility: (an Adapter) takes a Company and creates a # schema.org local business # Note that we...
true
f8cbea3885fee7c775546f7ef7fa6d7902381531
Ruby
lacie-unlam/robolucha
/app/helpers/application_helper.rb
UTF-8
498
2.625
3
[]
no_license
module ApplicationHelper def not_found(klass) content_tag :p, content_tag(:em, "No se encontraron #{klass.model_name.human.pluralize}") end def format_time(time) time ||= 0 mins, secs = time/60, time%60 "#{mins < 10 ? "0#{mins}" : mins}:#{secs < 10 ? "0#{secs}" : secs}" end def mins(time...
true
94c1df7cdbed15db798867ec09c5bc99f72de7b7
Ruby
danieled39/Ruby
/introduction.rb
UTF-8
181
3.15625
3
[]
no_license
puts "Je Mapelle Daniele, et toi?" name = gets.chomp while name != "Jacob" puts "Merci, enchante, #{name.capitalize}" puts "Comment allez vu?" name = gets.chomp.downcase puts "Enchante" end
true
21e6a979f9b6e41963885aa4481a534105892e76
Ruby
parzydlo/darwin
/test/test_sentence_generator.rb
UTF-8
956
3.03125
3
[]
no_license
require_relative '../cfg.rb' require_relative '../grammar_rule.rb' require_relative '../grammar_symbol.rb' require_relative '../sentence_generator.rb' # AB grammar in GNF: # S -> a B # S -> b A # A -> a # A -> a S # A -> b A A # B -> b # B -> b S # B -> a B B nt_s = GrammarSymbol.new(:nonterminal, 'S') nt_a = Grammar...
true
ea6b3496a6aece9e81287408568e2c775f515985
Ruby
brianjscoles/App-Academy
/Coding Challenge practice problems/Challenge 2/01_no_repeats.rb
UTF-8
191
3.453125
3
[]
no_license
def no_repeats(year_start, year_end) def all_uniq?(num) return num.to_s.split("").uniq.length == num.to_s.length end return (year_start..year_end).select{|year| all_uniq?(year)} end
true
9c45cddb1f0d120c3377fb43b3f4312071a71ac5
Ruby
redis/redis-rb
/examples/list.rb
UTF-8
474
2.9375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'rubygems' require 'redis' r = Redis.new r.del 'logs' puts p "pushing log messages into a LIST" r.rpush 'logs', 'some log message' r.rpush 'logs', 'another log message' r.rpush 'logs', 'yet another log message' r.rpush 'logs', 'also another log message' puts p 'contents of lo...
true
12e81a66dd7377db4051b3f192a06c78b7765000
Ruby
altairioffe/ar-exercises
/exercises/exercise_7.rb
UTF-8
908
3.328125
3
[]
no_license
require_relative '../setup' require_relative './exercise_1' require_relative './exercise_2' require_relative './exercise_3' require_relative './exercise_4' require_relative './exercise_5' require_relative './exercise_6' puts "Exercise 7" puts "----------" # Your code goes here ... class Employee validates :first_...
true
de8059787a3bc6764e3fd3d65772b3222dccf4df
Ruby
raisking/ga-final-project
/app/controllers/api/items_controller.rb
UTF-8
1,749
2.59375
3
[]
no_license
class Api::ItemsController < ApplicationController #display all items def index #get all items from db and save to instance variable @items = Item.all render json: @items end #display a specific item def show #get the item id from the url params item_id = params[:id] #use `item_...
true
80884b9ecfa7dd94c119ada26bef4e5e0106b35b
Ruby
garrett-codes/Bakery
/Bakery/app/models/ingredient.rb
UTF-8
639
3.28125
3
[]
no_license
class Ingredient @@all = [] attr_reader :name, :calories def initialize (name, calories) @name = name @calories = calories @@all << self end def ingredients DessertIngredient.all.select {|dessert_ingredeint| dessert_ingredeint.ingredient == self} end def dessert self.ingredients.map...
true
94f1c364b311c9b165a1d9c9a47c546132da7a8d
Ruby
ianslai/seven-langs
/1-ruby/day-2.rb
UTF-8
1,097
3.71875
4
[]
no_license
# Exercise 1. arr = (1..16).to_a (0..3).each { |i| puts arr[(i * 4)..(i * 4 + 3)].join(' ') } arr.each_slice(4) {|i| puts i.join(' ') } # Exercise 2. class Tree attr_accessor :children, :node_name def initialize(structure={}) if structure.size == 1 then singleton = structure.first @node_name ...
true
3c600f2f23f95129f13ba996c65c89fb4e3c6539
Ruby
arafatm/ruby-binary-tree
/lib/binary_search_tree.rb
UTF-8
3,536
4.21875
4
[]
no_license
# Binary Search Tree class BinarySearchTree class Node attr_reader :key, :left, :right # On initialization, the @key variable is set. This is used in the insert # method below as the parent for the @left and @right nodes. def initialize( key ) @key = key @left = nil @right = nil ...
true
70a41e781b54e5b1afbc139b841f271730a7b9ff
Ruby
houtanf/Event-Schedular-DSL
/Ruby/src/schedular.rb
UTF-8
1,085
3.046875
3
[ "Apache-2.0" ]
permissive
class Meeting attr_reader :meeting_name, :start_time, :end_time, :date, :participant_list def name(meeting_name) @meeting_name = meeting_name end def convert_time(time) ('%.2f' % time).sub('.', ':') end def start(start_time) @start_time = convert_time(start_time) end def finish(end_time)...
true
c584f03bd7eb47bd0a8c9d2ed0ec61274ffa547a
Ruby
aldoshin/ruby-calisthenics
/lib/rock_paper_scissors.rb
UTF-8
764
3.421875
3
[]
no_license
class RockPaperScissors RULES = { "R" => 1, "P" => 2, "S" => 3 } # Exceptions this class can raise: class NoSuchStrategyError < StandardError ; end def self.winner(player1, player2) raise NoSuchStrategyError, "Strategy must be one of R,P,S" unless RULES.key?(player1[1]) and RULES.key?(player2[1]) d...
true
60078cb2ba4c72f67e3e30ec90ef928d25cb1b73
Ruby
maykev/assistant_tournament_director
/app/models/bracket_configuration.rb
UTF-8
327
2.640625
3
[]
no_license
class BracketConfiguration < ApplicationRecord serialize :bye_pattern, Array serialize :loser_pattern, Array def loser_position(winner_position) bracket_positions = loser_pattern.select { |pattern| pattern.split('->').first == winner_position } bracket_positions.first.split('->').last e...
true
0c41ec7f38c740cf0aa9b0cf1165fa02afbbc2dc
Ruby
cloudfoundry/bosh
/src/bosh-director/spec/unit/ext_spec.rb
UTF-8
1,168
2.515625
3
[ "LGPL-2.1-only", "LicenseRef-scancode-other-permissive", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode-mappings", "Artistic-2.0", "LGPL-3.0-only", "LicenseRef-scancode-warranty-disclaimer", "GPL-3.0-or-later", "GPL-2.0-or-later", "GPL-3.0-only", "MPL-1.1", "Artistic-...
permissive
require 'spec_helper' describe 'Monkey Patches' do describe '#to_openstruct' do it 'should convert a complex object to an openstruct' do hash = { foo: [{ list: 'test' }], test: 'bad', nested: { hash: 3 }, } result = hash.to_openstruct ostruct = OpenStruct.new( ...
true
cb7c0e9ad5b2338061d6dd69b73fdd2465decd04
Ruby
matheusfig90/codility-lessons
/lesson-1_binary-gap.rb
UTF-8
1,766
3.8125
4
[]
no_license
=begin A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and co...
true
d23621ccd28a9bb77b7c6f782c095ff06147f455
Ruby
kn0/Plerus
/evo/mutagens/x86/add_nop_push_pop_joined.rb
UTF-8
822
2.890625
3
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "BSD-2-Clause-Views" ]
permissive
module Plerus class Evo < Mutagen def initialize super({ title: "Addition Mutation - push pop nop (joined)", scope: SINGLE_MUTAGEN, change: ASM_ADDITION, targets: nil, safe: true }) end def mutate(instruction) # Create an array of possible nops ...
true
3581965d4da4174539f4b7e2e4ca27695b431188
Ruby
fatcatt316/UniversityRenter
/config/initializers/to_ascii.rb
UTF-8
78
2.640625
3
[]
no_license
class String def to_ascii bytes.map{|byte| "&\##{byte};"}.join end end
true
00288546f1fc9d871a59ae69bf66b24665214411
Ruby
theodoro/rubybasico
/test_for.rb
UTF-8
73
2.953125
3
[]
no_license
class TestFor for i in (1..3) x = 1 end puts x end
true
b642eaeda50f73341e401f410a704d8cfe16b725
Ruby
carltonf/carltonf-blog-source
/_plugins/gen-tag-page.rb
UTF-8
849
2.828125
3
[]
no_license
# Based on: http://jekyllrb.com/docs/plugins/#generators # # Usage: Use the tags/index.html as an template for generating each tag page module Jekyll class TagPage < Page def initialize(site, base, dir, tag) @site = site @base = base @dir = dir @name = 'index.html' se...
true
130dafd0402ef09e3d62799f54e325f59e318fc5
Ruby
cjwales/bus_stop_work
/spec/BusStop_spec.rb
UTF-8
580
2.8125
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../BusStop.rb') require_relative('../Person.rb') class BusStopTest < MiniTest::Test def setup() @busstop1 = BusStop.new("George Street") @person1 = Person.new("Stuart", 52) @person2 = Person.new("Neil", 32) @person3 = Person.new("Jamie", 12) end #...
true
7a2f4d579af2a31915b3c8e0dfb72903ce5b11ce
Ruby
DanMcDonald91/Week2WeekendHW
/specs/Rooms_spec.rb
UTF-8
797
2.609375
3
[]
no_license
require('minitest/autorun') require_relative('../Rooms.rb') require_relative('../Songs.rb') require_relative('../Guests.rb') class TestRooms < Minitest::Test def setup @room_1 = Rooms.new("Volcano" , 4) @room_2 = Rooms.new("The Worst Toilet In Scotland" , 2 ) @room_3 = Rooms.new("Mother Superior's Place,"...
true
7ced8f7191cc7821e8d996796a7cfa761f205ca7
Ruby
isaacsanders/mini_java_compiler
/lib/nonterminals.rb
UTF-8
13,699
2.8125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- require_relative 'terminals' require_relative 'intermediate' class Nonterminal include Terminals def epsilon? not @epsilon.nil? end end class Program < Nonterminal def fill_slots(table_entry) @main_class_decl, @class_decl_list = table_entry end def to_ir main_class_ir...
true
15fd7ece06e5df8aacdb9078091f87b94c0cf111
Ruby
JoshuaRogers/ConfBot
/lib/application.rb
UTF-8
1,933
2.765625
3
[]
no_license
#!/usr/bin/ruby require 'rubygems' require 'sqlite3' require_relative 'connection' require_relative 'message' require_relative 'plugin' class Application def initialize @connections = [] @plugins = [] end def start start_database start_plugins start_connections end def stop @db.cl...
true
c041b5f340721794c7134967b375a172c230944f
Ruby
morrxy/ltp
/5/favnum.rb
UTF-8
117
3.09375
3
[]
no_license
# encoding: UTF-8 puts 'your favorite number?' fav = gets.chomp puts "#{ fav.to_i + 1 } is a better favorite number"
true
99ef0df8b1f536b48c3db5284edd9747a21e23c0
Ruby
sa-adebayo/RubyTrack
/Factorial/lib/integer.rb
UTF-8
105
3.15625
3
[]
no_license
class Integer def calculate_factorial (1..self).inject {|result, value| result * value } end end
true
d5916854dad454ab58a83bb62e54d1953822fb15
Ruby
cedricdlb/fast_pencil_quiz
/spec/fast_pencil_quiz_spec.rb
UTF-8
5,018
2.546875
3
[]
no_license
#!/usr/bin/ruby require_relative File.join('..', 'lib', 'fast_pencil_quiz') describe FastPencilQuiz do before(:each) do @fast_pencil_quiz = FastPencilQuiz.new subject { @fast_pencil_quiz } end context "when not yet #run" do subject { @fast_pencil_quiz.q_and_a_candidates } it { should be_a Hash } it { sho...
true
f17044f2d3e6967ef31b0c83831619ee5be68928
Ruby
txus/rexpl
/lib/rexpl/output.rb
UTF-8
2,696
3.453125
3
[ "MIT" ]
permissive
require 'ansi' module Rexpl # Utility module to abstract output-related stuff, like printing banners or # graphically representing stacks. class Output extend ANSI::Code class << self # Prints the welcome banner and a bit of instructions on how to use the # interactive console. def pri...
true
3dffa945c3dd3bcd2793703a9972bef3c22fb5be
Ruby
gitter-badger/ossert
/lib/ossert/presenters/project_v2.rb
UTF-8
4,090
2.59375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Ossert module Presenters module ProjectV2 CLASSES = %w( ClassE ClassD ClassC ClassB ClassA ).freeze KLASS_2_GRADE = { 'ClassA' => 'A', 'ClassB' => 'B', 'ClassC' => 'C', 'ClassD' => 'D', ...
true
8f9b779bebcf5be3bccb558e8075c5fefc0890e5
Ruby
semahawk/euler
/ruby/18.rb
UTF-8
771
4.25
4
[]
no_license
#!/usr/bin/env ruby # The items (values to make the biggest numbah), sum (answer, actually) and the triangle items = [] sum = 0 striangle = <<TRIANGLE 3 7 4 2 4 6 8 5 9 3 TRIANGLE # Transform this TRIANGLE shown above, into array(s) # # 3 # 7 4 ==> [[3], [7, 4], [2, 4, 6], [8, 5, 9, 3]] # 2 4 6 # 8 5 9 3...
true
cceaa9fedff6d676acd579ba0d8fe590f6c72030
Ruby
Zacharae/spring16ruby
/lib/string_calculator.rb
UTF-8
245
3.65625
4
[]
no_license
class StringCalculator def self.add(input) if input.empty? 0 else numbers = input.split(",").map { |integer| integer.to_i } numbers.inject(0) { |sum, number| sum + number } end end end # x = StringCalculator.new # x.add("55")
true
bc103cf3935f09f924e345bff2118f8188a9d425
Ruby
hannahlcameron/api-muncher
/lib/edamam_api_wrapper.rb
UTF-8
933
2.703125
3
[]
no_license
require 'httparty' class EdamamApiWrapper class EdamamError < StandardError; end BASE_URL = "https://api.edamam.com/search" ID = ENV["EDAMAM_API_ID"] KEY = ENV["EDAMAM_API_KEY"] def self.list_recipes(query) full_url = URI.encode(BASE_URL + "?q=" + query + "&app_id=" + ID + "&app_key=" + KEY + "&from=0&...
true
8648cb9b65e09925550c68f13838c805bec7f031
Ruby
hasumikin/mrubyc
/mrblib/numeric.rb
UTF-8
599
3.21875
3
[ "BSD-3-Clause" ]
permissive
# # Integer, mrubyc class library # # Copyright (C) 2015-2021 Kyushu Institute of Technology. # Copyright (C) 2015-2021 Shimane IT Open-Innovation Center. # # This file is distributed under BSD 3-Clause License. # class Integer # times def times i = 0 while i < self yield i i += 1 end ...
true
37b62914d1de816a1cb58408d1b1b4262b9b2c11
Ruby
liptiavenica/tugas_ruby_basic
/player.rb
UTF-8
241
3.296875
3
[]
no_license
class Player attr_accessor :nama, :blood, :manna def initialize nama @blood=100 @manna=40 @nama = nama end def serang @manna -=20 end def diserang @blood -=20 end def game_over @manna == 0 || @blood == 0 end end
true
4002e9c39985da9f866f21bdfb85667bd5d5ca0d
Ruby
aishwaryaramachandran/jungle-rails
/app/models/user.rb
UTF-8
604
2.5625
3
[]
no_license
class User < ActiveRecord::Base has_secure_password has_many :reviews has_many :orders validates :email, presence: true, uniqueness: {case_sensitive: false} validates :name, presence: true validates :password, confirmation: true, length: { minimum: 6 } def self.authenticate_with_credentials(email, passw...
true
b4ac849be8b1dc705caa8874c80d6258114c376b
Ruby
jmmastey/code_tests
/multi_armed_bandit/lib/strategies/epsilon_greedy_strategy.rb
UTF-8
359
3.15625
3
[]
no_license
class EpsilonGreedyStrategy attr_accessor :name, :epsilon def initialize(name: "EpsilonGreedy", epsilon: 10) @name = name @epsilon = epsilon end def choose_variant(variants) if exploring? variants.sample else variants.sort_by(&:expectation).last end end def exploring?...
true
a015b8c3ea22e22b1ea35752811659c2084ae51b
Ruby
shiba6v/test_sim
/app/controllers/home_controller.rb
UTF-8
1,973
2.8125
3
[]
no_license
class HomeController < ApplicationController def top end def result #手の名前、ステータスの管理 @hand = ["グー","チョキ","パー"] #プレイヤー(必殺の手,体力,攻撃,テクニック) #プレイヤー1を@a、プレイヤー2を@bと置く。 @a = [params[:num1],params[:hpt1],params[:atk1],params[:tec1]].map{|w| w=w.to_i} @b = [params[:num2],params[:hpt2],params[:atk2],pa...
true
f617bcc903a3910de63277c707c4fd4f3ffb2bd2
Ruby
MatLock/batalla_naval
/batalla_naval/features/step_definitions/disparo_step.rb
UTF-8
1,567
2.890625
3
[]
no_license
require_relative '../../app/models/Tablero.rb' require_relative '../../app/models/Barco.rb' Given(/^a board with dimension "(.*?)" x "(.*?)"$/) do |x, y| #@tablero = Tablero.new(x.to_i,y.to_i) visit '/mipagina' fill_in(:ancho, :with => x) fill_in(:alto, :with => y) click_button "crearTablero" end Given(/^...
true
870a940dfe07c11f36ce3798dcc56a739fd186e4
Ruby
eijimine/object-oriented-programming-class-methods-and-class-variables
/vampires.rb
UTF-8
1,215
3.6875
4
[]
no_license
require 'pry' class Vampire attr_accessor :name, :age, :in_coffin, :drank_blood_today @@coven = [] def initialize(name, age) @name = name @age = age @in_coffin = true @drank_blood_today = true end def self.create(name, age) new_vamp = Vampire.new(name, age) @@coven << new_vamp ...
true
57b922a02b6e49d594fda7b7ea4bf33c57ec1ae7
Ruby
caok/knowledge
/ruby/error127/badcmd-redir.rb
UTF-8
785
2.75
3
[]
no_license
# Lo and behold this works.{{{shot(3b)}}} # It seems like it has validated our theory. # In fact, though, this is a false positive. And if we continued forward # with this incorrect understanding, it could send us down some blind # alleys in the future. And yes, I speak from experience. # We can start to see that ...
true
caec03310725169bb0896510aeecccac873918b8
Ruby
kawamataryo/eratos
/lib/eratos.rb
UTF-8
492
3.328125
3
[]
no_license
require 'set' def eratos(max_num) # ステップ1 探索リストの作成 search_list = [] (2..max_num).each do |num| search_list << num end # ステップ2, 3 探索リストのふるい落とし i = 0 while search_list[i] < Math.sqrt(max_num) search_list.each do |composit_num| if composit_num > search_list[i] && (composit_num % search_list[i...
true
0130fb7c4e4f7b867210a1c8e4b40042185be567
Ruby
SpiderStrategies/sensu-resque-stale-jobs
/stale-resque-jobs.rb
UTF-8
1,980
2.625
3
[]
no_license
#!/usr/bin/env ruby # # A sensu plugin to determine if there are jobs sitting in the timestamps set too long # require 'rubygems' if RUBY_VERSION < '1.9.0' require 'sensu-plugin/check/cli' require 'redis' class RedisChecks < Sensu::Plugin::Check::CLI option :host, :short => "-h HOST", :long => "--host HOST"...
true
5592a5b251a45156cf0ff7664d97950bd4e294db
Ruby
JamRamPage/CRICKETLEAGUE
/app/models/batting_innings.rb
UTF-8
3,504
2.984375
3
[]
no_license
class BattingInnings < ApplicationRecord #BattingInnings is linker table between Innings and Player: belongs_to :Innings belongs_to :Player #BattingInnings also has two other Player fields (representing up to two) #members of other team that got the current batsman out. belongs_to :bowler, :class_name => 'P...
true
eb7d4b934e409fea6825fb5b2a7462a54b5120c2
Ruby
vrthra/clone-unit-coverage
/graphs/bin/coverage.rb
UTF-8
1,155
2.96875
3
[]
no_license
#!/usr/bin/ruby require 'rubygems' require 'SVG/Graph/Plot' # Data sets are x,y pairs # Note that multiple data sets can differ in length, and that the # data in the datasets needn't be in order; they will be ordered # by the plot along the X-axis. projection = [] begin File.open('summary/coverage-data.txt').each_line...
true
400bef1301fe5baf368c76896cc5d04d28ce22e3
Ruby
MaryBLee/Employee-Departments
/development.rb
UTF-8
1,838
3.703125
4
[]
no_license
require './department.rb' #Create a new department sales = Department.new(name: 'Sales') finance = Department.new(name: 'Finance') marketing = Department.new(name: 'Marketing') #Create a new employee rizzo = Employee.new(name: 'Rizzo', email: 'rizzo@gmail.com', phone: '919-123-4567', salary: 60000) sandy = Employee.n...
true
09829eec13148e17bd320a0c349b857d1735c1dc
Ruby
rmamdouh/final
/features/sales_filter_feature.rb
UTF-8
843
2.578125
3
[]
no_license
Feature: display list of good filtered by check box As a concerned parent So that I can quickly browse movies appropriate for my family I want to see movies matching only certain MPAA ratings Background: sales in database Given the following movies exist: | good | price | city | date ...
true
2ec64e7c597937c1990a82af6fdddd0fdac86df3
Ruby
Apemb/ruby_connect_4
/app/view.rb
UTF-8
150
2.625
3
[]
no_license
class View def initialize console @console = console end def get_player_input grid, player @console.puts 'C\'est au joueur 1' end end
true
bdb56bc445e69388d9809cb291aeccc16e46be2e
Ruby
j-rods/lrthw
/Chap14/ex14.rb
UTF-8
694
4.25
4
[]
no_license
#To run, ruby ex14.rb <yourname> # gets the first argument / used to get 1 argument user_name = ARGV.first #variable prompt prompt = 'answer below ' puts "Hi #{user_name}." puts "I'd like to ask you a few questions." puts "Do you like me #{user_name}? " puts prompt likes = $stdin.gets.chomp puts "Where do you live...
true
a9fb4b0fae25dd11097a1fabf2e943de11893810
Ruby
MrPowers/project_euler
/020/code.rb
UTF-8
176
3.546875
4
[]
no_license
def factorial(n) (1..n).to_a.inject(&:*) end def sum_digits(n) n.to_s.split("").inject(0) do |memo, n| memo += n.to_i memo end end p sum_digits(factorial(100))
true
49dc8372fccc1d9a2e45fee181a5565c8eb0b9f2
Ruby
Yves53/Yves53.github.io
/Project Euler/ProblemSix/problem_six.rb
UTF-8
296
3.4375
3
[]
no_license
# Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. multi_sum = 0 add_sum = 0 (1..100).each do |i| multi_sum += i**2 add_sum += i end puts "The difference between the two is #{(add_sum**2) - multi_sum}" # answer = 25164150
true
f52692450295da39477cf1dcde9f132bd188884e
Ruby
h55nick/project3
/app/models/question.rb
UTF-8
2,013
2.8125
3
[]
no_license
# == Schema Information # # Table name: questions # # id :integer not null, primary key # q :string(255) # created_at :datetime not null # updated_at :datetime not null # interest_id :integer # class Question < ActiveRecord::Base attr_accessible :q has_and_belongs...
true
964d387315495a36dd402eb0077a7e23127bac16
Ruby
ryanttb/internet_monitor
/lib/retrievers/hdi_parser.rb
UTF-8
701
2.609375
3
[]
no_license
class HDIParser require 'csv' include Amatch def data(options = {}) data = [] filename = options[:filename] csv = CSV.read(filename, { :headers => true }) csv.each do |row| country = Country.find_by_iso3_code(row['ISO Code']) next unless country ...
true
f63fd90104519e2e16cf9d610565ead5d353235b
Ruby
aimeesophia/pair-programming
/spec/arrays_spec.rb
UTF-8
1,253
3.671875
4
[]
no_license
require 'pairing.rb' describe 'plus_1' do it 'returns +1 to each entry in the array' do expect(plus_1([1, 2, 3, 4, 5])).to eq [2, 3, 4, 5, 6] end end describe 'arr_sort' do it 'returns the array sorted' do expect(arr_sort([1, 3, 5, 4, 2])).to eq [1, 2, 3, 4, 5] end end describe 'plus_1_and_sort' do ...
true
56d820699ab7a92116564244c6bd93549a49bd74
Ruby
haolhaol/rake-builder
/lib/rake/once_task.rb
UTF-8
560
2.671875
3
[ "MIT" ]
permissive
require 'rake/tasklib' module Rake # A task whick is no longer needed after its first invocation class OnceTask < Task attr_accessor :invoked attr_accessor :timestamp def self.define_task(*args, &block) task = super(*args, &block) task.timestamp = nil task.invoked = false task ...
true
5e367b509b1b36003a0e1cb7ac1a5f4b05956342
Ruby
MarcRF/RUBY1
/ex2.rb
UTF-8
531
3.4375
3
[]
no_license
def grr(x,y) lettres =[] lettres = x.split("") print lettres lettresHSC=[] lettres.each { |string| lettresHSC << string.ord } puts lettresHSC lettresHSC.each {|x| x += y print "#{x.chr}" } end grr("ab!bc", 1) puts " What a string! Bmfy f xywnsl!" =begin mots = x.split("!") print mots ["ryan", "j...
true
e5ada7b70b517d08131f47641df1625183981dc3
Ruby
jacqueline-lam/project-euler-multiples-3-5-online-web-pt-090919
/lib/multiples.rb
UTF-8
507
3.796875
4
[]
no_license
# Enter your procedural solution here! # list all natural numbers below limit that are multiples of 3 or 5 # collects correct multiples of natural numbers below limit def collect_multiples(limit) multiples = [] (1...limit).each do |num| multiples << num if (num % 3 == 0 || num % 5 == 0) end return multiple...
true
bb6d8dc6d1d75b2ce7ea9edf2a8be036f304d90b
Ruby
bachya/cliutils
/lib/cliutils/ext/hash_extensions.rb
UTF-8
4,658
3.3125
3
[ "MIT" ]
permissive
# Hash Class # Contains many convenient methods borrowed from Rails # http://api.rubyonrails.org/classes/Hash.html class Hash # Deep merges a hash into the current one. Returns # a new copy of the hash. # @param [Hash] other_hash The hash to merge in # @return [Hash] The original Hash def deep_merge(other_has...
true
edb9756d775ac6bba8e70cad2a4183ef19019522
Ruby
neilma/survey
/lib/models/response.rb
UTF-8
490
2.609375
3
[]
no_license
# frozen_string_literal: true module Models class Response attr_reader :email, :participant, :submitted_at, :answers def initialize(email:, employee_id:, submitted_at:, answers:) @participant = assign_participant(email: email, participant_id: employee_id) @submitted_at = submitted_at @answ...
true
88d5164adef062e3904556e534eae513d2448b21
Ruby
mjthompsgb/angel_api_gem
/app/models/angel_api_gem/role.rb
UTF-8
640
2.546875
3
[ "MIT" ]
permissive
module AngelApiGem class Role attr_accessor :id, :role, :confirmed, :name, :type, :user_id, :bio, :followers, :angel_url, :image_url def initialize(role) @id = role["id"] @role = role["role"] @confirmed = role["confirmed"] @name = role["tagged"]["name...
true
d89cbb7a2727d0d38e90340da2229fdd1a924d08
Ruby
brandonseroyer/buy_car
/lib/buy_car.rb
UTF-8
620
3.375
3
[]
no_license
class Vehicle define_method(:initialize) do |make, model, year| @make = make @year = year @model = model end define_method(:age) do current_year = Time.new().year() age = current_year.-(@year) end define_method(:worth_buying?) do american_cars = ["Chrysler", "Ford", "GM", "Chevrolet"...
true
c5df5e7070bbfcdb74b77920020262d4e416fd76
Ruby
gionaufal/rubymonk
/chapters/hashes.rb
UTF-8
574
3.765625
4
[]
no_license
# iterate with a hash via #each. Remember that hashes have keys and values restaurant_menu = { "Ramen" => 3, "Dal Makhani" => 4, "Coffee" => 2 } restaurant_menu.each do |item, price| restaurant_menu[item] = price * 1.1 end # one can use the keys and values methods in hashes. They produce arrays restaurant_menu = { ...
true
4ab939c46209fbef92a8a25c06944202bf40fa98
Ruby
huyha85/method_caching
/lib/method_caching.rb
UTF-8
1,601
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module MethodCaching module ClassMethods def method_caching(identifier_attr = :id) @identifier = identifier_attr.to_sym self.send(:include, InstanceMethods) end def cache_method(method, options = {}) old = "_#{method}".to_sym alias_method old, method define_method method do ...
true
3c47ee560b681cbee50a69493c37eca192fe3a55
Ruby
taiki45/unfav-counter
/unfav.rb
UTF-8
1,991
2.65625
3
[]
no_license
# -*- coding: utf-8 -*- require 'json' require 'yaml' require 'twitter/json_stream' require 'twitter' require 'ykk' module UnfavCounter class << self def config @config ||= Hash[YAML.load(open(File.expand_path('../config.yaml', __FILE__))).map {|k, v| [k.to_sym, v] }] end def client @client ...
true
4711f9554defafd2bd6d9365586016f19b32ccc4
Ruby
freecode23/RubyProjects
/solutions_and_lives/animals-master/spec/lion_spec.rb
UTF-8
360
2.65625
3
[]
no_license
require_relative '../lion' describe Lion do describe '#initialize' do it 'should create instance of an lion' do lion = Lion.new("scar") expect(lion).to be_an(Lion) end end describe '#talk' do it 'should return the roar of the lion' do lion = Lion.new("scar") expect(lion.talk)....
true
479449ee71b33f3d7e99c5f5995edad639fe90b9
Ruby
h0m3brew/Evaluarium
/app/services/project_program_summary_updater.rb
UTF-8
2,385
2.671875
3
[]
no_license
# frozen_string_literal: true # # This class manages the logic behind determining how a Summary's scores (JSONB) should # be updated, and then performs the update. # class ProjectProgramSummaryUpdater PROGRAM_TYPE_METHODS = { project_follow_up: :take_latest_evaluation, competition: :take_all_evaluations }....
true
e2773b63b7af554dccf2824184bb08a4ab310ff7
Ruby
mike-shock/Ruby-Raspberry_Pi_IoT
/demo/demo_bh1750.rb
UTF-8
275
2.6875
3
[ "MIT" ]
permissive
#!/usr/bin/ruby $LOAD_PATH << "../lib" unless ARGV[0] == "gem" require 'iot/bh1750' sensor = IoT::BH1750.new(0x23, 1) printf "=== %s DEMO ===\n", sensor.name t = 6 t.times do |n| printf "%02d Luminosity Level: %f lx (%f)\n", n, sensor.read, sensor.lux sleep(0.5) end
true
f86483d56d5f00f980a7d850af32b5d2826903ab
Ruby
chaecramb/weekend2_homework
/main.rb
UTF-8
1,201
2.953125
3
[]
no_license
require 'pry-byebug' require_relative 'methods' require_relative 'chain' require_relative 'hotel' require_relative 'room' require_relative 'person' chain = Chain.new("Vault Tec's Wasteland Fallout Shelter Network") hotels = [ ["Vault 13", "West of Shady Sands, Capital Wasteland, California"], ["Vault 101", "North...
true
efcac2b624becd4993f3e4a48fc2579913b2f596
Ruby
jbcden/tic-tac-toe
/lib/tic_tac_toe/game_errors.rb
UTF-8
450
2.546875
3
[]
no_license
class GameErrors class InvalidActionError < StandardError def initialize(msg="This space has already been marked") super end end class InvalidCoordinateError < StandardError def initialize(msg="An invalid coordinate was passed in, please try again") super end end class InvalidCha...
true
dad48566a45b9549cd17136509cae69750a228ae
Ruby
alexvicegrab/tangoLyricsDB
/rails_app/app/models/translation.rb
UTF-8
2,143
2.546875
3
[ "MIT" ]
permissive
class Translation < ActiveRecord::Base include Filterable include UrlHelper belongs_to :song, counter_cache: true belongs_to :language, counter_cache: true belongs_to :translator, counter_cache: true # Scopes # Next line overrides scoping in song Model, hence commented out # default_scope { order(...
true
e4f94637363ce0d8aa3fc29be3cdb2f4bded694f
Ruby
chris-parker/learn_to_program
/ch12-new-classes-of-objects/party_like_its_roman_to_integer_mcmxcix.rb
UTF-8
578
3.703125
4
[]
no_license
def roman_to_integer roman roman = roman.upcase roman.gsub!("IX", "9 ") roman.gsub!("IV", "4 ") roman.gsub!("XC", "90 ") roman.gsub!("XL", "40 ") roman.gsub!("CM", "900 ") roman.gsub!("CD", "400 ") roman.gsub!("M", "1000 ") roman.gsub!("D", "500 ") roman.gsub!("C", "100 ") ro...
true
f5bcce2e68cd52a42f7ab409081e3b1a86a6dc55
Ruby
pikesley/correctiondose
/spec/presenters/presenters_spec.rb
UTF-8
3,263
2.875
3
[ "MIT" ]
permissive
describe CarbohydrateIntakePresenter do before :each do DatabaseCleaner.clean end let(:carbs) { create :carbohydrate_intake } let(:decorated_carbs) { CarbohydrateIntakePresenter.new carbs } it 'presents as a whole table row' do expect(decorated_carbs.to_tr).to eq ( "<tr class='carbohydrate-int...
true
ec27708df3e505c4f326ed67918f431d27df3538
Ruby
shujishigenobu/genome_annot
/app/AEGeAn/parse_parseval_by_locus.rb
UTF-8
1,408
2.5625
3
[ "MIT" ]
permissive
in_locus_data = false seqid, range = nil next_is_ref = false next_is_pred = false ref_gene, pred_gene = nil data = [] File.open(ARGV[0]).each do |l| # p next_is_ref if m = /\|---- Locus:/.match(l) seqid, range = nil next_is_ref = false next_is_pred = false ref_gene, pred_gene = nil data << {:...
true
ead8b6e72c20fb91042c6d699aaa32c3bde1feb8
Ruby
TheNova22/algorithms
/leetcode/Ruby/No150.evaluate_reverse_polish_notation.rb
UTF-8
1,631
4.34375
4
[]
no_license
=begin Difficulty: Medium Desc: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is always valid. That means the exp...
true
d272563c634c51875206234af46406e7b1f2f39c
Ruby
Uchoosecode/badges-and-schedules-online-web-ft-120919
/conference_badges.rb
UTF-8
710
3.59375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker(name) i = 0 while i < name.length puts "Hello, my name is #{name}." i += 1 end return "Hello, my name is #{name}." end def batch_badge_creator(array) badges = [] array.each do |name| badges << "Hello, my name is #{name}." end return badges end def assign_rooms(speaker...
true
4d3898c998541bddc49dba14077273da58090acc
Ruby
pedz/Snapper
/lib/parse_error.rb
UTF-8
577
2.9375
3
[]
no_license
class ParseError < RuntimeError def self.from_exception(e, history) return e if e.is_a?(ParseError) n = ParseError.new(e.message, history) n.set_backtrace(e.backtrace) n.set_class(e) n end def initialize(text, history) @history = history @text = [ text ] @klass = self.class en...
true
1c1ba244f9e65e69afa1d847275d34736f26b966
Ruby
hindenbug/puzzles
/battle_ship/spec/ship_spec.rb
UTF-8
1,411
3.140625
3
[]
no_license
require "rspec" require_relative "../battle_field" require_relative "../ship" describe Ship do let(:field) { BattleField.new(10, 10) } let(:ship) { Ship.new(field, :aircraft_carrier, 1, 1, :h) } it "should deploy a new ship of the given type" do ship.ship_type.should eql :aircraft_carrier ship.directi...
true
7144b564bae430fb8f0ec800e7bdc6536ffc8210
Ruby
LehmRob/tmp
/rb/block/proc1.rb
UTF-8
933
4.3125
4
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby # Simple panda example myproc = Proc.new do |animal| puts "I love #{animal}!" end myproc.call("Panda") # Show example def make_show_name(show) Proc.new{|host| show + " mit " + host} end show1 = make_show_name("Wetten das") show2 = make_show_name("Schlag den Raab") puts show1.call("Thomas Gott...
true
0f620620465a8b0278b8caa4b295ca899e3248dc
Ruby
vaiorabbit/JumpPointSearch
/JumpPointSearch.rb
UTF-8
17,685
3.203125
3
[ "Zlib" ]
permissive
# coding: utf-8 # # Ref.: Online Graph Pruning for Pathfinding on Grid Maps [D. Harabor and A. Grastien. (2011)] # http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf # # Usage: $ ruby JumpPointSearch.rb road_map.txt [-dijkstra] [-astar] class String # Ref.: http://stackoverflow.com...
true
222e07008f383271f77a89f8480abc6618e6ee40
Ruby
shokai/linda-ruby
/lib/linda/test/tuple.rb
UTF-8
2,705
2.78125
3
[ "MIT" ]
permissive
module Linda module Test module Tuple def test_array_tuple tuple = target_tuple.new([1,2,:a]) assert_equal tuple.data, [1,2,:a] assert_equal tuple.type, Array assert_equal JSON.parse(tuple.to_json), [1,2,"a"] end def test_hash_tuple tuple = target_tuple....
true
62f8831aab5ab3a3adea0131e9fe640bcb89993e
Ruby
vagmi/spell_checker
/mangle.rb
UTF-8
123
2.5625
3
[]
no_license
#!/usr/bin/env ruby $:.unshift("./lib") require 'mangler' Mangler.new.mangle_line(ARGV.first).each { |word| puts word }
true
e8b87dd885ee040a682cf48be181fc887362abd5
Ruby
gervolinotm/WK2_CodeClanCaraoke
/room.rb
UTF-8
690
3.28125
3
[]
no_license
class Room attr_reader :room_limit attr_accessor :guests, :song_list def initialize(guests, song_list, room_limit) @guests = guests @song_list = song_list @room_limit = room_limit end def check_in_guests(guest_name) @guests.push(guest_name) end def check_out_guest(guest_name) @guest...
true
475bd386cd52ab1c84d4e78ddc9b1d32d40a9a81
Ruby
Cireou/ruby-oo-practice-flatiron-zoo-exercise-yale-web-yss-052520
/run.rb
UTF-8
577
3.34375
3
[]
no_license
require_relative "lib/Animal.rb" require_relative "lib/Zoo.rb" require 'pry' #Test your code here dog1 = Animal.new("Dog", 1, "bobbers") dog2 = Animal.new("Dog", 2, "hi") zoo1 = Zoo.new("Zoo1", "New York") zoo2 = Zoo.new("Zoo2", "New York") dog1.nickname dog1.weight dog1.species dog1.weight = 5 dog1.zoo = zoo1 dog...
true
0af498997470dfb1e6aa8ab667158c5bb43981c1
Ruby
knomedia/yesman
/lib/yesman/templater.rb
UTF-8
397
2.8125
3
[ "MIT" ]
permissive
require 'erb' class Templater def merge class_type, template_path @class_type = class_type @template_path = template_path load_template apply_class_to_template @output end def load_template @loaded_template = ERB.new File.read( @template_path ) end def apply_class_to_template ...
true
f232777dd0eee47451951d852edf69ce56f7f211
Ruby
robotscissors/quizbot
/app/models/score.rb
UTF-8
1,073
2.859375
3
[ "MIT" ]
permissive
class Score < ActiveRecord::Base belongs_to :user belongs_to :question def self.overall_score(user) # calculate the overall score @current_place = Score.current_place(user.id) @points = Score.where(:user_id => user.id).sum(:point) @possible_points = Score.where(:user_id => user.id).where.not(:poi...
true
e5a84445d3729fd1cd0fd830b62a77a0710b5a64
Ruby
denineguy/binary_search
/binary_search.rb
UTF-8
1,311
4.15625
4
[]
no_license
#Binary vs Linear Searching #Write an example demonstrating Binary Search. Write an example demonstrating Linear Search. # Hint: A linear search looks down a list, one item at a time, without jumping. in complexity # terms this is an O(n) search - the time taken to search the list gets bigger at the same rate # as t...
true
3939e10ce16548d7e894f65e77e1ce5bf2ab4515
Ruby
Luniak/mctechtree
/lib/item.rb
UTF-8
2,118
2.640625
3
[]
no_license
# encoding: utf-8 class UndefinedItemError < StandardError; end class CraftBuilder < SimpleDelegator def makes count, machine, ingredients, extra craft = Craft.create(machine, __getobj__, count, ingredients, extra) self.crafts << craft craft end end class PendingItem attr_accessor...
true
8792578671f06ebd34548d3fd965b82142cfba90
Ruby
Lastbastian/Ruby-me
/Week_17/hitchhikersguide.cgi
UTF-8
310
2.59375
3
[]
no_license
#!/usr/local/bin/ruby # Name: Chris Bastian - peacethrubeats@gmail.com # Date: 2015-12-20 Sunday # File: hitchhikersguide.cgi # Desc: Final Test Problem puts "Content-type: text/html" puts require "open-uri" string = "" url = "/users/dputnam/greetings.txt" open(url) do |content| content.each_line { |line| string...
true
eb3a58d3d14c773a8dc9f48873f4a1456865ed0e
Ruby
shuito1992/grokking_algorithms
/dijkstra.rb
UTF-8
2,012
3.390625
3
[]
no_license
@graph = { start:{ a: 2, b: 6 }, a: { fin: 1 }, b: { a: 3, fin: 5 }, fin: {} } @costs = { a: 6, b: 2, fin: Float::INFINITY } @parents = { a: :start, b: :start, fin: nil } @processed = [] def find_lowest_cost_node(costs) min = @costs.select{|node,cost| !@proce...
true
76cff98c17f073d74dfe7e4e732ed19f915fd1fc
Ruby
dantecrovetto/modulo2-prueba
/prueba.rb
UTF-8
1,072
2.9375
3
[]
no_license
require 'net/http' require 'openssl' require 'json' url = 'https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_' key = 'key=jwW2RykNrevmb9HjNeYzR2rnxkB0DL0yQIRDczc5' def request(url,key) uri = URI(url+key) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Get.new(uri) ...
true
d8569f2291af2b2a8b73415264521b6925f06650
Ruby
JannikWibker/tm_vm
/src/tm_re.rb
UTF-8
1,427
2.703125
3
[ "MIT" ]
permissive
module TM ID = '[_a-zA-Z]+[_a-zA-Z0-9]*' def TM.array(contents) inner = '((?:' + contents + '\s*,\s*)*(?:' + contents + '))?' '\[\s*' + inner + '\s*\]' end def TM.array_no_capture(contents) inner = '(?:(?:' + contents + '\s*,\s*)*(?:' + contents + '))?' '\[\s*' + inner + '\s*\]' end def ...
true
cf84ae6e452e24a4af0a690c63c0e5205d94cbc8
Ruby
fabientownsend/echoserver
/spec/echo_server_spec.rb
UTF-8
552
2.703125
3
[]
no_license
require 'spec_helper' require 'echo_server' RSpec.describe EchoServer do before(:each) do @input = StringIO.new("a\nb\nexit\n") @output = StringIO.new @server = EchoServer.new(@input, @output) end it "reads first input" do expect(@server.read).to eq("a\n") end it "prints last input" do ...
true
53fb6b69f251cd6338fdbb3904663045dbc41fae
Ruby
brandonjyuhas/wdi-practicework
/superheroes/seeds.rb
UTF-8
3,894
2.984375
3
[]
no_license
require_relative './hero' Hero.create( [ { alt: "Salvador Hernandez", name: "Brooklyn Boolean", super_power: "True/False Vision", cape: true, role: "hero", img: "/images/1.jpg", weakness: "Gray Area" }, { alt: "Brandon Yuhas", name: "The Triple Data Distiller", super_power: "Argues with Data and returns...
true
975afdb7f174e334a6ea1a644bba71e6b2c60b2a
Ruby
lucasluitjes/midi_bank_controller
/main.rb
UTF-8
981
2.515625
3
[]
no_license
require 'unimidi' require 'pp' require 'pry' # patch module AlsaRawMIDI class Input def gets sleep 0.01 until enqueued_messages? msgs = enqueued_messages @pointer = @buffer.length msgs end end end class Reader def initialize reload_controller @input = UniMIDI::Input.use(:...
true
e646345581ac1c1c7ec30dfffbc77ab1517584f5
Ruby
mgurbanzade/thinknetica
/Ruby_Idioms_Style_Guide/routes.rb
UTF-8
607
3.171875
3
[]
no_license
require_relative 'instance_counter' require_relative 'validation' class Route include InstanceCounter include Validation attr_reader :stations, :name def initialize(first, last) @stations = [first, last] validate! @name = "#{first.name} - #{last.name}" register_instance end def add_stati...
true
84970f9362b0c25724f262c37297b262d48a728d
Ruby
jacekwargol/odin-project
/connect_four/lib/game.rb
UTF-8
664
3.5625
4
[]
no_license
require_relative 'board' class Game attr_reader :board WHITE_DISC = "\u26AA" BLACK_DISC = "\u26AB" @player1 = def initialize @board = Board.new end def start_game puts "Player 1, choose color:\n1.Black\n2.White" until (player_choice = gets.chomp.to_i).between?(1, 2) do puts "Incorrec...
true
4ad67488fce30c953243307b811a970bb6cabfe4
Ruby
IIIIIIIIll/RubyQuizess
/Quiz10/question5.rb
UTF-8
220
3.328125
3
[]
no_license
class Something def meaning_of_life @result ||= result "The meaning of life is the number #{@result}" end def result 50 end def initialize @result=20 end end p Something.new.meaning_of_life
true
38a778f7082d2bd7242bf46ef16ee9bfc390b83a
Ruby
asnr/algorithm-design-manual
/all_subsets.rb
UTF-8
713
3.546875
4
[]
no_license
def all_subsets(set_size, current_subset, next_idx) if next_idx == set_size print_subset current_subset return end [true, false].each do |include_element| current_subset[next_idx] = include_element all_subsets(set_size, current_subset, next_idx + 1) end end def print_subset(subset) print '{'...
true