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
fcb6359b73fd129b7564cd496f173fc4c9fa994f
Ruby
botandrose/decisive
/lib/decisive/template_handler.rb
UTF-8
2,363
2.59375
3
[ "MIT" ]
permissive
require "action_view" require "decisive/stream_csv_context" require "decisive/render_csv_context" require "decisive/render_xls_context" module Decisive class TemplateHandler def self.register ActionView::Template.register_template_handler 'decisive', self end def self.call template, source=templa...
true
f866e8e807058be520c96ec2fc522ed1c9ddb2a5
Ruby
emboss/bytestring
/lib/bytestring.rb
UTF-8
2,446
3.3125
3
[]
no_license
class ByteString module BasicByteString include Enumerable def [](index) slice(index) end def slice(num_or_range, num=nil) return slice_n(num_or_range, num) if num slice = @inner.slice(num_or_range) return nil unless slice return slice.ord if slice.size == 1 ByteS...
true
30c38e06214eef1a24a3cf20510db3072ceee014
Ruby
remcopeereboom/aoc2017
/day1/puzzle1.rb
UTF-8
448
3.90625
4
[]
no_license
######################################################## # Find the sum of all digits that match the next digit.# # To run: ruby puzzle1.rb input # ######################################################## def match_next?(string, i) j = (i + 1) % string.length string[i] == string[j] end def ...
true
5be6101fb7ea1aee238a647a59297d49cc09026a
Ruby
rajeev-crypto/CODECHEF_PROBLEM_IN_RUBY
/6.rb
UTF-8
59
3.015625
3
[]
no_license
n= gets.chomp.to_i b= gets.chomp.to_i puts b>n ? b-n : b+n;
true
08e6adeea4a80561da7f0ede3f48b4494d3a8ec0
Ruby
doosolar/ruby-wordpress
/spec/tests/wordpress/post_spec.rb
UTF-8
2,358
2.546875
3
[ "MIT" ]
permissive
require 'spec_helper' describe WordPress::Post do subject { $wp.new_post({ :post_title => 'Sample Post', :post_name => 'sample-post-name' }) } its :class do should be WordPress::Post end its :post_title do should eq 'Sample Post' end its :post_name do should eq 'sample-post-name' end i...
true
de5a102009f75627836488675c117859b4c54472
Ruby
sioux-stark/blog_app_rails
/app/helpers/sessions_helper.rb
UTF-8
611
2.671875
3
[]
no_license
module SessionsHelper # takes in a user object def login(user) # stores their id in the session session[:user_id] = user.id # stores the user in an instance variable @current_user = user end def logout # set @current_user and session to nil # this effectively forgets the user @c...
true
031f6fd824bf44fcca40f60ab0f96234ec48ff07
Ruby
appfolio/praxis
/lib/praxis/types/fuzzy_hash.rb
UTF-8
767
2.921875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Praxis module Types class FuzzyHash def initialize(value={}) @hash = {} @regexes = [] update(value) end def update(value) value.each do |k,v| self[k] = v end self end def []=(k,v) case k when Regexp ...
true
f88624f582dbc3ad5e8ba218cccba6a67cd94988
Ruby
juliancheal/ruby-lpd8806
/lib/lpd8806.rb
UTF-8
920
2.8125
3
[ "MIT" ]
permissive
require 'firmata' require 'socket' require 'stringio' class Lpd8806 def initialize(device) @board = Firmata::Board.new(device) @board.connect end # device info interface def firmware_name @board.firmware_name end def version @board.version end def set_packed_pixel(position, colour) ...
true
c2ae1dbd365890da17c8b2871a8276da8f3592d3
Ruby
RanjunSingh/WeatherScraper
/Weather.rb
UTF-8
3,090
3.96875
4
[]
no_license
# @author Ranjun require 'forecast_io' require './WeatherScraper.rb' #Weather manages the information scraped from the darksky website. class Weather # Initializes an instance of the Weather class. # @param location - The location name def initialize(location) @location = location @locationString = getL...
true
ad7a6b8b4ab52715ebdcf52a6f45c6d6677733a1
Ruby
tiago972/git-thp
/D06/tests-ruby/lib/03_basics.rb
UTF-8
514
3.328125
3
[]
no_license
def who_is_bigger(a, b, c) if a == nil || b == nil || c == nil return "nil detected" end tab = [a, b, c] case tab.max when a return "a is bigger" when b return "b is bigger" when c return "c is bigger" end end def reverse_upcase_noLTA(string) string = string.reverse.upcase return string.delete("LTA")...
true
f57ad752df69726f3bf7b0e5d2248330846c24cc
Ruby
anasdima/programming-projects
/Ruby/Mathematics/weights.rb
UTF-8
1,584
2.953125
3
[]
no_license
@args = [] f = File.open("input.txt", "r") f.each_line do |line| @args << line end #read C matrix from file @n = @args[0].split(',')[0].to_i @k = @args[0].split(',')[1].to_i @c = @args[1..@k] if @c.size != @k puts "Table size must be #{@k}x#{@n} as defined in the first line of the input" exit end @c....
true
d944addf4926617a464b0d6db96827f07bd500c2
Ruby
uozumi212/kadai-ruby-oop-3
/main.rb
UTF-8
284
2.703125
3
[]
no_license
require "./human" tanaka = Human.new("田中太郎","25","電車") tanaka.say tanaka.think suzuki = Human.new("鈴木次郎","30","野球") suzuki.say suzuki.think sato = Human.new("佐藤花子","20","映画") sato.say sato.think
true
bb42f2ae661c02952db06491b03ec3554bdb6ca0
Ruby
HopeFrost/Ruby
/ruby_challenges/class_play.rb
UTF-8
2,073
3.359375
3
[]
no_license
class Family attr_accessor :name, :fav_activity end class Pet <Family attr_accessor :type, :fav_toy end pet1 = Pet.new pet1.name= "Kenzy" pet1_name = pet1.name pet1.type= "dog" pet1_type = pet1.type pet1.fav_toy= "Lambchop" pet1_toy = pet1.fav_toy pet2 = Pet.new pet2.name= "Bear" pet2_name =...
true
5fa1e6102f5ada331da682b12632c0349f18ef84
Ruby
JuandGirald/developers
/app/services/stack_overflow_search.rb
UTF-8
2,040
2.578125
3
[]
no_license
class StackOverflowSearch def self.get_users(page, id) developers = [] response = HTTParty.get("https://api.stackexchange.com/2.2/users?page=#{page}&pagesize=100&order=desc&sort=reputation&site=stackoverflow") users = response.parsed_response["items"] users.each do |user| developers << { ...
true
367e53c6b5129984ad2804e70e6dd1fcd3e4b3b7
Ruby
Antaresgames/gamemachine
/server/lib/game_machine/data_stores/jdbc.rb
UTF-8
2,605
2.5625
3
[ "Apache-2.0" ]
permissive
module GameMachine module DataStores class Jdbc attr_reader :serialization def initialize(serialization) @serialization = serialization end def dbname 'game_machine' end def dbtype @dbtype ||= case Application.config.jdbc.driver when '...
true
d5e483622bf76d927818e410f5db5afb9093498a
Ruby
mitmedialab/MediaMeter-Coder
/utilities/sample_articles.rb
UTF-8
1,502
2.953125
3
[]
no_license
require '../config/environment.rb' if ARGV.count != 2 puts "You need to supply two arguments - the number of articles to tag, and the tag to use" exit end total_articles_to_sample = ARGV[0].to_i new_sampletag = ARGV[1] puts "Starting script to sample #{total_articles_to_sample} articles with the sampletag '#{new...
true
ce2d5ac0c24c3333e6ed4f50de3dff58ca8f43a8
Ruby
robertobuso/the-bachelor-todo-dumbo-web-071618
/lib/bachelor.rb
UTF-8
2,048
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def get_first_name_of_season_winner(data, season) data.each do |season_number, contestant_data_array| if season_number == season contestant_data_array.each do |contestant_data| contestant_data.each do |label, detail| if detail == "Winner" contestant_data.each do ...
true
1c1a274920d23791643bb488776b10ff8e535004
Ruby
CodingDojoDallas/ruby-oct-2016
/Heffner_Daniel/Ruby Assignments/project.rb
UTF-8
372
3.578125
4
[]
no_license
class Project attr_accessor :name, :description def initialize(name, desc) @name = name @description = desc end def elevator_pitch puts "\nThe project's name is #{@name}. Basically, here it is:\n#{@description}" end end project1 = Project.new("Get Rich", "Step 1: Learn Ruby on Rails.\nStep 2: ???\nStep 3: P...
true
da81ce01d625498610919dd2908b3e0806f6950f
Ruby
zlbruce/nrciz
/projecteuler/010/010-zhan.rb
UTF-8
964
4.375
4
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- =begin The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. =end def prime? (num) 2.upto Math.sqrt(num).to_i do |div| if num % div == 0 return false end end return true ...
true
10aee32a017547e5cd08a9e0a43c67d0995d553c
Ruby
mborkowski105/oo-basics-with-class-constants-nyc-web-100719
/lib/shoe.rb
UTF-8
260
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Shoe attr_reader :brand BRANDS = [] def initialize(brand) @brand = brand if !(BRANDS.include?(brand)) BRANDS << brand end end # create the writer for genre and add the logic for the class constant end
true
78e579885de266eea819a7bf739fe06cda5c9ce8
Ruby
h4hany/leetcode
/solutions/376_wiggle_subsequence.rb
UTF-8
1,962
3.984375
4
[]
no_license
# A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. # For example, [1,7,4,9,2,5...
true
1533794489c29a61c6564cfb0338af98ff76013b
Ruby
AlexVPopov/exercism-ruby
/complex-numbers/complex_numbers.rb
UTF-8
1,163
3.46875
3
[]
no_license
# frozen_string_literal: true require 'bigdecimal' class ComplexNumber attr_reader :real, :imaginary def initialize(real, imaginary) @real = real.to_f @imaginary = imaginary.to_f end def ==(other) real == other.real && imaginary == other.imaginary end def +(other) self.class.new(real + ...
true
a345aa6862e201e70cb584fcb6166bffed7be666
Ruby
marsiox/math
/spec/prime_spec.rb
UTF-8
357
2.96875
3
[]
no_license
require 'spec_helper' require_relative '../prime' describe Prime do describe "#is_prime?" do it "checks if the given number is a prime number" do p = Prime.new expect(p.is_prime?(5)).to be true expect(p.is_prime?(19)).to be true expect(p.is_prime?(6)).to be false expect(p.is_prime?...
true
8e39bd633ad07b64314266b98485f09bfc33abcb
Ruby
rsmease/ruby-misc
/ascii_compare.rb
UTF-8
635
3.9375
4
[]
no_license
def compare(s1,s2) my_s1 = s1 my_s2 = s2 if my_s1.nil? or my_s1 === "" my_s1 = "1" end if my_s2.nil? or my_s2 === "" my_s2 = "1" end if not my_s1.split("").all? {|char| char =~ /[[:alpha:]]/} my_s1 = "" else my_s1 = my_s1.split("").map {|char| char.upcase} end if not my_s2.split("").all? {|char| ...
true
9afcc0fb308c9aa54c87de1c89c0901b878dba04
Ruby
timlatorre/ruby
/labs/basic_calculator_v2.rb
UTF-8
554
3.671875
4
[]
no_license
require 'pry' puts "Do you want to (a)dd, (s)ubtract, (m)ultiply, (d)ivide or (q)uit?" response = gets.chomp while response != "q" puts "First number" first = gets.to_f puts "Second number" second = gets.to_f if response == "a" result = first + second elsif response == "s" result = first - second elsi...
true
97e02b7e7fc35282acae1bdd161de99b176e8298
Ruby
Jonwheeler/trawler
/lib/trawler/document.rb
UTF-8
489
2.703125
3
[ "MIT" ]
permissive
module Trawler class Document def initialize(url, options = {}) @url = url @parser = options.fetch(:parser, Parser) @spider = options.fetch(:spider, Spider) @image = options.fetch(:image_size, "100") end def parse ParsedDocument.new(doc.full_url, parsed_data) end ...
true
b2832b8d397ab551fb39287373319db46ce55282
Ruby
Nimdis/znaigorod
/lib/tasks/social_likes.rake
UTF-8
558
2.53125
3
[]
no_license
# encoding: utf-8 require 'progress_bar' require 'social_likes' desc 'Get social likes for afishas,organizations and posts' task :social_likes => :environment do likes = SocialLikes.new ['Afisha','Organization', 'Post'].each do |klass| if klass == 'Afisha' collection = klass.constantize.with_showings ...
true
b44909fb314d939ac9402839bb18408a76ee8db6
Ruby
Alt-katell/rails-longest-word-game
/app/controllers/games_controller.rb
UTF-8
390
2.5625
3
[]
no_license
class GamesController < ApplicationController def new @letters = 10.times.map { ("A".."Z").to_a.sample } end def score end def in_the_grid? word_array = params[:word].chars word_array.each do |letter| if @letters.include?(letter) @letters.delete_at(@letters.index(letter)) el...
true
314fbc5e873e5fca4760a9fae999eb9b5c6667db
Ruby
kyyberi/bubble
/ruby/bubble-live2.rb~
UTF-8
3,727
2.625
3
[ "MIT" ]
permissive
#!/usr/bin/ruby require 'nokogiri' require 'open-uri' require 'mysql' require 'date' require 'net/http' def getLicenses(*params) lics = []; begin con = Mysql.new 'localhost', 'thing', 'thing', 'thingiverse' querystr = "select distinct license from thing where status='public'" rs = con.query(querystr) ...
true
ac3ae2e6bd7e249c16384500f89376b275808dc2
Ruby
rakib-amin/assigns
/assignment_2/xLTest/lib/error-detect.rb
UTF-8
8,699
2.828125
3
[]
no_license
=begin @input config files @output console.txt =end # pretty print for Hashes require 'pp' # roo rubygems for .ods parsing require 'rubygems' require 'roo' def is_leap(year) return year%400==0 || (year%4==0 && year%100!=0) end # class for extracting data from a given file class Extractor $glo...
true
288eff300320fd6db5d55dd928f416aa5aa4789c
Ruby
oscos/launch_school
/rb100/intro_ruby/flow_control/true_false.rb
UTF-8
313
3.875
4
[]
no_license
# Launch School Book: Introduction To Programming With Ruby # true_false.rb # Answered On: 11/14/2019 # INSTRUCTIONS: # NOTES: In ruby every expression evaluates to 'true' when used in a flow control, # except for 'false' and 'nil'. a = nil if a puts "how can this be true?" else puts "it is not true" end
true
a03bdaeb3be95d79a3163246b64d7241cfde596b
Ruby
CreazeroParis/surveillance
/app/models/surveillance/attempt.rb
UTF-8
4,177
2.515625
3
[ "MIT" ]
permissive
module Surveillance class Attempt < ActiveRecord::Base include AASM has_many :answers, class_name: "Surveillance::Answer", foreign_key: 'attempt_id', dependent: :destroy, inverse_of: :attempt, before_add: :set_attempt_on_answers accepts_nested_attributes_for :answers belongs_to :survey, ...
true
e303196e500f89d8139a157be42a0f7dedd42f84
Ruby
Wendalf/pitchfork-best-new-music-cli-gem
/lib/pitchfork_best_new_music/review.rb
UTF-8
442
2.6875
3
[ "MIT" ]
permissive
module Review module ClassMethods def batch_create_from_review_collection(scraped_reviews_collection) scraped_reviews_collection.each do |single_review_hash| self.new(single_review_hash) end end def find(input) self.all[input-1] end end module InstanceMethods def add_review_details(revi...
true
d9878785fcff7467cc3b20b02e3e06e8b514f824
Ruby
RomanADavis/challenges
/euler/ruby/solved/problem_set(26-50)/problem49/solutions/solution.rb
UTF-8
731
3.546875
4
[]
no_license
class Primes def self.under(n) candidates = (3..n).step(2).to_a primes = [2] cap = n**0.5 until candidates.empty? || primes.last > cap primes << candidates.shift candidates.reject! {|candidate| candidate % primes.last == 0} end primes + candidates end end primes = ...
true
1e83fbdf475e203633dfe4de139c14240aa106e4
Ruby
alfredo-pl/ruby_adicto_redes2
/adictos_a_redes2.rb
UTF-8
345
2.71875
3
[]
no_license
min =ARGV def scan_addicts2(arr) result = [] canti = arr.length canti.times do |i| if arr[i].to_i < 90 result.push'bien' elsif arr[i].to_i >= 90 && arr[i].to_i < 180 result.push'mejorable' else result.push'mal' end end result end ...
true
f175a5701120f030bac8c287566cda3da9fc5a8b
Ruby
colinwarmstrong/battleshift
/spec/services/values/space_spec.rb
UTF-8
837
2.734375
3
[]
no_license
require 'rails_helper' describe Space, type: :service do let(:coordinates) { double('A1') } let(:space) { Space.new(coordinates) } it 'exists' do expect(space).to be_a(Space) end it 'has attributes' do expect(space.coordinates).to eq(coordinates) expect(space.contents).to eq(nil) expe...
true
4183ecfb09a69064e742a8e80974284d85dc0cdc
Ruby
greyblake/ruby-sox
/lib/sox/combiner/process_substitution_strategy.rb
UTF-8
2,614
2.9375
3
[ "MIT", "CC-BY-3.0" ]
permissive
module Sox # Combines files using process substitution to build and use mediate files. # Process substitution is not supported by the standard shell, so we need # to pass the final command to bash via shell. # # Read more about process substitution: # http://en.wikipedia.org/wiki/Process_substitution clas...
true
9ad1d7985d1683d9321147e08848881de41fdb7f
Ruby
dnagir/game_of_life
/spec/models/game_spec.rb
UTF-8
970
2.890625
3
[]
no_license
require File.expand_path("../../spec_helper", __FILE__) describe GameOfLife, "initialization" do it "can be initialized with board size" do game = GameOfLife.new(3) game.board.width.should == 3 game.board.height.should == 3 end it "can be initialized with board" do board = GameBoard.new(:...
true
252b73bac23e94022b9318f8285d1ac5676b9030
Ruby
webdev1014/ref4seeker
/app/models/question.rb
UTF-8
1,635
2.5625
3
[]
no_license
class Question < ApplicationRecord belongs_to :user has_many :answers, dependent: :destroy has_many :categorizations, dependent: :destroy has_many :categories, through: :categorizations has_many :votes, dependent: :destroy has_many :voted_users, through: :votes, source: :user has_many :favorites, depen...
true
254056ed0d1e209f378dc6f57f8bb9c53bdcd994
Ruby
govindarajanv/ruby
/sololearn/book.rb
UTF-8
670
4.15625
4
[]
no_license
class Book @pages = 0 def initialize(name,pages) @name = name @pages = pages end def info() puts @name puts @pages end #accessors def get_name() puts @name end def get_pages() puts @pages end #setter methods: the method name is followed by an equal sign (=). def set_name=(name) @name = name ...
true
6c9ba1bafe1c6026257a8c3df4c04b377ea5867d
Ruby
sneakin/CooCoo
/lib/coo-coo/math/nmatrix.rb
UTF-8
5,977
3.15625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
require 'nmatrix' module CooCoo module NMatrix class Vector < CooCoo::Math::AbstractVector protected attr_reader :elements public def initialize(length, initial_value = 0.0, &block) if length != nil if length <= 0 raise ArgumentError.new("size mus...
true
0244878e4eb9e13855ade9499e4766b62f38ce9f
Ruby
coolbrg/progfun
/design_patterns/abstract_factory/demo_codes/ex1_plants.rb
UTF-8
447
3.734375
4
[]
no_license
# Tree Class class Tree def initialize(name) @name = name end def grow puts "The Tree #{@name} grow talls." end end # Algae Class class Algae def initialize(name) @name = name end def grow puts "The Algae #{@name} socks up the sun and grows." end end # Lotus Class class Lotus def i...
true
f6ac2ad87a9ee42008fad2a2d4506ca4da06c10d
Ruby
robbkidd/advent-of-code
/2019/ruby/lib/day07.rb
UTF-8
2,548
3.078125
3
[]
no_license
class Day07 def self.go puts "Part1: #{part1}" puts "\nPart2: #{part2}" end def self.part1 (0..4).to_a.permutation.map do |sequence| output_signal = AmpCircuit.new(phase_sequence: sequence, software: amp_control_software).run [sequence, output_signal] ...
true
b3ddbe99950fe70c1ff6ae4d48a4add829565b29
Ruby
scottishdev/codaoke
/spec/client_spec.rb
UTF-8
746
2.6875
3
[]
no_license
require('minitest/autorun') require('minitest/reporters') Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new require_relative('../client.rb') require_relative('../karaoke_room.rb') class TestClient < Minitest::Test #setup method for test data def setup @client1 = Client.new("Barry", 50, "Song 1") ...
true
9ce27aaf1ad4df85e52c97a57a5857831cef0c28
Ruby
backupify/shearwater
/lib/shearwater/migrator.rb
UTF-8
1,284
2.59375
3
[ "MIT" ]
permissive
module Shearwater class Migrator def initialize(migrations_dir, backend, options = {}) @migrations_dir, @backend = migrations_dir, backend @verbose = !!options[:verbose] end def migrate migrations.keys.sort.each do |id| unless @backend.migrated?(id) migration = migra...
true
bc6262b8df44518a4c0666a81dff02014d55f8b3
Ruby
demonicirish87/Ruby-Assignment
/11_Blocks.rb
UTF-8
519
3.703125
4
[]
no_license
#Thomas Ostdiek 11 blocks #help from http://stackoverflow.com/questions/11352061/cartesian-product-ruby class CartesianProduct include Enumerable def initialize(xs, ys) @xs = xs @ys = ys end def each return to_enum unless block_given? @xs.each do |x| #go through each x @ys.each { |y| yield [x, y]...
true
7628ef53b1f316738cafd7f2f4f3205aa229d885
Ruby
ksbek/breed-rails-test
/app/helpers/breeds_helper.rb
UTF-8
450
2.640625
3
[]
no_license
module BreedsHelper def breed_list begin breeds_list = JSON.parse(RestClient.get("https://dog.ceo/api/breeds/list/all").body)["message"] breeds = {} breeds_list.keys.each do |key| breeds[key.capitalize] = key breeds_list[key].each do |sub_breed| breed = [key, sub_breed].joi...
true
0078ce786c7ef0128da21f0551dc46223093815a
Ruby
amorphid/learn_sql_ruby
/spec/statements/010_CROSS_JOIN_grapes_spec.rb
UTF-8
1,420
2.546875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
RSpec.describe "CROSS JOIN" do before do LearnSQL.query(%q{ CREATE TABLE grapes ( id SERIAL, color CHARACTER VARYING, is_seedless BOOLEAN, PRIMARY KEY (id) ); }) LearnSQL.query(%q{ CREATE TABLE skus ( id SERIAL, size CHARACTER VARYING, ...
true
9cfe8c84f533b9230c5132a1c571dde515c6a725
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/phone-number/4e4eb79527a348daad45a93bf8a18c79.rb
UTF-8
597
3.28125
3
[]
no_license
class PhoneNumber INVALID = "0000000000" def initialize phone @phone_number = phone.scan(/[\d]/).join @phone_number = INVALID unless phone.scan(/[[:alpha:]]/).empty? end def number correct_number? end def area_code number.slice(0..2) end def to_s "(#{area_code}) #{number.slice(3....
true
fd39787fa738bd7a40982d4aac4f21bafde93d19
Ruby
sibevin/random_token
/test/get/test_hash_seed.rb
UTF-8
1,270
2.734375
3
[ "MIT" ]
permissive
require 'minitest/autorun' require "random_token" class TestHashSeed < Minitest::Test def test_get_should_create_a_random_with_the_given_seeds length = 10000 token = RandomToken.get(length, :seed => { 'a' => 1, 'b' => 2, 'c' => 3 }) assert_match(/^[a-c]{#{length}}$/, token) end def test_get_should_c...
true
9c0302be74dc7a9fc5260864c0a4d7a2fa9e993f
Ruby
pujarisahil/Shinsa
/server/access_account.rb
UTF-8
7,719
3.109375
3
[]
no_license
#!/usr/bin/ruby -w require "mysql" require "json" require_relative "db_info" require_relative "id_convert" # Public: Builds and returns all account data # # _username - username of player # # Returns Account Object # def getAccount(_username) begin # Establish connection with database dbc = Mysql.new(DB_SERVER,...
true
81d01b850afc71a0236b45e24df140570ada6eff
Ruby
tcheng96/sp16-hw2
/app/controllers/concerns/foobar.rb
UTF-8
185
3.21875
3
[]
no_license
class Foobar # ENTER CODE FOR Q2 HERE def initialize(x) @word = x end def bar(x, y) list = y.flatten() index = 2 return "#{x}#{@word}#{list[index]}" end end
true
302db39cf3f3763dbd1ad5a2fc17661cc3a1dd88
Ruby
NEvans85/W1D3
/word_chains/word_chains.rb
UTF-8
915
3.4375
3
[]
no_license
require 'set' class WordChainer attr_reader :all_seen_words def initialize(dictionary_file_name) @dictionary = Set.new(File.readlines(dictionary_file_name).map(&:chomp)) end def adjacent_words(target_word) @dictionary.dup.keep_if { |word| target_word.diff(word) == 1 } end def run(source, target)...
true
993f0555df5f4770bd1cc2d5b3182b13ac32b45f
Ruby
ender672/tiedye
/lib/tiedye/transform/colorize.rb
UTF-8
374
2.546875
3
[ "MIT" ]
permissive
module TieDye module Transform class Colorize include Image def initialize(source, r, g, b) @source = source @color = Color::SRGB.new(r, g, b).to_lab end def run gradient = Generate::LumSRGBGradient.new @color, Color::Lab::WHITE, 256 @source.greyscale.run....
true
e82ed082d20a4dd144c9d9fe8153b27708bd2e6e
Ruby
alex-solo/ruby-problems
/Medium 2/now_i_know_my_ABCs.rb
UTF-8
1,305
3.828125
4
[]
no_license
=begin BLOCKS = {['B', 'O'] => true, ['X', 'K'] => true, ['D', 'Q'] => true, ['C', 'P'] => true, ['N', 'A'] => true, ['G', 'T'] => true, ['R', 'E'] => true, ['F', 'S'] => true, ['J', 'W'] => true, ['H', 'U'] => true, ['V', 'I'] => true, ['L', 'Y'] => true, ['Z', 'M'] => true} - above are availabl...
true
2181e97539a0b2bcf99fa2c228547921a1dfe8a6
Ruby
EdwardObala1/algorithms_sock_merchant
/lib/algorithm.rb
UTF-8
734
3.09375
3
[]
no_license
class Matchingsock def pairs(socks) # using a hash/dictionary to store the sock colour and pair number # time complexity of creating a dictionary sock_pairs = {} # time complexity of going through the socks of o(n) socks.each do |sock| # time of insertion in a hash o(1) sock_pair...
true
4b4b9aaed10b4b4f42dfadea7ebe6b492c0d228a
Ruby
jsl/ruby_ukanren
/lib/micro_kanren/cons.rb
UTF-8
1,026
3.25
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module MicroKanren class Cons attr_reader :car, :cdr # Returns a Cons cell (read: instance) that is also marked as such for # later identification. def initialize(car, cdr) @car, @cdr = car, cdr end # Converts Lisp AST to a String. Algorithm is a recursive implementation of # http:...
true
4d57b2b1e75477bc22158f1630584be38023e9ef
Ruby
sonialin/launchschool
/Exercises/101-109 Small Problems/Easy 7/03_capitalize.rb
UTF-8
298
3.734375
4
[]
no_license
def word_cap(str) arr = str.split(" ").map {|substr| substr.capitalize} arr.join(" ") end puts word_cap('four score and seven') == 'Four Score And Seven' puts word_cap('the javaScript language') == 'The Javascript Language' puts word_cap('this is a "quoted" word') == 'This Is A "quoted" Word'
true
aa3672352e99fcb201074c3852acdc73d41e335a
Ruby
bentrevor/dark_dragon
/spec/dark_dragon/options_spec.rb
UTF-8
3,209
2.6875
3
[ "MIT" ]
permissive
require 'spec_helper' describe DarkDragon::Options do let(:options) { described_class.parse_ARGV(argv) } before do allow(File).to receive(:write) end describe '#correctly_formatted?' do it 'raises an error for the wrong number of arguments' do expect { described_class.parse_ARGV(['path'...
true
51e0d92334761e126f538d2e9b130dd4bfe6766e
Ruby
nov/webfinger
/lib/webfinger/exception.rb
UTF-8
793
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module WebFinger class Exception < StandardError; end class HttpError < Exception attr_accessor :status, :response def initialize(status, message = nil, response = nil) super message @status = status @response = response end end class BadRequest < HttpError def initialize(mes...
true
8822ffdb344975398ce9e1567454efb9a83b4ee5
Ruby
lugray/advent_of_code
/2021/day02_alt.rb
UTF-8
881
3.375
3
[]
no_license
#!/usr/bin/env ruby require_relative 'day' class Day02 < Day def initialize @movements = input.each_line.map do |l| a, b = l.split(' ') [a, b.to_i] end end class Sub def initialize @x = 0 @y = 0 end def forward(d) @x += d end def down(d) @y += d...
true
c950a6a9ec4d4b8007a80f21421605d5a1d808e0
Ruby
kristynp/reverse-each-word-denver-web-060319
/reverse_each_word.rb
UTF-8
191
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(string) arr = string.split(" ") reverse_arr = [] arr.collect do |word| drow = word.reverse reverse_arr.push(drow) end return reverse_arr.join(" ") end
true
e9b18bbdd940eab78a2dd400ebf65010040b331c
Ruby
junara/komee
/app/models/concerns/uploads.rb
UTF-8
1,671
2.734375
3
[]
no_license
# frozen_string_literal: true # REF http://www.carlosramireziii.com/what-options-can-be-passed-to-the-active-storage-variant-method.html?utm_source=rubyflow # REF https://prograils.com/posts/rails-5-2-active-storage-new-approach-to-file-uploads class Uploads class << self def jpeg?(blob) blob.content_type...
true
ed0a41d8ab456400b3c2f67a42608ef75a805778
Ruby
deepcerulean/minotaur
/lib/minotaur/support/range_helpers.rb
UTF-8
454
2.5625
3
[ "MIT" ]
permissive
module Minotaur module Support module RangeHelpers def range_overlap?(range_one,range_two) range_one.include?(range_two.begin) || range_two.include?(range_one.begin) end def range_overlap(range_one,range_two) raise "no overlap between #{range_one} and #{range_two}" unless range_overlap...
true
f9c9f3421c8c419601e138e31fbfb29ea33d4cac
Ruby
Adria1988/ProgrammingExercises
/Ruby/Enumerables&Ranges/FirstInArray.rb
UTF-8
654
4.71875
5
[]
no_license
# frozen_string_literal: true # First In Array # Write a method first_in_array that takes in an array and two elements, # the method should return the element that appears earlier in the array. def first_in_array(arr, el1, el2) element1 = 0 element2 = 0 arr.each_with_index do |arr, i| arr.include?(el1) ? el...
true
32e37df213e1d41a4c38e771782fd2bbbb98772c
Ruby
Tedworthy/github-trello
/lib/github-trello/server.rb
UTF-8
4,538
2.6875
3
[ "MIT" ]
permissive
require "json" require "sinatra/base" require "github-trello/version" require "github-trello/http" module GithubTrello class Server < Sinatra::Base post "/posthook" do config, http_users = self.class.config, self.class.http_users payload = JSON.parse(request.body.read) # Get the Trello board ...
true
706f94b2ac43289af17ac71dfecae84148236611
Ruby
christoomey/plugin-ruby
/test/method.rb
UTF-8
1,050
2.9375
3
[ "MIT" ]
permissive
# frozen_string_literal: true # rubocop:disable Lint/DuplicateMethods, Lint/UnusedMethodArgument # rubocop:disable Metrics/ParameterLists def foo; end def foo(); end def foo alpha end def foo(alpha) end def self.foo; end def self.foo(); end def self.foo alpha end def self.foo(alpha) end def foo(alpha, beta, *...
true
151f4abb3738c547b0a37a87374d9afd77a8c4ae
Ruby
mfine/attributed
/lib/monkey_patch.rb
UTF-8
164
2.890625
3
[]
no_license
class Numeric def seconds self end def minutes self * 60 end def hours self * 60 * 60 end def days self * 60 * 60 * 24 end end
true
94be449ef52a375b3a43e8a2f95b12c02ea756b0
Ruby
evo2013/TDD
/word-count/word_count.rb
UTF-8
490
3.125
3
[]
no_license
class Phrase Phrase::VERSION = 1 def initialize(input) @str = [] multi_str = input.split(/[\s,]+/) multi_str.each do |i| compressed = i.gsub(/\W+(?<!')/, '') compressed.delete!("'") if compressed.chr == "'" @str << compressed.downcase if compressed != "" end end def word_coun...
true
c3864b418afdbd16b13de288a841d55390e4fa56
Ruby
gitvar/back-end-development
/assessment-109-revision/array_reversal.rb
UTF-8
260
4.28125
4
[]
no_license
# reverse.rb arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def reverse_array(array) t_arr = [] size = array.size - 1 array.each_with_index do |element, index| t_arr[index] = array[size - index] end t_arr end my_arr = reverse_array(arr) p arr p my_arr
true
18fa6bc6dd82fa20e57f7f91fe4465ec08557fea
Ruby
chrisrusselldigital/Battle
/app.rb
UTF-8
727
2.5625
3
[]
no_license
require 'sinatra/base' require './lib/player' require './lib/game' class Battle < Sinatra::Base enable :sessions get '/' do erb :index end post '/names' do $p1_name = Player.new(params[:p1_name]) $p2_name = Player.new(params[:p2_name]) redirect '/play' end get '/pla...
true
014665f22d7c0a4ffa3f73f70111d9f547fd71da
Ruby
yyytuit/ruby_gold
/弱い問題/13.rb
UTF-8
1,389
4.0625
4
[]
no_license
# 3 # 次のコードを実行するとどうなりますか。 v1 = 1 / 2 == 0 v2 = !!v1 or raise RuntimeError puts v2 and false # シンタックスエラーとなる # 選択肢 # 実行時にエラーとなる # 選択肢 # true と表示される # 選択肢 # false と表示される # 1: v1 = 1 / 2 == 0 # 2: v2 = !!v1 or raise RuntimeError # 3: puts v2 and false # 1行目では、Fixnumクラス同士の除算はFixnumクラスになります。 # よって、0 == 0が評価され、v1はtrueに...
true
d6ef38528609962b96bc0289d4ca9ae18204bfeb
Ruby
jsuchy/limetweet
/styles.rb
UTF-8
474
2.609375
3
[]
no_license
backdrop { background_color "#94E4E8" width "100%" height "100%" horizontal_alignment "center" vertical_alignment "center" } doing { width 600 height 600 background_color "white" padding 10 } status { width 500 height 200 } status_bar { width 600 height 40 horizontal_alignment "left" } w...
true
73d4faf92916bf3bde7825a45c8f774695d0e241
Ruby
amoeba/treestats.net
/helpers/race_helper.rb
UTF-8
786
2.890625
3
[ "MIT" ]
permissive
module RaceHelper RACES = { 1 => "Aluvian", 2 => "Gharu'ndim", 3 => "Sho", 4 => "Viamontian", 5 => "Shadowbound", 6 => "Gearknight", 7 => "Tumerok", 8 => "Lugian", 9 => "Empyrean", 10 => "Penumbraen", 11 => "Undead", 12 => "Olthoi", 13 => "OlthoiAcid" } ...
true
86957345e82db2887348c1d1727f65e3d6fe2cc8
Ruby
samuel-hcl/ruby_mutation_tests
/app/cart.rb
UTF-8
569
2.953125
3
[]
no_license
class Cart # def total_price(quantity, discount_coupon = nil) # return if quantity <= 0 # if quantity >= 10 || discount_coupon == 'OBADESCONTO' # return quantity * 15 # else # return quantity * 20 # end # end def total_price(quantity, discount_coupo...
true
47b3ddb4b828d170e686a668a839f323a45b7aa2
Ruby
alphasights/cxml
/lib/cxml/invoice_detail_request/contact.rb
UTF-8
859
2.625
3
[ "MIT" ]
permissive
module CXML module InvoiceDetailRequest class Contact attr_accessor :role, :name, :language, :postal_address, :email, :address_id def initialize(data={}) if data.kind_of?(Hash) && !data.empty? @role = data[:role] @name = data[:name] @email = data[:email] ...
true
c9604d22fe9fb0a8027508c9272e39fa1ab9f731
Ruby
delfer/bonnie-as-a-service
/baas
UTF-8
2,847
2.75
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'colorize' require 'erb' require 'hashie' require 'net/ssh' require 'net/scp' require 'net/sftp' require 'yaml' started = Time.now.utc module Baas def self.line_clear! puts puts ('-' * 30).red puts end def self.configuration return @config if @co...
true
9fee0d986e02333f10fa4afceb916156c4b4cbaa
Ruby
NeelAiyar/OOP-1
/save/OOP/ex04/second_class.rb
UTF-8
172
2.859375
3
[]
no_license
class SecondClass < FirstClass def initialize("name","number") super("name") @number = "number" end def number puts "????" Hello(rand(1..6)) end end
true
e16ddaba2ddde1000725eabdd23b3e163d23ce25
Ruby
EricRicketts/LaunchSchool
/Ruby/ProgrammingFoundations/study_groups/101_109/session_4_test.rb
UTF-8
2,650
4.28125
4
[]
no_license
# Create a method that takes two integers as arguments. The first argument is # a count, and the second is the first number of a sequence that your method # will create. The method should return an Array that contains the same number # of elements as the count argument, while the values of each element will be # multip...
true
7957d07479769786d18fab9490d86bef005d718f
Ruby
Inauth/log4jruby
/examples/simple.rb
UTF-8
731
3.109375
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/setup' require 'log4jruby' logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug) logger.debug("hello world") class MyClass attr_reader :logger def initialize @logger = Log4jruby::Logger.get(self.class.name, :level => :debug, :tracing => true) end ...
true
a85774b0ad3999e9ec5126de8dc8c419fa0b17b4
Ruby
kamaradclimber/advent-of-code-2020
/days/day19.rb
UTF-8
3,154
3.109375
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true require 'aoc' require 'pry' class Day19 < Day def solve_part1 rules, messages = input.split("\n\n") messages = messages.split("\n") rules = rules.split("\n").map do |line| id, rule = line.split(': ') [id.to_i, parse_rule(rule)] end.to_h # now we need to...
true
99e5429f0e448d45f0fd7f43edaa7dc541c2e365
Ruby
shunshunsuke/book_algorithm
/chap05/5_8.rb
UTF-8
500
2.9375
3
[]
no_license
N, M = gets.split.map(&:to_i) a = gets.split.map(&:to_i) # 区間[j, i)の平均値を前処理で求める f = Array.new(N + 1) { Array.new(N + 1) } (1..N).each do |i| i.times do |j| f[j][i] = a[j..(i - 1)].sum / (i - j) end end dp = Array.new(N + 1) { Array.new(M + 1, 0) } dp[0][0] = 0 (0..N).each do |i| i.times do |j| (1..M).ea...
true
bb1b71af5c8ec9ee881a9e6d8c59f9a70d41bf04
Ruby
xrxrxr/thhckngprject
/ruby/exo_20.rb
UTF-8
255
3.28125
3
[]
no_license
puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?" print ">" etage = gets.chomp.to_i var = '#' if (etage> 25) puts "Désolé 25 étages maxi!" else puts " voila ta pyramide!" i=0 while i<etage puts '#'*i i=i+(1) end end
true
b4444689bd0054ddf9d3c8b38dc92cca133d0e67
Ruby
hannahbeckdesign/ruby_challenges
/wk3_love_loop.rb
UTF-8
514
3.671875
4
[]
no_license
print "Do I love you?\n\nQ. Is the pope Catholic? Please answer Y/N: " answer = gets.chomp.downcase while (answer == "y") print "A. I love you. Q. Is rain wet? Please answer Y/N: " answer = gets.chomp.downcase print "A. I love you. Q. Does a bear poop in the woods? Please answer Y/N: " answer = gets.chomp.down...
true
bdae3089c6abe308d91b4cbdb7f5a53746c5d8cb
Ruby
josem-gp/rspec-course
/spec/spies_spec.rb
UTF-8
1,206
3.375
3
[]
no_license
# they are testing doubles but a normal double places the expectation BEFORE the action while a spy does it AFTER the action # we can use spies or doubles. it is up to us RSpec.describe 'spies' do let(:animal) { spy('animal') } #we dont need to explicitly define the methods that the spy will have it 'confirm...
true
b5a775598598d38fbc83041e6329d2d91ad83fe4
Ruby
calazans10/algorithms.rb
/others/mixins.rb
UTF-8
357
3.0625
3
[]
no_license
class Person end class Hero < Person def can_fly? false end def fast? false end end module Flying def can_fly? true end end module Fast def fast? true end end class SuperMan < Hero include Flying include Fast end class TheFlash < Hero include Fast end f = TheFlash.new p f.ca...
true
8400a9b53e2b3014d0b25a58219bb8de7f3ee41f
Ruby
garciajordy/Ruby-Linters-Capstone
/lib/error.rb
UTF-8
3,424
3.171875
3
[]
no_license
# Error Class to find all the errors class Error attr_reader :white_space private # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def indentation(lines, ind) @white_space = lines.index(lines.lstrip) if lines.strip.length.positive? if lines.include?('end') @max...
true
d5c5643109220a6fa16b213aed7ad4ad22e309be
Ruby
peterhinners/donation-cat
/testing.rb
UTF-8
891
2.71875
3
[ "MIT" ]
permissive
good_american_link = "http://www.amazon.com/gp/registry/wishlist/T8E7KL29ENDQ/?ie=UTF8&tag=childsplaycha-20&linkCode=ur2&camp=1789&creative=9325" bad_american_link = "http://www.amazon.com/registry/wishlist/1I9RPW4H98KTH/?_encoding=UTF8&camp=1789&creative=9325&linkCode=ur2&tag=childsplaycha-20" canadian_link = "http:...
true
7ddff16c1f971001892aa12d823dc43faaecda85
Ruby
smeyyeac/Ruby-basic-examples
/tausayi.rb
UTF-8
655
4.03125
4
[]
no_license
#Doğal sayı çarpanlarının sayısına kalansız bölünebilen sayılara "Tau sayısı" denir. #Örneğin; 8 sayısı bir Tau sayısıdır. #Çünkü 8 sayısının doğal sayı çarpanları 1, 2, 4 ve 8 olmak üzere 4 tanedir #ve 8 sayısı 4 ile kalansız bölünür. def tau_number(number) counter = 0 dividing = 1 while (dividing <= nu...
true
de5f6becca0d8ce89e6e2bfebf0945125abbbba1
Ruby
pierreleclair/THP-SCRAPPING
/lib/mairi_christmas.rb
UTF-8
821
2.765625
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'pry' def get_the_email_of_a_townhal_from_its_webpage(a_townhal_url) name_selector = "body > div > main > section.text-center.well.well-sm > div > div > div > h1" page = Nokogiri::HTML(open("http://annuaire-des-mairies.com/#{a_townhal_url}")) if a_townhal_url hash...
true
c4679f688ab478bcc4a7728c1884816bf403d29e
Ruby
GeorgeSeeger/student-directory
/directory.rb
UTF-8
3,013
3.78125
4
[]
no_license
@students = [] def print_header puts "The students of Villains Academy" puts "-"*10 end def print_students(array) array.each.with_index do |e, i| puts "#{i+1}: #{e[:name]}, #{e[:cohort]} cohort".center(50) end end def print_footer(names) puts "Overall we have #{names.count} great students" end def prin...
true
203f5a7c82bb8514fe9f8c0e01c956956f805e20
Ruby
marcon29/CLI-dinner-finder-grocery-list
/lib/cli.rb
UTF-8
3,571
3.625
4
[ "MIT" ]
permissive
class CLI def main_menu puts "What would you like to do? (enter number)" puts "1. Add recipe" puts "2. View all recipes" puts "3. Delete one or all recipes" puts "4. Create grocery list" puts "5. Exit" puts "" input = gets.strip if input.to_i.between?(1,6) case input ...
true
ad4679f35f8e6877c72e8b397a19caea9f2ab6cf
Ruby
dalspok/exercises
/small_problems_i2/medium_1/9.rb
UTF-8
347
3.40625
3
[]
no_license
=begin P: E: D: A: C: ========================= =end def fibonacci(limit) return 1 if limit <= 2 first = 1 second = 1 (3..limit).each do |_| second, first = (first + second), second end second end p fibonacci(20) == 6765 p fibonacci(100) == 354224848179261915075 p fibonacci(100_001) # => 4202692...
true
a13490dddb88c2118b766d10003936864a1fe1fe
Ruby
djc00p/flash_cards
/test/turn_test.rb
UTF-8
1,093
2.890625
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/turn' require './lib/card' class TurnTest < Minitest::Test def test_it_exists turn = Turn.new("Juneau", Card.new("What is the capital of Alaska?", "Juneau", :Geography)) assert_instance_of Turn, turn card = Card.new("What is the capital ...
true
dc29909669cd0918d52d93a315ed2c1ebca58750
Ruby
jtlai0921/PG20249_example
/PG20249_sample/Ruby268-SampleProgram-UTF8/Ch9/sample227-01.rb
UTF-8
72
2.578125
3
[]
no_license
require "open-uri" open("http://www.example.com/"){|f| print f.read }
true
8ac94f557cd5830d2f521c32cd5f551fe9f04961
Ruby
guncho2/bloc_record
/lib/bloc_record/selection.rb
UTF-8
9,340
2.515625
3
[]
no_license
require 'sqlite3' require 'bloc_record/persistence' require 'bloc_record/collection' module Selection def find(*ids) if ids.length == 1 find_one(ids.first) else ids.each do |id| if id.is_a?(Integer) && id > 0 next else puts "This is not a valid ID" ...
true
fef127ddcfdf244c7e529c336ebbbcd01fa6909b
Ruby
datadebrief/projeuler
/euler144.rb
UTF-8
2,217
3.734375
4
[]
no_license
# In laser physics, a "white cell" is a mirror system that acts as a delay line for the laser beam. # The beam enters the cell, bounces around on the mirrors, and eventually works its way back out. # The specific white cell we will be considering is an ellipse with the equation 4x2 + y2 = 100 # The section correspondi...
true
7dcc0089aa1e7d215c33c28e228c89e0186150b9
Ruby
noahdiewald/icu4r
/test/test_calendar.rb
UTF-8
3,206
2.609375
3
[ "MIT" ]
permissive
# Calendar stuff is known to be broken and I don't user it. Skipping #require 'ext/icu4r/c/icu4r' #require 'test/unit' ## these tests are ICU 3.4 dependent #class UCalendarTest < Test::Unit::TestCase # # def test_time_zones # v = UCalendar.time_zones # assert_kind_of(Array, v) # assert_kind_of(UString, v[0]) # ...
true
f4d40107f4eb00b855bc6ceb9b3310cc072db18b
Ruby
tomdulin/algorithms
/add_two_numbers.rb
UTF-8
3,141
3.671875
4
[]
no_license
# You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. # You may assume the two numbers do not contain any leading zero, except the number 0 itself. # ...
true
5a0e1e9f2adce202becce69ac1c85ed0f38f6fad
Ruby
yiyi1026/projecteuler_ruby
/leetcode/54.spiral_matrix.rb
UTF-8
1,081
4.03125
4
[]
no_license
''' Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. ''' def spiral_order(matrix) return matrix if matrix.empty? m, n = matrix.leng...
true