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

Commit 919837a

Browse files
author
Holger Lösken
committed
🎉 First commit
0 parents  commit 919837a

File tree

12 files changed

+2475
-0
lines changed

12 files changed

+2475
-0
lines changed

.github/dependabot.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
3+
updates:
4+
5+
- package-ecosystem: "composer"
6+
commit-message:
7+
include: "scope"
8+
prefix: "composer"
9+
directory: "/src/php"
10+
labels:
11+
- "dependency"
12+
open-pull-requests-limit: 10
13+
schedule:
14+
interval: "daily"
15+
versioning-strategy: "increase"
16+
17+
- package-ecosystem: "github-actions"
18+
commit-message:
19+
include: "scope"
20+
prefix: "github-actions"
21+
# default location of `.github/workflows`
22+
directory: "/"
23+
labels:
24+
- "dependency"
25+
open-pull-requests-limit: 10
26+
schedule:
27+
interval: "daily"

.github/workflows/tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Tests
2+
on: [push]
3+
jobs:
4+
run:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
php: ['8.0']
9+
dependency-version: [prefer-stable]
10+
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
11+
steps:
12+
- name: Checkout code
13+
uses: actions/[email protected]
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: ${{ matrix.php }}
19+
20+
- name: Get Composer Cache Directory
21+
id: composer-cache
22+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
23+
24+
- name: Cache dependencies
25+
uses: actions/[email protected]
26+
with:
27+
path: ~/.composer/cache/files
28+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
29+
30+
- name: Install dependencies
31+
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
32+
working-directory: src/php
33+
34+
- name: Run tests
35+
run: composer test
36+
working-directory: src/php

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
A repository of coding challenges/tasks I came across in various job interviews.
2+
I mostly do backend programming in Go and PHP, so here you can find some solutions.
3+
4+
The solutions to the tasks do not fulfill to be the shortest, fastest or cleanest solutions.
5+
6+
## Tasks
7+
8+
Each task should come with a solution plus some tests to verify.
9+
10+
### Task 1
11+
12+
Create a function `maskify` to mask digits of a credit card number with `#`.
13+
14+
**Requirements:**
15+
* Do not mask the first digit and the last four digits
16+
* Do not mask non-digit chars
17+
* Do not mask if the input is less than 6
18+
* Return '' when input is empty
19+
20+
### Task 2
21+
22+
Create a function `number_to_ordinal` to create an ordinal number for a given input.
23+
Ordinal numbers in English have something like `st`, `nd`, `rd`, etc.
24+
25+
**Requirements:**
26+
* Apply for number 1 to 1001... if that works any given number will do ;-)
27+
28+
### Task 3
29+
30+
Create a calculator for [Reverse Polish Notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation).
31+
32+
**Requirements:**
33+
* Support the mathematical operations for `+`, `-`, `*` and `/`
34+
* Check for invalid syntax, like `2 3+`. There is a space missing.
35+
* Return 0 (integer) when nothing is entered
36+
* Return the numeric value when no operand is given
37+
38+
## Contribute
39+
40+
Feel free to contribute. Use the issue list to propose new tasks or open PRs. Just provide proper tests
41+
and description and requirements for the tasks.

src/php/composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "codedge/coding-challenges",
3+
"author": "Holger Lösken <[email protected]>",
4+
"require": {
5+
"php": "^8.0",
6+
"phpunit/phpunit": "^9.5"
7+
},
8+
"autoload-dev": {
9+
"files": [
10+
"t1/s1.php",
11+
"t2/s1.php",
12+
"t3/s1.php"
13+
],
14+
"psr-4": {
15+
"Tests\\": "tests/"
16+
}
17+
},
18+
"scripts": {
19+
"test": [
20+
"./vendor/bin/phpunit"
21+
]
22+
}
23+
}

0 commit comments

Comments
 (0)