{"id":17085102,"url":"https://github.com/p1xt/algo-nov-17","last_synced_at":"2025-03-23T14:12:03.255Z","repository":{"id":88167120,"uuid":"74048350","full_name":"P1xt/algo-nov-17","owner":"P1xt","description":"repository for JavaScript Algorithm Challenge - November 9 through 16","archived":false,"fork":false,"pushed_at":"2016-11-17T17:00:31.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T20:16:45.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/P1xt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-17T16:58:50.000Z","updated_at":"2016-11-17T17:00:33.000Z","dependencies_parsed_at":"2023-03-16T17:15:30.496Z","dependency_job_id":null,"html_url":"https://github.com/P1xt/algo-nov-17","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/P1xt%2Falgo-nov-17","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P1xt%2Falgo-nov-17/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P1xt%2Falgo-nov-17/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P1xt%2Falgo-nov-17/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/P1xt","download_url":"https://codeload.github.com/P1xt/algo-nov-17/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245111952,"owners_count":20562512,"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":"2024-10-14T13:23:15.932Z","updated_at":"2025-03-23T14:12:03.236Z","avatar_url":"https://github.com/P1xt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript Algorithm Challenge - November 9 through 16\n\nI would like to challenge everyone to solve the following algorithmic problem over the next week. Consider the problem carefully, take your time, edit your solution as many times as you want.\n\n## The Challenge\nThis is a \"code golf\" challenge which means: Solve the following algorithmic challenge using the fewest characters of code possible. Every character (alpha, numeric, whitespace, punctuation, ANYTHING) between the beginning brace` \"{\"` and the ending brace `\"}\"` will count as one character. \n\nFor instance:\n```\nfunction rideP1xt(g, c) { return g };\n```\nwould receive a score of 10 because there are 10 characters between the braces (including spaces). Note, that newlines and tabs count as characters as well.\n\nYou are aiming for the \"lowest score\" possible.\n\n### Answers to questions about the challenge#\n\n@Omegga  - Passing logic in as default parameters, though wildly clever, wouldn't be acceptable.\n\n@Velenir - Yes, you can pollute the global namespace. Yes you can rewrite the function as an arrow function, though it should be testable by calling `rideVelenir(\"ABSTAR\", \"USACO\")` and nothing except the comet and group should be passed in via parameters (no shaving off bytes by declaring or initializing anything outside the function or as default parameters to the function).\n\n#### The rules (totally unenforceable, but hey, be honest, you'll learn more):\n\n* Post your solution in spoiler tags.\n* One solution per camper, but you can edit your post (and thus your solution) as many times as you want until the challenge is over.\n* Name the function you create `ride\u003cForum Name\u003e` where `\u003cForum Name\u003e` is your name on the forums, my solution would be in a function named `rideP1xt`\n* Solve the problem yourself. Don't google for an answer, don't hit stack overflow, don't read other camper's answers.\n* To the extent that it's possible, limit yourself to one post in this thread (so it'll be easier for me to round up everybody's answers at the end.\n* Please avoid discussion after you've solved the problem until the challenge is over, so you don't spoiler others and mess up their chances to solve the problem on their own.\n\n## The Problem\n\n\u003e It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a function which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.\n\n\u003e Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where \"A\" is 1 and \"Z\" is 26. For instance, the group \"USACO\" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that \"a mod b\" is the remainder left over after dividing a by b; 34 mod 10 is 4.)\n\n\u003e Write a function named ride\u003cForum Name\u003e where \u003cForum Name\u003e is your name on the forums which takes as parameters the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, and returns the string \"GO\" if they match and \"STAY\" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.\n\n\u003e \n\u003e rideX(\"COMETQ\", \"HVNGAT\");\n\u003e Should Return: GO\n\n\u003e rideX(\"ABSTAR\", \"USACO\");\n\u003e Should Return: STAY\n\n\n\n## Helpful Notes:\n\nAny camper who wants can join in this, if you're not up to the JavaScript section of FCC yet, hit [codecademy (javascript lessons)](https://www.codecademy.com/learn/javascript)  or [The Net Ninja's JavaScript Tutorial on YouTube](https://www.youtube.com/playlist?list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET) and then code your solution on [repl.it](https://repl.it/languages/javascript). Once you've got it working, copy the code into a post here (inside spoiler tags, of course). \n\n### You might also find the following helpful:\nhttps://www.youtube.com/playlist?list=PL4cUxeGkcC9gKfw25slm4CUDUcM_sXdml\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while\n### You create spoiler tags by enclosing your spoiler text in between `[details=\"Spoiler\"]Text you want to hide[/details]`\n\nHere's exactly how to put a code snippet inside a Spoiler tag. You can copy it directly (be sure to get the blank line at  the top) and paste it into your post, then replace the `function rideX` part with your own function.\n\n    \n    [details=Spoiler]\n\n    ```javascript\n\n    function rideX(cometName, groupName) {\n      \n    }\n\n    ```\n\n    [/details]\n\nI will be testing all solutions using Node.js 6.5 (so you can feel free to use any ES6 that will run in 6.5, which is most of it).\n\n@JacksonBates Wrote up a handy tutorial on how to use Mocha and Chai to write a handy test runner to double check that your function produces the correct values here: \nhttp://forum.freecodecamp.com/t/testing-your-own-code-using-mocha-and-chai-simple-example/44149 \n\n## When the challenge ends:\n\nHere's a handy countdown timer so you know how long before the challenge ends:\nhttps://countingdownto.com/countdown/javascript-algorithm-challenge-november-9-through-16-countdown-clock\n\nThe morning after the challenge ends, I'll first test everyone's answer to ensure it's correct, then run a script to character count all of the correct solutions. \n\n## The Reward?\n\nAside from the pure fun of practicing creating algorithms, I don't have a lot to offer. Though I will post the names of everyone who solved the problem, with a special list of those who solved it the most succintly as an edit to this post\n\n\n## The Results\n\n### All Participants\n----------\nZsoltime,\nBenGitter,\nNewBorn,\nJacksonBates,\nJenovs,\nOmegga,\nVelenir,\nkevcomedia,\njoelpeyton,\nalichristensen,\nZackWard,\nNacla01,\nRayBB,\nappleJax,\nNicksIdeaEngine,\nCirych,\nBhavik\n\n\n### Top Five by solution character count\n----------\nVelenir - 76 characters    \nOmegga - 80 characters    \nkevcomedia - 83 characters    \nZackWard - 93 characters    \nRayBB - 93 characters     \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1xt%2Falgo-nov-17","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp1xt%2Falgo-nov-17","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1xt%2Falgo-nov-17/lists"}