Skip to content

Commit 676deae

Browse files
committed
adding coding exercise
0 parents  commit 676deae

File tree

6 files changed

+196
-0
lines changed

6 files changed

+196
-0
lines changed

README.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Turnitin Java Coding Exercise 2
2+
3+
Welcome! We're excited you've decided to talk with us about a position on our
4+
engineering team.
5+
6+
The purpose of this exercise is so we can have a conversation about your
7+
technical background and abilities. We think that asking you to code on a
8+
whiteboard during an interview isn't a great way to have a conversation. And
9+
even if we sit down and pair during an interview it's a higher pressure
10+
situation than it could be.
11+
12+
Instead we ask that you read these instructions and do _at most_ a few hours of
13+
work, on your time, to complete the exercise. During the interview we'll talk
14+
about decisions you've made, the resulting application, and how you might
15+
change it given different circumstances.
16+
17+
Below are two sections:
18+
19+
- _Instructions_: the problems we'd like you to solve along with expectations we
20+
have about your solution.
21+
- _Logistics_: constraints around the problem, and how we'd like you to
22+
communicate your solution to us
23+
24+
# Instructions
25+
26+
Please solve the following two problems as described below using Java 11 preferably
27+
(or older versions if necessary). Feel free to create classes,
28+
structures, interfaces, or any other construct needed to solve this.
29+
30+
## Sample Data
31+
32+
PHRASES = {
33+
{ "1", ["afterward", "whenever", "however", "until", "as soon as", "as long as", "while", "again", "also", "besides"]},
34+
{ "2", ["therefore", "thus", "consequently", "as a result", "for this reason", "so", "so that", "accordingly", "because"]},
35+
{ "3", ["in addition to", "so", "moreover"]},
36+
{ "4", ["in general", "for the most part", "as a general rule", "on the whole", "usually", "typically", "in summary"]}
37+
}
38+
39+
INPUT_TEXT = "Afterwards, soon yellow bird landed on the tall tree in addition to a lazy tortoise. However, he had a " +
40+
"read beak. In addition to white the patches on the wings, he was completely yellow. In summary, it was yellow bird. " +
41+
"In summary, it did not sing."
42+
43+
44+
## Problem 1
45+
Get the frequencies of each phrase from PHRASES above, ie how many times the phrase appears in the text as described in INPUT_TEXT.
46+
Of course, it should be able to work with any text.
47+
48+
For example, If you were given the following:
49+
50+
PHRASES = {{ "1", ["until, "so", "usually"]}}
51+
INPUT_TEXT = "So, I have not seen this. So, usually, I don't follow all trends."
52+
53+
It will create the following output:
54+
55+
frequencies: "until":0, "so": 2, "usually":1
56+
57+
## Problem 2
58+
Based on the phrases in PHRASES, create a unique vocabulary of phrases, and generate a vector that
59+
represents the frequency of each phrase for the given text.
60+
61+
62+
For example, if we have the following:
63+
64+
PHRASES = {{"1", ["until, "so", "usually", "so"]}}
65+
INPUT_TEXT = "So, I have not seen this. So, usually, I don't follow all trends."
66+
67+
It will have the following output:
68+
69+
vocabulary = ["so", "until", "usually"]
70+
vector = [2, 0, 1]
71+
72+
# Logistics
73+
74+
##1. Timeframe
75+
76+
You should take a max of three hours to complete this exercise. We want to be
77+
both respectful of your time and fair to other candidates who might not have
78+
a whole weekend to work on it.
79+
80+
##2. Git
81+
82+
You will need to use git for this exercise. To get these instructions and a
83+
repo with test scripts do the following:
84+
85+
1. [Create a Github account](https://github.com/join) if you don't already have
86+
one. For the examples below we assume a user `pusheen`.
87+
2. Clone our repository:
88+
89+
```
90+
# Using ssh
91+
$ git clone [email protected]:turnitin/java-coding-exercise-2.git
92+
93+
# Using https
94+
$ git clone https://[email protected]/turnitin/java-coding-exercise-2.git
95+
```
96+
97+
##3. Remote
98+
99+
Once you are done you can put your solution in your own repository by adding it
100+
as a remote and pushing to it.
101+
102+
1. Create a new repo via the github UI, let's assume you call it
103+
`java-coding-exercise-2` to mirror ours.
104+
2. If possible use a private repo. If you've run out of private repos on github
105+
them no worries, we'd just like to make sure that every candidate's work is
106+
his or her own.
107+
3. Add your repo as a remote and push:
108+
109+
```
110+
$ git remote add myrepo [email protected]:pusheen/java-coding-exercise-2.git
111+
$ git push myrepo master
112+
```
113+
114+
##4. Access
115+
116+
Provide following users read access to your repository
117+
118+
- skumar-tii
119+
- <>
120+
121+
##5. Notify us
122+
123+
At least a day before your in-person interview, email `[email protected]`
124+
your repo address.

exercise.iml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="CheckStyle-IDEA-Module">
4+
<option name="configuration">
5+
<map />
6+
</option>
7+
</component>
8+
<component name="NewModuleRootManager" inherit-compiler-output="true">
9+
<exclude-output />
10+
<content url="file://$MODULE_DIR$">
11+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
12+
</content>
13+
<orderEntry type="inheritedJdk" />
14+
<orderEntry type="sourceFolder" forTests="false" />
15+
<orderEntry type="library" name="R User Library" level="project" />
16+
<orderEntry type="library" name="R Skeletons" level="application" />
17+
</component>
18+
</module>
Binary file not shown.

src/.DS_Store

6 KB
Binary file not shown.

src/com/.DS_Store

6 KB
Binary file not shown.

src/com/turnitin/sample/Exercise.java

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.turnitin.sample;
2+
3+
import java.util.Arrays;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
public class Exercise {
9+
10+
public static Map<String, List<String>> PHRASES = new HashMap<>();
11+
12+
static {
13+
PHRASES.put("1", Arrays.asList("afterward", "whenever", "however", "until", "as soon as", "as long as", "while", "again", "also", "besides"));
14+
PHRASES.put("2", Arrays.asList("therefore", "thus", "consequently", "as a result", "for this reason", "so", "so that", "accordingly", "because"));
15+
PHRASES.put("3", Arrays.asList("in addition to", "so", "moreover"));
16+
PHRASES.put("4", Arrays.asList("in general", "for the most part", "as a general rule", "on the whole", "usually", "typically", "in summary"));
17+
}
18+
19+
public static String INPUT_TEXT = "Afterwards, soon yellow bird landed on the tall tree in addition to a lazy tortoise. " +
20+
"However, he had a read beak. In addition to white the patches on the wings, he was completely yellow. " +
21+
"In summary, it was yellow bird. In summary, it did not sing.";
22+
23+
/*
24+
Description: Please code the two problems as described below using Java 11 preferably ( or older versions if necessary). Feel free to create classes,
25+
structures, interfaces, or any other construct needed to solve this. Note: the keys (1,2,3,4) in PHRASES have no particular significance to this.
26+
*/
27+
public static void main(String[] args) {
28+
/*
29+
Problem 1) Get the frequencies of each phrase from PHRASES above, ie how many times the phrase appears in the text as described in inputText,
30+
but it should be able to work with any text.
31+
32+
For example, if you have the following:
33+
phrases = [ "1", ["until, "so", "usually"]]
34+
text = "So, I have not seen this. So, usually, I don't follow all trends."
35+
36+
It will create the following output:
37+
frequencies: "until":0, "so": 2, "usually":1
38+
*/
39+
40+
41+
/*
42+
Problem 2) Based on the phrases in PHRASES, create a unique list of phrases (vocabulary) , then generate a vector/list that
43+
represents the frequency of each phrase for the given text.
44+
45+
For example, if we have the following:
46+
phrases = ["1", ["until, "so", "usually", "so"]]
47+
text = "So, I have not seen this. So, usually, I don't follow all trends."
48+
49+
It will have the following output:
50+
vocabulary = ["so", "until", "usually"]
51+
vector = [2, 0, 1]
52+
*/
53+
}
54+
}

0 commit comments

Comments
 (0)