{"id":13746192,"url":"https://github.com/apauley/HollingBerries","last_synced_at":"2025-05-09T07:30:26.369Z","repository":{"id":3278211,"uuid":"4318176","full_name":"apauley/HollingBerries","owner":"apauley","description":"A fictional scenario implemented in multiple languages in order to compare language paradigms.","archived":false,"fork":false,"pushed_at":"2016-04-08T10:59:58.000Z","size":193,"stargazers_count":68,"open_issues_count":0,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T22:51:09.498Z","etag":null,"topics":["clojure","erlang","haskell","python","ruby","scala","smalltalk","toy-problems"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apauley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-13T22:55:13.000Z","updated_at":"2024-12-24T04:10:15.000Z","dependencies_parsed_at":"2022-08-26T08:00:20.493Z","dependency_job_id":null,"html_url":"https://github.com/apauley/HollingBerries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apauley%2FHollingBerries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apauley%2FHollingBerries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apauley%2FHollingBerries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apauley%2FHollingBerries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apauley","download_url":"https://codeload.github.com/apauley/HollingBerries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253209221,"owners_count":21871610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","erlang","haskell","python","ruby","scala","smalltalk","toy-problems"],"created_at":"2024-08-03T06:00:49.559Z","updated_at":"2025-05-09T07:30:26.031Z","avatar_url":"https://github.com/apauley.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"Introduction\n============\nMeet Mr. and Mrs. Hollingberry. Recently retired, Mr. Hollingberry has decided\nto move to sunny South Africa and open up a small local convenience store to\nkeep him and Mrs. Hollingberry out of mischief.\n\nAlas, it turned out not be such a laid-back job as he had hoped...\n\nThe Problem\n===========\nOne of their current problems is printing price tags on their fresh produce.\nEvery morning, as soon as the various produce have been delivered,\nMrs. Hollingberry enters it into a program her nephew had written.\n\nThe result is a comma-seperated file that includes, among other\nfields, the cost price (in cents) and delivery date of each product.\n\nThe Task\n========\nYour job is to write a program that reads the csv file and then creates\na new file that will be used to print out the price tags.\n\nThe Input File\n===============\nAn example csv file is in this directory (produce.csv).\nWe use the following fields:\n\n*   Supplier ID.\n\n    All suppliers are equal, but [some are more equal than others](https://en.wikiquote.org/wiki/Animal_Farm).\n\n*   Product code.\n\n    This tells us what kind of produce we're dealing with.\n\n*   Description.\n\n    We can print part of this on the price tag.\n\n*   Delivery date.\n\n    YYYY/MM/DD. We use this to calculate the sell-by date.\n\n*   Cost price.\n\n    In cents. We use this to calculate the selling price.\n\n*   Unit count.\n\n    We need to print a price tag for each item delivered.\n\nThe Output File\n===============\nAn example output file generated from the example input file is in this directory (pricefile.txt).\nThe price file has 3 fields on each line:\nthe selling price, the sell-by date and a product description.\n\nThe price file is in fixed-width format, because the label printer has\nlimited space (50 characters) for each price tag. Each line in the price file will\ncause one price tag to be printed.\n\nThe selling price takes up 9 characters. One currency symbol (R), 5\ndigits before the decimal (a dot) and 2 digits after the decimal.\nLike this: R99999.99\n\nMr Hollingberry says we shouldn't worry about larger amounts. If he\never sells something for a 100 grand he will have to retire again, and\nhe can't take that kind of stress again.\n\nThe sell-by date, just like the delivery date in the input file, is in\nYYYY/MM/DD format (10 characters).\n\nThe remaining 31 characters is used for the product description.\n\nA typical line in the price file will look like this:\n\n\u003e R   19.922012/05/26Apples 1kg Green. They are very\n\nThe Business Rules\n==================\nYou have to calculate the selling price and the sell-by date. Luckily\nwe can use the description just as it is in the csv file. Well, the\nfirst 31 characters of it anyway.\n\n## Markup Rules\n* The markup for apples  is 40%.\n* The markup for bananas is 35%.\n* The markup for berries is 55%.\n* The markup for anything else 50%.\n\n## Sell-by Dates\n* Apples have to be sold 2 weeks after the date of delivery.\n* Bananas have to be sold 5 days after the date of delivery.\n* All other types of fruit has to be sold 1 week after the date of\ndelivery.\n\n## Product Codes\n* Fruit has product codes ranging from 1000 to 1999.\n* Apples specifically have product codes ranging from 1100 to 1199.\n* Bananas have product codes ranging from 1200 to 1299.\n* Berries have product codes ranging from 1300 to 1399.\n\n## Supplier Troubles\nOne of the suppliers, Susan Windler (Supplier ID 32), has been known to deliver\nfruit that is not quite as fresh as that of the other suppliers.\nMr. Hollingberry has decided to handle this quietly, by:\n\n* ensuring that the sell-by date for anything delivered by Susan is always 3\n  days earlier than normal.\n* making the price R2 less than usual.\n\nCome to think of it, Togetherness Tshabalala (Supplier ID 101), also\nneeds to be on this list.\n\n## Premium Produce (tm)\nSome suppliers are dedicated Premium Produce (tm) suppliers.\nThe customer has to believe that they are buying something better than\nusual.\nMr Hollingberry does this by making the packaging look nice, and by increasing the\nprice.\nThe suppliers already took care of the nice packaging, you now have to\nmake it expensive. Anything supplied by a Premium Produce (tm)\nsupplier gets an additional 10% markup, and then the price is rounded\nup to the nearest Rand.\n\nFor example, a product that would usually have a 50% markup would now have a 60% markup.\n(It would be incorrect to first apply a 50% markup and then apply another 10% on top of that).\nIf a product costs R25.11 after the extra 10% markup has\nbeen applied, you need to round it up to R26.\n\nThe Premium Produce suppliers currently are:\n\n* Promise Mashangu (Supplier ID 219)\n* Karel Visser (Supplier ID 204)\n\nHow do I contribute my solution?\n================================\n\n*   Fork https://github.com/apauley/HollingBerries on github.\n\n*   Make a subdirectory for your language, if it isn't already there\n\n*   Put your code in a subdirectory named with your github username\n\n    \u003e eg. ocaml/yminsky\n\n*   If you want, put a description after your github username\n\n    \u003e eg. ruby/apauley-functionalruby\n\n*   Make sure that your solution generates exactly the same output\n    file when given the sample input file:\n\n    \u003e $ diff -u ../../pricefile.txt pricefile.txt # Expect no output\n\n*   Include a README file with instructions on how to build/run your\n    code. A Makefile or something similar will be nice. Also, tell us\n    a bit about your solution if you feel like it.\n\n*   Ensure that your repository is up to date:\n\n    \u003e $ git pull --rebase\n\n*   Send me a pull request so that your solution is included with the\n    others. By doing this you agree that your code may be used by\n    anyone for any purpose. If you use someone elses code it will be\n    nice to give him/her credit. Email me if you have a suggestion for an informal\n    license that fits these code comparisons. MIT? Creative Commons?\n\nWhy this example?\n=================\n\nProgrammers with an Object Oriented background that are interested in\nFunctional Programming (like myself) often have the following\nconcerns:\n\n\"How do I design/model a problem when I don't have my trusted classes\nand objects available?\"\n\nIf you're used to the \"everything must be an object\" philosophy, you\nmight feel that your hands are cut off.\n\nI wanted a scenario that a typical OO programmer would solve using an\nobject hierarchy with some polymorphism. And then have solutions for\nthe same problem in functional programming languages so that it can be\neasily compared.\n\nOf course it will also be very interesting to see paradigms other than\nOO and FP :-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapauley%2FHollingBerries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapauley%2FHollingBerries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapauley%2FHollingBerries/lists"}