Решение на Втора задача от Йоана Тодорова

Обратно към всички решения

Към профила на Йоана Тодорова

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 1 успешни тест(а)
  • 10 неуспешни тест(а)

Код

#!usr/bin/ruby -w
class Song
attr_accessor :s_name, :s_artist, :s_album
def initialize(name, artist, album)
@s_name, @s_artist, @s_album = name, artist, album
end
def name
@s_name
end
def artist
@s_artist
end
def album
@s_album
end
def keep_song?(array_of_criteria)
result = false
array_of_criteria.each do |hash_criteria|
result = (matches_criteria?(hash_criteria, true) or result)
end
result
end
def matches_criteria?(hash_criteria, result)
hash_criteria.each do |key, value|
a = method(key[0]).call == key[1]
b = value == true
result = (( b and a) or (not b and not a)) and result
end
end
end
class Collection
include Enumerable
def each
@collection.each { |obj| yield obj }
end
def initialize(songs)
@collection = Array.new.concat(songs)
@collection
end
def self.parse(text)
text = (text).split("\n\n").map { |obj| (obj).split("\n") }
@collection = text.map { |obj| Song.new(obj[0],obj[1],obj[2]) }
Collection.new(@collection)
end
def self.names
names_array = @collection.map { |song| song.name }
Collection.new(names_array.compact.uniq)
end
def self.artists
Collection.new(artists_array.compact.uniq)
print artists_array
end
def self.albums
albums_array = @collection.map { |song| song.album }
Collection.new(albums_array.compact.uniq)
end
def filter(values)
(array_of_songs = @collection).keep_if { |song| song.keep_song?(values) }
Collection.new(array_of_songs)
print array_of_songs
end
def adjoin(collection2)
Collection.new((@collection.concat(collection2)).uniq)
end
end
module MyModule
def help_and(crit)
@criteria.each { |hash_crit_other| crit = crit.merge(hash_crit_other) }
crit
end
def help_not(hash)
newhash = {}
hash.map { |key, value| newhash[key] = (not value) }
newhash
end
end
class Criteria
include Enumerable
include MyModule
attr_accessor :truth, :type, :value
def each
@criteria.each { |obj| yield obj }
end
def initialize(values)
@criteria = []
values.each { |value| @criteria = @criteria << value }
end
def self.name(text)
Criteria.new([{[:name, text] => true}])
end
def self.artist(text)
@truth ||="true"
Criteria.new([{[:artist, text] => true }])
end
def self.album(text)
@truth ||="true"
Criteria.new([{[:album, text] =>true}])
end
def &(other)
arr = []
@criteria.each { |hash_criteria| arr << other.help_and(hash_criteria) }
Criteria.new(arr)
end
def |(other)
other.each {|ob| puts ob.instance_of? Hash }
other.each { |hash_criteria| @criteria = @criteria << hash_criteria}
Criteria.new(@criteria)
end
def !@
arr = []
@criteria.each { |ob| arr = arr << help_not(ob) }
Criteria.new(arr)
end
end

Лог от изпълнението

FFF[#<Song:0x8a9e75c @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x8a9e02c @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x8a9df3c @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8a9df00 @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8a9dd70 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x8a9dc80 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x8a9db40 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x8a9d974 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x8a9d85c @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x8a9d758 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F[#<Song:0x8aaaa5c @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x8aaa9e4 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x8aaa994 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8aaa87c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8aaa728 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x8aaa5d4 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x8aaa46c @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x8aaa1ec @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x8aa9788 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x8aa9634 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F[#<Song:0x8ac73a0 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x8ac7288 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x8ac724c @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8ac70f8 @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8ac6fe0 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x8ac6d88 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x8ac6cd4 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x8ac6c20 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x8ac6b44 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x8ac6ab8 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F[#<Song:0x8ace9fc @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x8ace9c0 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x8ace998 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8ace920 @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8ace894 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x8ace858 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x8ace718 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x8ace68c @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x8ace5ec @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x8ace54c @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">].[#<Song:0x8d0fc98 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x8d0fc70 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x8d0fc34 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8d0fc0c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x8d0fbe4 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x8d0fbbc @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x8d0fb80 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x8d0fb58 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x8d0fb30 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x8d0fb08 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]Ftrue
[#<Song:0x9304dc4 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x9304cfc @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x9304c34 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9304a2c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x93049f0 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x930489c @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x9304720 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x9304644 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x93044c8 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x930439c @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F[#<Song:0x9308f14 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x9308ed8 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x9308e74 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9308e4c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9308e24 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x9308dfc @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x9308dac @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x9308d70 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x9308d48 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x9308cf8 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F[#<Song:0x9305fe4 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x9305fa8 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x9305f58 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9305f1c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9305ee0 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x9305ea4 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x9305e68 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x9305e40 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x9305e18 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x9305d78 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">][#<Song:0x9305fe4 @s_name="Fields of Gold", @s_artist="Sting", @s_album="Ten Summoner's Tales">, #<Song:0x9305fa8 @s_name="Mad About You", @s_artist="Sting", @s_album="The Soul Cages">, #<Song:0x9305f58 @s_name="Fields of Gold", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9305f1c @s_name="Autumn Leaves", @s_artist="Eva Cassidy", @s_album="Live at Blues Alley">, #<Song:0x9305ee0 @s_name="Autumn Leaves", @s_artist="Bill Evans", @s_album="Portrait in Jazz">, #<Song:0x9305ea4 @s_name="Brain of J.F.K", @s_artist="Pearl Jam", @s_album="Yield">, #<Song:0x9305e68 @s_name="Jeremy", @s_artist="Pearl Jam", @s_album="Ten">, #<Song:0x9305e40 @s_name="Come Away With Me", @s_artist="Norah Johnes", @s_album="One">, #<Song:0x9305e18 @s_name="Acknowledgment", @s_artist="John Coltrane", @s_album="A Love Supreme">, #<Song:0x9305d78 @s_name="Ruby, My Dear", @s_artist="Thelonious Monk", @s_album="Mysterioso">]F

Failures:

  1) Collection can find all the artists in the collection
     Failure/Error: collection.artists.should =~ [
     NoMethodError:
       undefined method `artists' for #<Collection:0x8a724a4>
     # /tmp/d20130203-23049-7qlizo/spec.rb:5:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Collection can find all the names of all songs in the collection
     Failure/Error: collection.names.should =~ [
     NoMethodError:
       undefined method `names' for #<Collection:0x8a8b8dc>
     # /tmp/d20130203-23049-7qlizo/spec.rb:17:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Collection can find all the albums in the collection
     Failure/Error: collection.albums.should =~ [
     NoMethodError:
       undefined method `albums' for #<Collection:0x8a937d0>
     # /tmp/d20130203-23049-7qlizo/spec.rb:30:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Collection can be filtered by song name
     Failure/Error: filtered.map(&:artist).should =~ ['Eva Cassidy', 'Sting']
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:45:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Collection can be filtered by song name
     Failure/Error: filtered.map(&:album).should =~ ['The Soul Cages', "Ten Summoner's Tales"]
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:50:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) Collection can be filtered by album
     Failure/Error: filtered.map(&:name).should =~ ['Fields of Gold', 'Autumn Leaves']
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:55:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) Collection supports a conjuction of filters
     Failure/Error: filtered.map(&:album).should eq ["Ten Summoner's Tales"]
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:65:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) Collection supports a disjunction of filters
     Failure/Error: filtered.map(&:album).should =~ [
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:70:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) Collection supports negation of filters
     Failure/Error: filtered.map(&:name).should eq ['Mad About You']
     NoMethodError:
       undefined method `map' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:79:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) Collection can be adjoined with another collection
     Failure/Error: adjoined = sting.adjoin(eva)
     NoMethodError:
       undefined method `adjoin' for nil:NilClass
     # /tmp/d20130203-23049-7qlizo/spec.rb:85:in `block (2 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.01301 seconds
11 examples, 10 failures

Failed examples:

rspec /tmp/d20130203-23049-7qlizo/spec.rb:4 # Collection can find all the artists in the collection
rspec /tmp/d20130203-23049-7qlizo/spec.rb:16 # Collection can find all the names of all songs in the collection
rspec /tmp/d20130203-23049-7qlizo/spec.rb:29 # Collection can find all the albums in the collection
rspec /tmp/d20130203-23049-7qlizo/spec.rb:43 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-7qlizo/spec.rb:48 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-7qlizo/spec.rb:53 # Collection can be filtered by album
rspec /tmp/d20130203-23049-7qlizo/spec.rb:63 # Collection supports a conjuction of filters
rspec /tmp/d20130203-23049-7qlizo/spec.rb:68 # Collection supports a disjunction of filters
rspec /tmp/d20130203-23049-7qlizo/spec.rb:77 # Collection supports negation of filters
rspec /tmp/d20130203-23049-7qlizo/spec.rb:82 # Collection can be adjoined with another collection

История (1 версия и 3 коментара)

Йоана обнови решението на 31.10.2012 15:34 (преди около 12 години)

+#!usr/bin/ruby -w
+
+class Song
+ attr_accessor :s_name, :s_artist, :s_album
+
+ def initialize(name, artist, album)
+ @s_name, @s_artist, @s_album = name, artist, album
+ end
+
+ def name
+ @s_name
+ end
+
+ def artist
+ @s_artist
+ end
+
+ def album
+ @s_album
+ end
+
+ def keep_song?(array_of_criteria)
+ result = false
+ array_of_criteria.each do |hash_criteria|
+ result = (matches_criteria?(hash_criteria, true) or result)
+ end
+ result
+ end
+
+ def matches_criteria?(hash_criteria, result)
+ hash_criteria.each do |key, value|
+ a = method(key[0]).call == key[1]
+ b = value == true
+ result = (( b and a) or (not b and not a)) and result
+ end
+ end
+end
+
+class Collection
+ include Enumerable
+
+ def each
+ @collection.each { |obj| yield obj }
+ end
+
+ def initialize(songs)
+ @collection = Array.new.concat(songs)
+ @collection
+ end
+
+ def self.parse(text)
+ text = (text).split("\n\n").map { |obj| (obj).split("\n") }
+ @collection = text.map { |obj| Song.new(obj[0],obj[1],obj[2]) }
+ Collection.new(@collection)
+ end
+
+ def self.names
+ names_array = @collection.map { |song| song.name }
+ Collection.new(names_array.compact.uniq)
+ end
+
+ def self.artists
+ Collection.new(artists_array.compact.uniq)
+ print artists_array
+ end
+
+ def self.albums
+ albums_array = @collection.map { |song| song.album }
+ Collection.new(albums_array.compact.uniq)
+ end
+
+ def filter(values)
+ (array_of_songs = @collection).keep_if { |song| song.keep_song?(values) }
+ Collection.new(array_of_songs)
+ print array_of_songs
+ end
+
+ def adjoin(collection2)
+ Collection.new((@collection.concat(collection2)).uniq)
+ end
+end
+
+module MyModule
+ def help_and(crit)
+ @criteria.each { |hash_crit_other| crit = crit.merge(hash_crit_other) }
+ crit
+ end
+
+ def help_not(hash)
+ newhash = {}
+ hash.map { |key, value| newhash[key] = (not value) }
+ newhash
+ end
+end
+
+class Criteria
+ include Enumerable
+ include MyModule
+
+ attr_accessor :truth, :type, :value
+
+ def each
+ @criteria.each { |obj| yield obj }
+ end
+
+ def initialize(values)
+ @criteria = []
+ values.each { |value| @criteria = @criteria << value }
+ end
+
+ def self.name(text)
+ Criteria.new([{[:name, text] => true}])
+ end
+
+ def self.artist(text)
+ @truth ||="true"
+ Criteria.new([{[:artist, text] => true }])
+ end
+
+ def self.album(text)
+ @truth ||="true"
+ Criteria.new([{[:album, text] =>true}])
+ end
+
+ def &(other)
+ arr = []
+ @criteria.each { |hash_criteria| arr << other.help_and(hash_criteria) }
+ Criteria.new(arr)
+ end
+
+ def |(other)
+ other.each {|ob| puts ob.instance_of? Hash }
+ other.each { |hash_criteria| @criteria = @criteria << hash_criteria}
+ Criteria.new(@criteria)
+ end
+
+ def !@
+ arr = []
+ @criteria.each { |ob| arr = arr << help_not(ob) }
+ Criteria.new(arr)
+ end
+end

Допълнително:

  • s_name, s_* не се прави в Ruby като се именуват променливи (т.е. типът им не се вкарва по този начин в името)
  • Променливи с имена arr, ob, MyModule, help_and, collection2, obj, a, b и т.н. са лошо избрани номера; това вече сме го казвали няколко пъти и ще взимаме точки за него; трябва да се вижда старание за добро именоване; изобщо, почти всичките ти имена са или твърде генерични, или зле избрани; например text в Collection.parse всъщност не е текст а списък от списъци с полета на песни; songs или нещо такова щеше да е по-подходящо
  • Ред 53, ако list = [:a, :b, :c] то вместо това foo(list[0], list[1], list[2]) може да направиш така: foo(*list) (има го в слайдовете)
  • Имаш редица проблеми с дизайна; след час-два като приключи крайния срок, ще може да видиш решения на колеги, които са успели да измислят хитри начини за справяне с проблема; силно препоръчвам да ги разгледаш и/или да се обадиш в някоя почивка, понеже коментарът ми е тесен да опиша всичките проблеми и, честно казано, ме мързи да пиша толкова :)