265OXFLQA7GQAZTAD2PAE7C6M2M3HW3576QAQ6NQ4J4SOGJYIOYQC class Library# Title;ISBN;Author;PublishedCATALOG_DATA = <<~DATAThe Adventures of Tom Sawyer;9780191604928;Mark Twain;2007Republic;9780718198916;Plato;2012Programming Ruby: The Pragmatic Programmers Guide;9780974514055;David Thomas;2004Pride and Prejudice by Jane Austen;9781986431484;Jane Austen;2018To Kill a Mockingbird;9780446310789;Harper Lee;1988Cosmicomics;9780330319089;Italo Calvino;1969The Lord of the Rings;9780544003415;J. R. R. Tolkien;2012Lord of the Flies;9780140283334;William Golding;19991984: A Novel;9780451524935;George Orwell;2009DATACATALOGUE = CATALOG_DATA.split("\n").map {|line| line.split(";")}def initializedef lookup_title(isbn)CATALOGUE.select {|a| a[1] == isbn}[0][0]enddef lookup_author(isbn)CATALOGUE.select {|a| a[1] == isbn}[0][2]enddef lookup_publication_year(isbn)CATALOGUE.select {|a| a[1] == isbn}[0][3]end@counts = CATALOGUE.map { |line| [line[1], [0, 0]] }.to_hdef add_stock!(isbn, count)@counts[isbn][0] += countenddef borrow!(isbn)if @counts[isbn][0] > 0@counts[isbn][0] -= 1@counts[isbn][1] += 1endenddef put_back!(isbn)if @counts[isbn][1] > 0@counts[isbn][0] += @counts[isbn][1]@counts[isbn][1] = 0endenddef lookup_stock(isbn)@counts[isbn][0]enddef book_in_stock?(isbn)@counts[isbn][0] > 0enddef books_in_stockCATALOGUE.map { |line| line[1] }.select { |isbn| @counts[isbn][0] > 0 }enddef total_books_in_stockCATALOGUE.inject(0) { |sum, line| sum + @counts[line[1]][0] }endendend
// @ts-check/*** Extract a value from an object using a path** @template T** @param {object} object the input object* @param {string} path the path to the value in the object** @returns {T}*/export function extract(object, path) {return path.split('.').reduce((acc, elem) => typeof acc[elem] === 'undefined' ? null : acc[elem], object);}
// input: some string// output: that string with all vowels removedpub fn disemvowel(s: &str) -> String {let mut s = s.to_string();s.retain(|c| !"AEIOUaeiou".contains(c));s}
"""Perform Run Length Encoding compression on a string."""def compress(raw: str) -> bytes:"""Compress the raw string to bytes using RLE."""out: list[int] = []for b in raw.encode('utf-8'):if out:byte = out.pop()if b == byte:count = out.pop()out.append(count + 1)out.append(byte)else:out.append(byte)out.append(1)out.append(b)else:out.append(1)out.append(b)return bytes(out)
package go1bimport ("strconv""strings")func Score(hand string) int {var out int = 0for _, card := range strings.Split(hand, "") {val, err := strconv.Atoi(card)if err == nil {out += val} else {switch card {case "X", "J", "Q", "K":out += 10case "A":out += 11}}}return out}// PlayerWins determines if the player has a winning blackjack hand.func PlayerWins(playerHand string, dealerHand string) bool {var playerScore, dealerScore int = Score(playerHand), Score(dealerHand)return dealerScore > 21 || playerScore > dealerScore && playerScore <= 21}
module AggregateScorers exposing (..)import Dict exposing (Dict)aggregateScorers : List String -> List StringaggregateScorers playerNames =letdict = List.foldl (\elem acc ->if Dict.member elem accthenDict.update elem (Maybe.map <| \count -> count + 1) accelseDict.insert elem 1 acc) Dict.empty playerNamesinList.map (\orig ->letval = Dict.get orig dictinif val == Just 1thenorigelseorig ++ " (" ++ String.fromInt (Maybe.withDefault 0 val) ++ ")") <| List.sort <| Dict.keys dict
# DescriptionMy solutions to the exercises and experiments on [exercism](https://exercism.io/).---## LicenseThis software is distributed and licensed under the terms of the [Blue Oak Model License 1.0.0](https://web.archive.org/web/20190309191626/https://blueoakcouncil.org/license/1.0.0).
# Blue Oak Model LicenseVersion 1.0.0## PurposeThis license gives everyone as much permission to work withthis software as possible, while protecting contributorsfrom liability.## AcceptanceIn order to receive this license, you must agree to itsrules. The rules of this license are both obligationsunder that agreement and conditions to your license.You must not do anything with this software that triggersa rule that you cannot or will not follow.## CopyrightEach contributor licenses you to do everything with thissoftware that would otherwise infringe that contributor'scopyright in it.## NoticesYou must ensure that everyone who gets a copy ofany part of this software from you, with or withoutchanges, also gets the text of this license or a link to<https://blueoakcouncil.org/license/1.0.0>.## ExcuseIf anyone notifies you in writing that you have notcomplied with [Notices](#notices), you can keep yourlicense by taking all practical steps to comply within 30days after the notice. If you do not do so, your licenseends immediately.## PatentEach contributor licenses you to do everything with thissoftware that would otherwise infringe any patent claimsthey can license or become able to license.## ReliabilityNo contributor can revoke this license.## No Liability***As far as the law allows, this software comes as is,without any warranty or condition, and no contributorwill be liable to anyone for any damages related to thissoftware or this license, under any kind of legal claim.***