# Title;ISBN;Author;Published
= <<~DATA
The Adventures of Tom Sawyer;9780191604928;Mark Twain;2007
Republic;9780718198916;Plato;2012
Programming Ruby: The Pragmatic Programmers Guide;9780974514055;David Thomas;2004
Pride and Prejudice by Jane Austen;9781986431484;Jane Austen;2018
To Kill a Mockingbird;9780446310789;Harper Lee;1988
Cosmicomics;9780330319089;Italo Calvino;1969
The Lord of the Rings;9780544003415;J. R. R. Tolkien;2012
Lord of the Flies;9780140283334;William Golding;1999
1984: A Novel;9780451524935;George Orwell;2009
DATA
= CATALOG_DATA.split("\n").map {
line.split(";")
}
CATALOGUE.select {
a[1] == isbn
}[0][0]
end
CATALOGUE.select {
a[1] == isbn
}[0][2]
end
CATALOGUE.select {
a[1] == isbn
}[0][3]
end
@counts = CATALOGUE.map { [line[1], [0, 0]] }.to_h
@counts[isbn][0] += count
end
if @counts[isbn][0] > 0
@counts[isbn][0] -= 1
@counts[isbn][1] += 1
end
end
if @counts[isbn][1] > 0
@counts[isbn][0] += @counts[isbn][1]
@counts[isbn][1] = 0
end
end
@counts[isbn][0]
end
@counts[isbn][0] > 0
end
CATALOGUE.map { line[1] }.select { @counts[isbn][0] > 0 }
end
CATALOGUE.inject(0) { sum + @counts[line[1]][0] }
end
end
end