1 def solve(goal, values)
2 x = values.____
3
4 subsets = lambda do |k|
5 return { _______ } if k < 0
6 old_sums = subsets[___]
7
8 new_sums = ___
9
10 old_sums.keys.each do |p|
11 c = p + ____
12 new_sums[c] = _________________ if c <= goal
13 end
14
15 return old_sums._____(new_sums)
16 end
17
18 z = subsets[values.________][goal] || []
19 x.values_at(*z)
20 end
21
22 rdropbox = {
23 'free-lunch' => 802,
.. .......................,
34 'playing-drums' => -295
35 }.invert
36
37 s = solve(0, rdropbox.keys)
38 puts s.inspect
39 puts rdropbox.values_at(*s).inspect
________________)
_______________)
__________________)
_______________)
_________)
e = 'c'.re - +('d'.re | 'r'.re) # /c(d|r)+/
s = 'crddf'
remaining = e[s] # s =~ /c(d|r)+/
puts "/c(d|r)+/ '#{s}' Matched. Remaining = '#{remaining}'" if remaining
# /c(d|r)+/ 'crddf' Matched. Remaining = 'f'
e = 'c'.re - ~('d'.re | 'r'.re) # /c(d|r)*/
s = 'cdrdrf'
remaining = e[s] # s =~ /c(d|r)*/
puts "/c(d|r)*/ '#{s}' Matched. Remaining = '#{remaining}'" if remaining
Rellene el código que falta:
1 class ____
2
3 def -(right) # concatenacion
4 lambda { |x| _ _ self[x] ___ right[_] }
5 end
6
7 def |(right) # or
8 lambda { |x| self[x] __ _____[x] }
9 end
10
11 def epsilon # palabra vacía
12 lambda {|x| _ }
13 end
14
15 def ~ # cierre de Kleene *
16 lambda { |x| (_____)[x] or self._______[x] }
17 end
18
19 def +@ # cierre positivo
20 lambda { |x| (____________)[x] }
21 end
22
23 end # Proc
24
25 class ______
26 def re
27 lambda { |x| x[0,self.______] == ____ and x[self.______..__] }
28 end
29 end
send?¿Que argumentos lleva? ¿que retorna?
define_method? ¿Cómo funciona?
¿Que argumentos recibe? ¿Que devuelve? ¿En que contexto espera ser evaluado?
/^[a-z_]+\w*$/i?
method_missing? ¿Que argumentos espera? ¿Que precauciones hay que tomar
cuando se escribe uno?
1 require 'delegate' 2 class Set < DelegateClass(Array)¿Que ocurre en la línea 2? ¿Que debe hacerse en el
initialize para que el proceso de delegación funcione?
index de un objeto de la clase Array?
x?
x?
mm de una clase o módulo MM
por nuestro propio mm?
markby:
class HTML
attr_accessor :page
def initialize(&block)
@page = ____
_____________ &block
end
def build_attr(attributes)
return '' if attributes.nil? or attributes._____?
attributes.______(__) { |s,x| s += %{ ___________________ } }
end
def method_missing(tag, *args)
if block_given?
@page.____ ______
_____
text = @page.________
else
text = args.__________ || "\n"
end
tagattr = build_attr(args.shift)
text = "______________________________________"
@page[__].push ____
text
end
def to_s
@page.join("\n")
end
end
git init
git add
git commit
git clone ssh://..
git status
git diff oldref newref
git push
git pull
require '_________' para elaborar una prueba?
Test::Unit?
Rake?
Rakefile ¿cierto o falso?
sh?
libs y pattern del objeto t en el siguiente código?
Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList['test/test*.rb'] t.verbose = true end
Casiano Rodriguez León 2015-01-07