{"id":18947177,"url":"https://github.com/qedsoftware/facebook-hackercup-2013-quals","last_synced_at":"2025-10-08T19:38:15.922Z","repository":{"id":6642856,"uuid":"7887019","full_name":"qedsoftware/facebook-hackercup-2013-quals","owner":"qedsoftware","description":"(Python) Facebook Hackercup 2013 Qualifying Round solutions. ","archived":false,"fork":false,"pushed_at":"2013-04-18T21:53:04.000Z","size":136,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-25T13:48:37.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/qedsoftware.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":"2013-01-29T06:51:17.000Z","updated_at":"2018-04-27T12:42:12.000Z","dependencies_parsed_at":"2022-08-26T08:41:18.796Z","dependency_job_id":null,"html_url":"https://github.com/qedsoftware/facebook-hackercup-2013-quals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qedsoftware/facebook-hackercup-2013-quals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Ffacebook-hackercup-2013-quals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Ffacebook-hackercup-2013-quals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Ffacebook-hackercup-2013-quals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Ffacebook-hackercup-2013-quals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qedsoftware","download_url":"https://codeload.github.com/qedsoftware/facebook-hackercup-2013-quals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Ffacebook-hackercup-2013-quals/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000703,"owners_count":26082805,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-08T13:09:10.832Z","updated_at":"2025-10-08T19:38:15.891Z","avatar_url":"https://github.com/qedsoftware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"FACEBOOK-HACKERCUP-2013-QUALS\n=============================\n\nMy solutions for Facebook Hackercup 2013, Qualifying Round.\n\nWilliam Wu\n\n\n\nPROBLEM 1: BALANCED SMILEYS\n=============================\n\nWhen John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.\n\nGiven a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.\n\nThe beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)\n\nYou're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?\n\n__Input__\n\nThe input file consists of a single integer m followed by m lines.\n\n__Output__\n\nYour output should consist of, for each test case, a line containing the string \"Case #x: y\" where x is the case number (with 1 being the first case in the input file, 2 being the second, etc...) and y is the maximum beauty for that test case.\n\n__Constraints__\n\n5 \u003c= m \u003c= 50\n2 \u003c= length of s \u003c= 500\n\n\n__Example Input__\n\n\t5\n\tABbCcc\n\tGood luck in the Facebook Hacker Cup this year!\n\tIgnore punctuation, please :)\n\tSometimes test cases are hard to make up.\n\tSo I just go consult Professor Dalves\n\n\n__Example Output__\n\n\tCase #1: 152\n\tCase #2: 754\n\tCase #3: 491\n\tCase #4: 729\n\tCase #5: 646\n\n\n\nPROBLEM 2: BEAUTIFUL STRINGS\n=============================\n\nYour friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :(\n \nSometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.\n \nA message has balanced parentheses if it consists of one of the following:\n- An empty string \"\"\n- One or more of the following characters: 'a' to 'z', ' ' (a space) or ':' (a colon)\n- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'\n- A message with balanced parentheses followed by another message with balanced parentheses.\n- A smiley face \":)\" or a frowny face \":(\"\n \nWrite a program that determines if there is a way to interpret his message while leaving the parentheses balanced.\n \n__Input__\n\nThe first line of the input contains a number T (1 \u003c= T \u003c= 50), the number of test cases.\nThe following T lines each contain a message of length s that you got from John.\n \n__Output__\n\nFor each of the test cases numbered in order from 1 to T, output \"Case #i: \" followed by a string stating whether or not it is possible that the message had balanced parentheses. If it is, the string should be \"YES,\" else it should be \"NO\" (all quotes for clarity only).\n \n__Constraints__\n\n\t1 \u003c= length of s \u003c= 100\n\n__Example Input__\n\n\t5\n\t:((\n\ti am sick today (:()\n\t(:)\n\thacker cup: started :):)\n\t)(\n\n__Example Output__\n\n\tCase #1: NO\n\tCase #2: YES\n\tCase #3: YES\n\tCase #4: YES\n\tCase #5: NO\n\n\n\nPROBLEM 3: FIND THE MIN\n=============================\nAfter sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, m, which contains n non-negative integers. However, only the first k values of the array are known to him, and he wants to figure out the rest.\n \nJohn knows the following: for each index i, where k \u003c= i \u003c n, m[i] is the minimum non-negative integer which is *not* contained in the previous *k* values of m.\n \nFor example, if k = 3, n = 4 and the known values of m are [2, 3, 0], he can figure out that m[3] = 1.\n \nJohn is very busy making the world more open and connected, as such, he doesn't have time to figure out the rest of the array. It is your task to help him.\n \nGiven the first k values of m, calculate the nth value of this array. (i.e. m[n - 1]).\n \nBecause the values of n and k can be very large, we use a pseudo-random number generator to calculate the first k values of m. Given positive integers a, b, c and r, the known values of m can be calculated as follows:\n\nm[0] = a\nm[i] = (b * m[i - 1] + c) % r, 0 \u003c i \u003c k\n \n__Input__\n\nThe first line contains an integer T (T \u003c= 20), the number of test cases.\nThis is followed by T test cases, consisting of 2 lines each.\nThe first line of each test case contains 2 space separated integers, n, k (1 \u003c= k \u003c= 105, k \u003c n \u003c= 109).\nThe second line of each test case contains 4 space separated integers a, b, c, r (0 \u003c= a, b, c \u003c= 109, 1 \u003c= r \u003c= 109).\n\n__Output__\n\nFor each test case, output a single line containing the case number and the nth element of m.\n\n__Example Input__\n\n\t5\n\t97 39\n\t34 37 656 97\n\t186 75\n\t68 16 539 186\n\t137 49\n\t48 17 461 137\n\t98 59\n\t6 30 524 98\n\t46 18\n\t7 11 9 46\n\n__Example Output__\n\n\tCase #1: 8\n\tCase #2: 38\n\tCase #3: 41\n\tCase #4: 40\n\tCase #5: 12","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedsoftware%2Ffacebook-hackercup-2013-quals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqedsoftware%2Ffacebook-hackercup-2013-quals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedsoftware%2Ffacebook-hackercup-2013-quals/lists"}