Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 359e7a3

Browse files
Setting up repository, adding disclaimer about forks
0 parents  commit 359e7a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+32322
-0
lines changed

.gitignore

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Created by https://www.gitignore.io/api/scala,intellij,sbt
2+
3+
### Floobits
4+
*.floo*
5+
6+
### Scala ###
7+
*.class
8+
*.log
9+
10+
# sbt specific
11+
.cache
12+
.history
13+
.lib/
14+
dist/*
15+
target/
16+
lib_managed/
17+
src_managed/
18+
project/boot/
19+
project/plugins/project/
20+
21+
# Scala-IDE specific
22+
.scala_dependencies
23+
.worksheet
24+
25+
26+
### Intellij ###
27+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
28+
29+
*.iml
30+
31+
## Directory-based project format:
32+
.idea/
33+
# if you remove the above rule, at least ignore the following:
34+
35+
# User-specific stuff:
36+
# .idea/workspace.xml
37+
# .idea/tasks.xml
38+
# .idea/dictionaries
39+
40+
# Sensitive or high-churn files:
41+
# .idea/dataSources.ids
42+
# .idea/dataSources.xml
43+
# .idea/sqlDataSources.xml
44+
# .idea/dynamic.xml
45+
# .idea/uiDesigner.xml
46+
47+
# Gradle:
48+
# .idea/gradle.xml
49+
# .idea/libraries
50+
51+
# Mongo Explorer plugin:
52+
# .idea/mongoSettings.xml
53+
54+
## File-based project format:
55+
*.ipr
56+
*.iws
57+
58+
## Plugin-specific files:
59+
60+
# IntelliJ
61+
/out/
62+
63+
# mpeltonen/sbt-idea plugin
64+
.idea_modules/
65+
66+
# JIRA plugin
67+
atlassian-ide-plugin.xml
68+
69+
# Crashlytics plugin (for Android Studio and IntelliJ)
70+
com_crashlytics_export_strings.xml
71+
crashlytics.properties
72+
crashlytics-build.properties
73+
74+
75+
### SBT ###
76+
# Simple Build Tool
77+
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
78+
79+
target/
80+
lib_managed/
81+
src_managed/
82+
project/boot/
83+
.history
84+
.cache
85+
86+
#javascript section
87+
node_modules
88+
89+
### Python ###
90+
**.pyc

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 IntentHQ
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Intent HQ Code Challenges
2+
3+
Home of the katas we sometimes use for our interview candidates.
4+
5+
The challenges are available in:
6+
7+
* Java
8+
* Scala
9+
* Python
10+
* Javascript
11+
12+
See the `README.md` in the directory corresponding to each language for more
13+
information on running the challenges and their tests.

java_scala/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Intent HQ Java/Scala Code Challenges
2+
3+
If you are a candidate and are doing one (or more) of this small katas at home you may want to read this.
4+
5+
There are different katas in the package `com.intenthq.challenge`, each of them consists of a single file: `SKataName` (if scala) or `JKataName` (if java).
6+
7+
Each challenge comes with a set of tests written in specs2, you won't probably need to add any test, but in case you need to, you'll find documentation about the test framework in here: http://specs2.org/
8+
9+
## How to start
10+
11+
1. Read all the challenges and chose the one(s) you like best
12+
2. Download this folder or clone the repo **without creating a fork** and start working on it.
13+
3. Push your changes and send us the link to the github repo
14+
4. If you have any doubt while working on it just drop us an email and we'll help
15+
16+
17+
```
18+
To test your scala code:
19+
$ sbt testOnly -- include scala
20+
21+
To test your java code:
22+
$ sbt testOnly -- include java
23+
24+
To test a specific challenge:
25+
$ sbt testOnly -- include nice/graph -- exclude java/scala
26+
```

java_scala/build.sbt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
scalaVersion := "2.12.7"
2+
3+
libraryDependencies ++= Seq(
4+
"org.specs2" %% "specs2-core" % "4.3.5" % "test",
5+
"com.google.guava" % "guava" % "27.0-jre"
6+
)
7+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.6.1

java_scala/project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.intenthq.challenge;
2+
3+
import java.util.Collections;
4+
import java.util.List;
5+
6+
public class JConnectedGraph {
7+
// Find if two nodes in a directed graph are connected.
8+
// Based on http://www.codewars.com/kata/53897d3187c26d42ac00040d
9+
// For example:
10+
// a -+-> b -> c -> e
11+
// |
12+
// +-> d
13+
// run(a, a) == true
14+
// run(a, b) == true
15+
// run(a, c) == true
16+
// run(b, d) == false
17+
public static boolean run(JNode source, JNode target) {
18+
throw new RuntimeException("Not implemented");
19+
}
20+
21+
public static class JNode {
22+
public final int value;
23+
public final List<JNode> edges;
24+
public JNode(final int value, final List<JNode> edges) {
25+
this.value = value;
26+
this.edges = edges;
27+
}
28+
public JNode(final int value) {
29+
this.value = value;
30+
this.edges = Collections.emptyList();
31+
}
32+
}
33+
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.intenthq.challenge;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
public class JEnigma {
7+
8+
// We have a system to transfer information from one place to another. This system
9+
// involves transferring only list of digits greater than 0 (1-9). In order to decipher
10+
// the message encoded in the list you need to have a dictionary that will allow
11+
// you to do it following a set of rules:
12+
// > Sample incoming message: (​1,2,3,7,3,2,3,7,2,3,4,8,9,7,8)
13+
// > Sample dictionary (​23->‘N’,234->‘ ’,89->‘H’,78->‘Q’,37 ->‘A’)
14+
// - Iterating from left to right, we try to match sublists to entries of the map.
15+
// A sublist is a sequence of one or more contiguous entries in the original list,
16+
// eg. the sublist (1, 2) would match an entry with key 12, while the sublist (3, 2, 3)
17+
// would match an entry with key 323.
18+
// - Whenever a sublist matches an entry of the map, it’s replaced by the entry value.
19+
// When that happens, the sublist is consumed, meaning that its elements can’t be used
20+
// for another match. The elements of the mapping however, can be used as many times as needed.
21+
// - If there are two possible sublist matches, starting at the same point, the longest one
22+
// has priority, eg 234 would have priority over 23.
23+
// - If a digit does not belong to any matching sublist, it’s output as is.
24+
//
25+
// Following the above rules, the message would be: “1N73N7 HQ”
26+
// Check the tests for some other (simpler) examples.
27+
28+
private final Map<Integer, Character> map;
29+
30+
private JEnigma(final Map<Integer, Character> map) {
31+
this.map = map;
32+
}
33+
34+
public static JEnigma decipher(final Map<Integer, Character> map) {
35+
return new JEnigma(map);
36+
}
37+
38+
public String deciphe(List<Integer> message) {
39+
throw new RuntimeException("Not implemented");
40+
}
41+
42+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.intenthq.challenge;
2+
3+
import java.util.List;
4+
5+
public class JNiceStrings {
6+
// From http://adventofcode.com/day/5
7+
// --- Day 5: Doesn't He Have Intern-Elves For This? ---
8+
//
9+
// Santa needs help figuring out which strings in his text file are naughty or nice.
10+
//
11+
// A nice string is one with all of the following properties:
12+
//
13+
// It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou.
14+
// It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd).
15+
// It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements.
16+
// For example:
17+
//
18+
// ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double letter (...dd...), and none of the disallowed substrings.
19+
// aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap.
20+
// jchzalrnumimnmhp is naughty because it has no double letter.
21+
// haegwjzuvuyypxyu is naughty because it contains the string xy.
22+
// dvszwmarrgswjxmb is naughty because it contains only one vowel.
23+
// How many strings are nice?
24+
25+
public static int nice(List<String> xs) {
26+
throw new RuntimeException("Not implemented");
27+
}
28+
29+
}

0 commit comments

Comments
 (0)