forked from Shopify/eng-internship-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 78e3943
Showing
28 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'go/**' | ||
|
||
jobs: | ||
go-tests: | ||
name: Run Go Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- id: changes | ||
uses: jitterbit/get-changed-files@v1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.21.5' # Specify your Go version here | ||
|
||
- name: Set Environment Variable | ||
run: echo "TEST_ANSWER=${{ secrets.TEST_ANSWER }}" >> $GITHUB_ENV | ||
|
||
- name: Run Go Tests | ||
run: cd go && go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'javascript/**' | ||
|
||
jobs: | ||
javascript-tests: | ||
name: Run JavaScript Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- id: changes | ||
uses: jitterbit/get-changed-files@v1 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
- name: Set Environment Variable | ||
run: echo "TEST_ANSWER=${{ secrets.TEST_ANSWER }}" >> $GITHUB_ENV | ||
- run: cd javascript && npm install | ||
- run: cd javascript && npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'python/**' | ||
|
||
jobs: | ||
python-tests: | ||
name: Run Python Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- id: changes | ||
uses: jitterbit/get-changed-files@v1 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' # Specify the Python version here | ||
|
||
- name: Set Environment Variable | ||
run: echo "TEST_ANSWER=${{ secrets.TEST_ANSWER }}" >> $GITHUB_ENV | ||
|
||
- name: Run Python Tests | ||
run: | | ||
cd python | ||
python3 solution.test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'ruby/**' | ||
|
||
jobs: | ||
ruby-tests: | ||
name: Run Ruby Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.0' | ||
bundler-cache: true | ||
|
||
- name: Set Environment Variable | ||
run: echo "TEST_ANSWER=${{ secrets.TEST_ANSWER }}" >> $GITHUB_ENV | ||
|
||
- run: cd ruby && bundle install | ||
- run: cd ruby && rspec solution.test.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'typescript/**' | ||
|
||
jobs: | ||
typescript-tests: | ||
name: Run TypeScript Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- id: changes | ||
uses: jitterbit/get-changed-files@v1 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Set Environment Variable | ||
run: echo "TEST_ANSWER=${{ secrets.TEST_ANSWER }}" >> $GITHUB_ENV | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd typescript | ||
npm install | ||
- name: Run TypeScript Tests | ||
run: | | ||
cd typescript | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
package-lock.json | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Thematics" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Engineering Internship | ||
## Technical Assessment Challenge | ||
|
||
### Playfair Cipher Solver | ||
|
||
#### Challenge | ||
Your goal is to build an application that can solve a Playfair Cipher. To learn more about Playfair Ciphers and how they are constructed, consult the following Wikipedia page on the subject: [https://en.wikipedia.org/wiki/Playfair_cipher](https://en.wikipedia.org/wiki/Playfair_cipher). | ||
|
||
Ideally this challenge should be able to be completed in 3 hours or less. You may choose one of the 5 following programming languages to complete this challenge: | ||
- Ruby | ||
- JavaScript | ||
- TypeScript | ||
- Python | ||
- Go | ||
|
||
Ensure your code is properly commented and formatted for readability and ease-of-understanding. | ||
|
||
#### Thematics | ||
*"Attention spy network! You've been assigned a task of the utmost importance! We've received an encrypted message from an agent in the field containing the password to a top secret club for super spies. The encrypted message reads as follows: **"IKEWENENXLNQLPZSLERUMRHEERYBOFNEINCHCV"**. We've been told if we can crack this code and give the password to the door-person at the corner of 32nd Street, we will gain access to the illustrious spy club **Spy City**! We must get inside! However the password has been encrypted with an older system known as a **Playfair Cipher**. Our agent in the field says the key to the cipher is the string **"SUPERSPIES"**. However, for the life of us we cannot crack this code! Devise an application that can solve this encryption, get the password, and join us inside Spy City for what we are sure will be a night to remember!"* | ||
|
||
#### Instructions | ||
1. Fork this repo to your personal Github account. | ||
2. Clone your forked repo to begin working on the challenge locally. | ||
3. Create a new Branch in your repo where you will be pushing your code to. | ||
4. Choose which programming language you wish to complete the challenge with. | ||
- Navigate to the folder of that programming language and complete your work in the `solution` file found inside. ie: `ruby/solution.rb` | ||
- **Do not** edit the test file in the folder. Tests will only work as intended after you have submitted a PR. | ||
- You'll find a separate `README.md` in that folder with language specific instructions. | ||
5. Ensure your application is executable from the command-line by running your `solution` file. | ||
6. Your decrypted string must by entirely **UPPER CASE**, and not include `spaces`, the letter `"X"`, or `special characters`. Ensure you meet all these conditions before outputting the result. | ||
7. Your application must output ***only*** the decrypted Playfair Cipher string. | ||
- ie: `BANANAS` ***not*** `The decrypted text is: BANANAS` | ||
|
||
#### Submission | ||
Upon completion of the challenge, create a PR of your work and compare it against the original Assessment Repo's `main` branch. Submit a link to your PR with your internship application in the appropriate field. | ||
|
||
This repo is designed to run a test against your work to ensure the correct decrypted string is outputted to the console when executing your code. Admins on this repo will deploy the test manually only after you have submitted your PR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Go Instructions | ||
|
||
- Ensure your code can run in the command-line with the command `go run solution.go` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module solution | ||
|
||
go 1.21.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestSolutionOutput(t *testing.T) { | ||
cmd := exec.Command("go", "run", "solution.go") | ||
outputBytes, err := cmd.CombinedOutput() | ||
if err != nil { | ||
t.Fatalf("Failed to run the command: %v", err) | ||
} | ||
|
||
// Trim space from output and expected value | ||
output := strings.TrimSpace(string(outputBytes)) | ||
expected := strings.TrimSpace(os.Getenv("TEST_ANSWER")) | ||
|
||
if output != expected { | ||
t.Errorf("Unexpected output, got: %q, want: %q", output, expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# JavaScript Instructions | ||
|
||
- Install all dependencies with the command `npm install` | ||
- Ensure your code can run in the command-line with the command `node solution.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "javascript", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "solution.js", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"jest": "^29.7.0" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { exec } = require("child_process"); | ||
|
||
describe('solution.js script', () => { | ||
it('should output correct answer to the console', (done) => { | ||
exec("node solution.js", (error, stdout, stderr) => { | ||
expect(error).toBeNull(); | ||
expect(stderr).toBe(""); | ||
expect(stdout.trim()).toBe(process.env.TEST_ANSWER); // trim to remove any extra newlines that console.log might generate | ||
done(); // indicate that this async test is complete | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Python Instructions | ||
|
||
- Ensure your code can run in the command-line with the command `python3 solution.py` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
import subprocess | ||
import os | ||
|
||
class TestSolution(unittest.TestCase): | ||
def test_decryption_output(self): | ||
# Run the solution.py script | ||
result = subprocess.run(['python3', 'solution.py'], text=True, capture_output=True) | ||
|
||
# Check the output | ||
expected_output = os.getenv('TEST_ANSWER') | ||
self.assertEqual(result.stdout.strip(), expected_output) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "rspec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ruby Instructions | ||
|
||
- Ensure your code can run in the command-line with the command `ruby solution.rb` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe 'Playfair Decryption Script' do | ||
it 'outputs the correct decrypted text' do | ||
output = `ruby solution.rb` # Using backticks to execute the script and capture the output. | ||
expect(output.strip).to eq(ENV['TEST_ANSWER']) # Compares the stripped output to the expected string. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# TypeScript Instructions | ||
|
||
- Install all dependencies with the command `npm install` | ||
- Ensure your code can run in the command-line with the command `ts-node solution.ts` or `npx ts-node solution.ts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "typescript", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "solution.js", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.7", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
|
||
const execAsync = promisify(exec); | ||
|
||
describe('solution.ts output', () => { | ||
it('should print the correct output to the console', async () => { | ||
const { stdout } = await execAsync('ts-node solution.ts'); | ||
|
||
const expected = process.env.TEST_ANSWER; | ||
expect(stdout.trim()).toBe(expected); | ||
}); | ||
}); |
Empty file.