{"id":27766484,"url":"https://github.com/uggla/rust_dojo_02","last_synced_at":"2025-06-29T23:32:40.734Z","repository":{"id":217276422,"uuid":"743445452","full_name":"uggla/rust_dojo_02","owner":"uggla","description":"Coding dojo #1 in Rustlang","archived":false,"fork":false,"pushed_at":"2025-01-06T15:16:10.000Z","size":329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T11:12:35.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uggla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-15T08:55:41.000Z","updated_at":"2025-03-30T17:27:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"39afadd1-6c43-4826-b5b4-15e27863f239","html_url":"https://github.com/uggla/rust_dojo_02","commit_stats":null,"previous_names":["uggla/dojo","uggla/rust_dojo_02"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uggla/rust_dojo_02","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Frust_dojo_02","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Frust_dojo_02/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Frust_dojo_02/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Frust_dojo_02/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uggla","download_url":"https://codeload.github.com/uggla/rust_dojo_02/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Frust_dojo_02/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685118,"owners_count":23348409,"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":[],"created_at":"2025-04-29T17:31:56.030Z","updated_at":"2025-06-29T23:32:40.714Z","avatar_url":"https://github.com/uggla.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coding Dojo #1\n\nA simple rust exercise to be done in a coding dojo.\nThis is based on Advent of Code 2022 day 1: \u003chttps://adventofcode.com/2022/day/1\u003e\n\nThe subject has been extended to manage error and show ownership concepts.\n\nI think this example is not difficult from a algorithmic point of view,\nthe idea is to really decompose the problem into smaller pieces and provides\nunitary tests for each of them.\nSo attendes could focus on TDD and discover some part of the Rust language.\n\n## Expectations\n\nGive participants some Rust insight that will give them\nmotivations to learn more.\nThis is also an experimentation to know if this approach could help people\nto start and learn Rust.\n\n## Instruction\n\n### Part 1\n\nSanta's reindeer typically eat regular reindeer food, but they need a\nlot of magical energy to deliver presents on Christmas. For that, their\nfavorite snack is a special type of star fruit that only grows deep in the\njungle. The Elves have brought you on their annual expedition to the grove\nwhere the fruit grows.\n\nTo supply enough magical energy, the expedition needs to retrieve a minimum\nof fifty stars by December 25th. Although the Elves assure you that the\ngrove has plenty of fruit, you decide to grab any fruit you see along the\nway, just in case.\n\nCollect stars by solving puzzles. Two puzzles will be made available on\neach day in the Advent calendar; the second puzzle is unlocked when you\ncomplete the first. Each puzzle grants one star. Good luck!\n\nThe jungle must be too overgrown and difficult to navigate in vehicles or\naccess from the air; the Elves' expedition traditionally goes on foot. As your\nboats approach land, the Elves begin taking inventory of their supplies. One\nimportant consideration is food - in particular, the number of Calories\neach Elf is carrying (your puzzle input).\n\nThe Elves take turns writing down the number of Calories contained by the\nvarious meals, snacks, rations, etc. that they've brought with them, one\nitem per line. Each Elf separates their own inventory from the previous\nElf's inventory (if any) by a blank line.\n\nFor example, suppose the Elves finish writing their items' Calories and\nend up with the following list:\n\n    1000\n    2000\n    3000\n\n    4000\n\n    5000\n    6000\n\n    7000\n    8000\n    9000\n\n    10000\n\nThis list represents the Calories of the food carried by five Elves:\n\n- The first Elf is carrying food with 1000, 2000, and 3000 Calories,\n  a total of 6000 Calories.\n- The second Elf is carrying one food item\n  with 4000 Calories.\n- The third Elf is carrying food with 5000 and\n  6000 Calories, a total of 11000 Calories.\n- The fourth Elf is carrying\n  food with 7000, 8000, and 9000 Calories, a total of **24000** Calories.\n- The fifth Elf is carrying one food item with 10000 Calories.\n\nIn case the Elves get hungry and need extra snacks, they need to know\nwhich Elf to ask: they'd like to know how many Calories are being carried\nby the Elf carrying the most Calories. In the example above, this is **24000**\n(carried by the fourth Elf).\n\nFind the Elf carrying the most Calories. How many total Calories is that Elf carrying?\n\n### Part 2\n\nBy the time you calculate the answer to the Elves' question, they've already\nrealized that the Elf carrying the most Calories of food might eventually\nrun out of snacks.\n\nTo avoid this unacceptable situation, the Elves would instead like to\nknow the total Calories carried by the top three Elves carrying the most\nCalories. That way, even if one of those Elves runs out of snacks, they\nstill have two backups.\n\nIn the example above, the top three Elves are the fourth Elf (with 24000\nCalories), then the third Elf (with 11000 Calories), then the fifth Elf\n(with 10000 Calories). The sum of the Calories carried by these three elves\nis 45000.\n\nFind the top three Elves carrying the most Calories. How many Calories are\nthose Elves carrying in total?\n\n### Part 3\n\nAn elf was drunk when providing the list.\nSo instead of writing the line with 8000, he wrote \"Bleurg!!\".\n\nIf a line cannot be transformed to a correct value, then the value is 0.\n\nWrite the corresponding test and fix the code to handle that case.\n\n### Part 4\n\nThe highest calorie count identified in part1 must be saved on Santa Claus's\ncomputer.\n\nFor this purpose, a **SantaComputer struct** that holds the data and\na checksum is required. The elves are currently developing this interface,\nwhich may undergo modifications; hence, it's advised to employ a function\nnamed **data** to calculate the data and another function named **checksum**\nto generate the checksum.\n\nAdditionally, for security measures, the elves\nhave provided a function named **get_santa_computer_secret**.\n\nThis function must be used with the part1 data to retrieve the secret value\nbefore the data and checksum calculations are performed.\n\n### Part 5\n\nThe elves have just discovered json, you should now provide the\nSantaComputer struct serialized into json.\n\n### Part 6\n\nStarting from part2, if you encounter an invalid value, you must not set it to 0.\nYou must discard all the colories transported by that elf.\n\n### Part 7\n\nCreate a checksum2 function that return an \u0026str instead of a string.\n\n### Part 8\n\nCreate a .top(n) method that return the top n elements of a Vec.\nThis can be achieved using the extension traits pattern.\n\n## Proposed editor\n\nThe idea is to use on online editor. Gitpod seems a good solution in that\ncase as only a browser is required to edit the code and the workspace can\nbe shared between participants.\n![Edition into Gitpod](pictures/gitpod.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Frust_dojo_02","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuggla%2Frust_dojo_02","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Frust_dojo_02/lists"}