Skip to content

Instantly share code, notes, and snippets.

View davidxkr's full-sized avatar

David Madrigal davidxkr

  • ArcusFi
  • Colima, Mexico
View GitHub Profile
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.
#Feedback from "El gran pregunton" !!!!
c = 0
d = 0
5001.times do
c += 1
d = d + c
end
#Feedback from "El gran pregunton" !!!!
c = 0
d = 0
5001.times do
c += 1
d = d + c
end
#Feedback from "El Gran pregunton" !!!!
# Podemos ver que entendiste bien la idea
# Por otro lado es posible refactorizar tu codigo de la siguiente manera
i = 1
y=0
x=1 # estas tres asignaciones pueden ser en una sola linea "Asignación paralela" i,y,x = 1,0,1
while i=1 do # Recuerda i == 1
#Feedback from "El gran pregunton" !!!!
# Es posible que no haya quedado muy claro el problema
# ya que calculas el primer numero triangular que "Acumula" 500 divisores
#
def triangle_num
cont = 0 #Puedes ahorrarte estas cuatro lineas con "Asignación paralela" "cont, n, i, tri = 0, 0, 0, 0"
n = 0
i = 0
class SM1
def initialize
file = File.exists?('dev.log') ? File.open('dev.log', 'a') : File.new('dev.log', 'a')
file << 'Just creating ' + self.class.to_s + "\n"
end
end
class SM2
def initialize
require 'benchmark'
class Euler14Recursive
def initialize
@chain_size = 0
end
def euler_chain_recursive(number)
@chain_size += 1

#Question 3# ##Problem overview##

On May 18, 2006 Jeff Atwood from http://www.codinghorror.com/blog/ said:

I'm often asked why the book Refactoring isn't included in my recommended developer reading list. Although I own the book, and I've read it twice, I felt it was too prescriptive-- if you see (x), then you must do (y). Any programmer worth his or her salt should already be refactoring aggressively. It's so essential to the craft that if you have to read a book to understand how it works, you probably shouldn't be a programmer in the first place.

There's nothing wrong with codifying refactoring guidelines in a book. But the most important guideline is to watch for warning signs in your own code-- so called "code smells". ##Now, this is what you have do to##

The n^(th) term of the sequence of triangle numbers is given by, t_(n) = ½n(n+1); so the first ten triangle numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is 19 + 11 + 25 = 55 = t_(10). If the word value is a triangle number then we shall call the word a triangle word.
implement the ruby code than answer the last question ?
Using the next file: words.txt a 16K text file containing nearly two-thousand common English words, how many are triangle words?
RailsSettings::Settings::SettingNotFound in Admin::ConfigurationsController#update
Setting variable "footer_image" not found
Rails.root: /Users/david_xkr/proyectos/pp_peru
Application Trace | Framework Trace | Full Trace
lib/image_creator.rb:36:in `upload_images'
app/controllers/admin/configurations_controller.rb:37:in `upload_style_images'
app/controllers/admin/configurations_controller.rb:15:in `update'
Request