Link Search Menu Expand Document

Take-Home Examples

You’ll find examples of challenges that you can build within CoderPad’s Take-Homes feature. These should serve as inspiration for your company and we don’t recommend using these in your actual Take-Homes.

  1. API/HTTP Call
  2. React Components
  3. Liars Dice

API/HTTP Call

BackendWith Test Cases

Although this challenge can be used for all levels, this question is especially great for junior to mid level engineers. The goal of this challenge is to see if the candidate can perform tasks that an engineer would do in their everyday workflow.

While the example makes use of https://www.premierleague.com data - we suggest tailoring this question to your business logic.

For example - as a food delivery company, you’d provide an API/HTTP that works with restaurant menu data/site. If you are a video streaming platform, you’d provide an API/HTTP that handles movie and tv-show data/site.

This provides a great candidate experience, and also gives the candidate a sense of what they would be working on in a day-to-day role at your company. It also lets you see how the candidate works in a real-world environment.

It’s good to leave some parts of the question to the candidate’s discretion. This allows you to see how they handle ambiguities. E.g. are they taking into account other URLs being entered, is the URL valid etc.

We recommend keeping this challenge to a time-limit of 30 minutes to 2 hours.

Candidate Instructions:

### Hey Candidate - Welcome to the API Take-Home Challenge

Your task is to create a function that makes an API call to request an HTML page, and parse through the HTML to retrieve a soccer team's logo

This function should work for every single team page from https://www.premierleague.com link. In the case the URL is not valid - you should return an error message.

#### An example:
Request: "https://www.premierleague.com/clubs/10/Liverpool/overview"
Response: "https://resources.premierleague.com/premierleague/badges/t14.png"

You can use C++, Java, Javascript, Python or Ruby. Some of these languages have request libraries. Others you will have to use the language's default HTTP methods. To see the available packages/libraries for the language you choose, simply click on the info button located next to the language.

We have included test cases that will allow you to see if your code will pass or fail. The string must match exactly to pass. In the case of no image in the page, please return the message "No image found!". To view the test cases, you can view the test case tab, or when you run the code, you will see each test in the console and whether it failed or passed. You can log your output in the console at any time as well.

Good luck!

Starter Code:

def solution(url):
    # Please write your code here.
    return "example"

Test Cases:

Arguments Expected Result - Return Value
https://www.premierleague.com/clubs/10/Liverpool/overview https://resources.premierleague.com/premierleague/badges/t14.png
https://www.premierleague.com/clubs/12 https://resources.premierleague.com/premierleague/badges/t1.png
https://premierleague.com No Image Found!

React Components

FrontendWithout Test Cases

The below example shows a frontend setup that can be used inside of CoderPad’s HTML/CSS/JS pads. To use this for Take-Home Challenges, you have to build this out using our “Create a Challenge WITHOUT test cases” option.

The benefit of being able to run your frontend challenges through CoderPad is that you can make use of your own design systems. The below example makes use of the Bootstrap React package.

The challenge has a time-limit of 2 hours. It is straightforward if you know React. It is short and precise. If the candidate has a good handle of React, they should be able to complete the challenge quickly and give you a good indication if they should move ahead in the interview process.

Candidate Instructions:

Welcome Candidate and thank you for taking the time to complete the COMPANY NAME take-home challenge for our frontend position. 

You will have 2 hours to complete this assignment. Once you have completed your solution, you can use the "Submit Challenge" button located in the bottom right hand corner. If you cannot come to a solution within the 2 hours, the code you have at 2 hours will be auto-submitted.

The goal of this challenge is to build out a UI and layout found in this image: URL-GOES-HERE

The UI is made up of a main header title and a list of posts that are formatted utilizing Bootstrap's Card component. You will need to make an API call to retrieve the posts. To get the posts, use this URL: https://jsonplaceholder.typicode.com/posts.

Here are the strict rules of this challenge...you must:
1) Use the way you see fit to make the API call
2) Only retrieve the first 10 posts that the API gives you.
2) Utilize ReactBootstrap package to create the layout (an example of bringing in the `<Container/>` component from the library is below)
3) Create components as you feel is best suited for your solution

The rest is up to you! Feel free to be creative once you have an initial solution. "Wow us!"

Resources:
1) API: https://jsonplaceholder.typicode.com/posts
2) React Bootstrap Docs: https://react-bootstrap.github.io/components/alerts/
3) React Docs: https://reactjs.org/docs/getting-started.html

Good luck and if you have questions, please reach out to us recruiting@companyname.com

Starter Code:

<html>
  <head>
    <meta charset="UTF-8" />
    <title>COMPANY NAME -- Frontend Challenge</title>
    <script src="https://unpkg.com/react/umd/react.production.min.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom/umd/react-dom.production.min.js" crossorigin></script>
    <script src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js" crossorigin></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous" />
  </head>
  <body>
    <div id="root"></div>
        
    <script type="text/jsx">
      var Container = ReactBootstrap.Container,
           Row = ReactBootstrap.Row;

      class Main extends React.Component {
        state = {
          count: 0
        }
        
        render() {
         return (
          <Container>
            <Row>
          
              // ----- YOUR CODE HERE -------
              // Please create your components below
            
            </Row>
          </Container>
         ) 
        }
      }
      
      // ----- YOUR CODE HERE ------
      // Please create your components here
    
      
      // Render component to the page
      ReactDOM.render(<Main />, document.getElementById('root'));
    </script>
  </body>
</html>

Liars Dice

BackendWithout Test Cases

The below example revolves around creating the game Liar’s Dice. This question can be used as inspiration for building other “utilities”. E.g. build a chatbot class, build out an invoice system etc.

This question makes use of both the IDE and the actual console itself. In this case, the candidate’s solution is using Ruby and it utilizes methods within the Game class. It can be instantiated in the console using Game.new(number_of_players).

The starter code is limited, but the challenge details should be enough guidance for the candidate to get started. The great thing about this question is not only are you testing for the mechanical skills, you can also get a good sense of a candidates algorithmic thinking.

Candidate Instructions:

Welcome to your Take-Home Interview!

For this interview, your task will be to build out the game Liar's Dice. The game is a class of dice games for two or more players requiring the ability to deceive and detect an opponents deception.

Each player begins with 5 dice that are hidden from the other players. Each player will roll their dice and hide the results. Player 1 puts X (between 0 and 5 of their own) number of dice in the middle, and declares how many dice of a certain number are in play.

For example: Player 1 puts 2 3's into the middle of the table, and says "I believe there are at least 7 3's in play". This means player 1 thinks there is at least 7 3's across everyone's hand (including the 2 that they put into the middle).

After a player places the dice in the middle and makes a bid, the player must reroll the remaining dice in their hand.

Now the next player, let's call them Player 2 - must either challenge Player 1's claim or make a new claim that is at least one die higher. For example, "I believe there are like 9 3's in play". 

The goal is this exercise is to write a class that represents a game of Liar's Dice of X number of players (at least 2). The game itself does not have to work complete, but it must implement three public facing methods that are accessible.


These methods are:
1) move - you should be able to tell the game that player A put B dice showing the number C in the middle
2) claim - you should be able to ask the game the probability that a claim of A number of B's is correct at any point
3) challenge - you should be able to challenge a claim and the game should tell you if you are correct

An example use of this class:

1. Instantiate the game: `game = Game.new(players: 4)`
2. Make player 1 move: `game.move(player: 1, dice: 3, value: 5)`
3. Make player 2 move: `game.move(player: 2, dice: 1, value: 5)`
4. Check claim: `game.claim(dice: 20, value: 5)` ---> low percentage
5. Challenge: `game.challenge(dice: 20, value: 5)` ----> false

The formula to determine the probability of k dice of the same value given n total dice:
n! / k! (n - k)! * (1/6)^k * (5/6)^(n-k)
https://www.thoughtco.com/probabilities-and-liars-dice-4038637

This formula above only tells us the probability when you know the exact number of dice, not "at least this number". You have to sum all the possibilities together for that.

Example: There are 17 dice left, and we want to calculate the odds of at least 16. Thus we calculate the probability of getting exactly 16 and add that to the probability that all 17 are the same.
17! / 16!(1!) * (1/6)^16 * (5/6)^1 = 0.0000000000051
17! / 17!(0!) * (1/6)^17 * (5/6)^0 = 0.000000000000059

So...

(0.0000000000051 + 0.000000000000059) * 100 = 0.000000000516% or pretty much never.

Here is one final example execution to give you a better idea:

game = Game.new(players: 4)
game.move(player: 3, dice: 2, value: 3)
game.move(player: 4, dice: 4, value: 3)
game.move(player: 1, dice: 5, value: 3)
game.move(player: 2, dice: 5, value: 3)
game.move(player: 3, dice: 3, value: 3)

There are 19 3's on the board.
game.claim(dice: 20, value: 3)

Since there is only 1 die left n = 1, k = 1, thus:
1! / 1!0! * 1/6^1 * (5/6)^0 = 16.67%