{"id":27083765,"url":"https://github.com/geektimus/scala-challenges","last_synced_at":"2025-04-06T03:19:09.747Z","repository":{"id":55374261,"uuid":"122686406","full_name":"geektimus/scala-challenges","owner":"geektimus","description":"This repo will contain the solutions using scala for some coding challenges","archived":false,"fork":false,"pushed_at":"2022-01-12T15:55:54.000Z","size":113,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T05:55:24.052Z","etag":null,"topics":["challenge","codility","coding-challenges","hackerrank","scala","scala-challenges"],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/geektimus.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":"2018-02-24T00:18:13.000Z","updated_at":"2023-02-11T22:31:18.000Z","dependencies_parsed_at":"2022-08-14T22:50:25.380Z","dependency_job_id":null,"html_url":"https://github.com/geektimus/scala-challenges","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/geektimus%2Fscala-challenges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geektimus%2Fscala-challenges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geektimus%2Fscala-challenges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geektimus%2Fscala-challenges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geektimus","download_url":"https://codeload.github.com/geektimus/scala-challenges/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427210,"owners_count":20937250,"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":["challenge","codility","coding-challenges","hackerrank","scala","scala-challenges"],"created_at":"2025-04-06T03:19:09.244Z","updated_at":"2025-04-06T03:19:09.737Z","avatar_url":"https://github.com/geektimus.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scala Challenges\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5120a93f50d44aebb6c291072ad363aa)](https://app.codacy.com/app/geektimus/scala-challenges?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=geektimus/scala-challenges\u0026utm_campaign=Badge_Grade_Dashboard)\n[![Build Status](https://travis-ci.org/geektimus/scala-challenges.svg?branch=master)](https://travis-ci.org/geektimus/scala-challenges)\n[![Maintainability](https://api.codeclimate.com/v1/badges/640e9a8ef7fc7f757aaf/maintainability)](https://codeclimate.com/github/geektimus/scala-challenges/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/640e9a8ef7fc7f757aaf/test_coverage)](https://codeclimate.com/github/geektimus/scala-challenges/test_coverage)\n\nOther Stats\n\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=geektimus_scala-challenges\u0026metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=geektimus_scala-challenges)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=geektimus_scala-challenges\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=geektimus_scala-challenges)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=geektimus_scala-challenges\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=geektimus_scala-challenges) |\n\nThis repo will contain the solutions using Scala for challenges found on:\n\n* Books\n* Hacker Rank\n* Codility\n* CodeFights\n\n## Challenges\n\n### Hacker Rank\n\n#### Super Reduced String\n\nWrite a function to reduce a given string to its shortest length by doing a series of\noperations in which we select a pair of adjacent lowercase letters that match,\nand then we delete them.\n\n#### Gemstone finder\n\nWe have a collections of rocks, and we represent its minerals in a string with letters from [a-z] and we need to write a function to find the gemstones in the collection of rocks. A gemstone is a mineral that occurs at least once in each of the rocks.\n\nExample:\n\n```text\nfor [\"abc\",\"abaaa\",\"bcd\"] b is a gemstone since it appears in the three rocks\nfor [\"ab\",\"cd\",\"ef\"] there's no gemstone\n```\n\n### Codility\n\n#### Missing Integer\n\nFind the smallest positive integer that is NOT in the given array:\n\nExample:\n\n```text\nfor [1, 3, 6, 4, 1, 2] the missing integer is [5]\nfor [4, 1, 5, 6, 2] the missing integer is [3]\n```\n\n#### Tape Equilibrium\n\nGiven a non-empty zero-indexed array A of N integers, returns the minimal difference\nthat can be achieved after we split the array on a pivot P. Such as\n```|(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])|```\n\n#### Frog Jumps\n\nWe need to find the minimum number of jumps a small frog can make from a starting position X to a ending position Y given a jump distance D\n\n### Qualified\n\n#### Number and Credit Card Mask\n\nWe need to write a function that will allow us to mask any given string. We have only two rules\n\n* The mask will only be applied to numbers or numbers separated with dashes (-)\n* The mask will not be applied to string containing characters or strings which length is less than 6\n* The mask will preserve the first and the last four numbers\n\nFor example:\n\n* 8888-9999-9999-0000 -\u003e 8###-####-####-0000\n* 1234567890987654321 -\u003e 1##############4321\n* Credit Card -\u003e Credit Card\n* 123 -\u003e 123\n\n#### Ordinal number representation\n\nWe need to write a function that given a non-negative number it returns the ordinal representation of that number.\n\nMost ordinal numbers end in \"th\" except for:\n\n* one ⇒ first (1st)\n* two ⇒ second (2nd)\n* three ⇒ third (3rd)\n\n#### Infix Calculator\n\nWe need to write a function that given an expression on infix notation will return the result of the operations.\n\nInfix notation is a notation when the numbers are provided first and the operation next.\n\nFor example:\n\n* 3 4 + = 3 + 4 = 7\n* 3 2 1 - \\* = (2 - 1) \\* 3 = 3\n* 9 sqrt = sqrt 9 = 3\n\n### Aperiodic (Scala Specific Challenges)\n\n1. P01 (*) Find the last element of a list.\n1. P02 (*) Find the last but one element of a list.\n1. P03 (*) Find the Kth element of a list.\n1. P04 (*) Find the number of elements of a list.\n1. P05 (*) Reverse a list.\n1. P06 (*) Find out whether a list is a palindrome.\n1. P07 (**) Flatten a nested list structure.\n1. P08 (**) Eliminate consecutive duplicates of list elements.\n1. P09 (**) Pack consecutive duplicates of list elements into sublists.\n1. P10 (*) Run-length encoding of a list.\n\n### Others (Challenges proposed by Friends or Solved on hackatons)\n\n#### Recursively reverse a string\n\nGiven a string, reverse the characters and return.\n\nExample:\n\n```text\nfor \"Test\" it should return \"tseT\"\nfor \"Return\" it should return \"nruteR\"\n```\n\n#### Classical Fizz Buzz solution\n\nWrite a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz\n\n#### Find number in Array\n\nThis is a basic problem where we need to find if a number is present on the\ngiven array.\n\n#### Basic word count problem but without using REGEX expressions\n\nWrite a function which returns the number of words in a given string - without using REGEX expressions\n\n```text\ngiven \"disco1 hero2\" or\n      \"  disco1  hero2\" or\n      \"disco1  hero2  \" or\n      \"  disco1  hero2  \"\nthen the word count should be 2, the solution should ignore the spaces.\n```\n\n#### Find the last index of a slice on a given array\n\nWrite a function which prints the index of the last occurrence of the entire sequence within a given array WITHOUT using inbuilt **sliding**, **lastIndexOf** and **lastIndexOfSlice** functions.\n\n## Useful commands\n\n### Enable scala style check on compile\n\nIf you want to enable the scala check as part of the compile task you can add the following lines to the _build.sbt_ file\n\n```bash\nlazy val compileScalastyle = taskKey[Unit](\"compileScalastyle\")\ncompileScalastyle := scalastyle.in(Compile).toTask(\"\").value\n(compile in Compile) := ((compile in Compile) dependsOn compileScalastyle).value\n```\n\nI don't add the line myself since this plugin get executed before the compile step, this can cause problems because if the code does not compile, you’ll get the scalastyle errors messages, not the scalac ones. Great though scalastyle is, it can’t match the error messages produced by the compiler\n\n### Run scala style check\n\n```bash\nsbt scalastyle\n```\n\n### Run Coverage Reports and Generate Report*\n\n```bash\nsbt clean coverage test coverageReport\n```\n\n[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-black.svg)](https://sonarcloud.io/summary/new_code?id=geektimus_scala-challenges)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektimus%2Fscala-challenges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeektimus%2Fscala-challenges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektimus%2Fscala-challenges/lists"}