Skip to content

Commit 1f121c3

Browse files
authored
Merge branch 'main' into tests--update-reverse-string-exercise
2 parents d29706d + 8ef5867 commit 1f121c3

609 files changed

Lines changed: 42474 additions & 5719 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ on:
1111
jobs:
1212
linux-min:
1313
name: Linux Min Config
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
strategy:
1616
matrix:
17-
compiler: [clang++-6.0, g++-10]
17+
compiler: [clang++-15, g++-12]
1818
steps:
19-
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2020
- name: Install Dependencies
2121
# Boost must be installed only because the CMake version (3.12) can't
2222
# detect the installed Boost version (1.69)
23-
run: sudo apt-get update && sudo apt-get -y install ninja-build libboost-date-time-dev clang-6.0 g++-10 g++-multilib
23+
run: sudo apt-get update && sudo apt-get -y install ninja-build libboost-date-time-dev g++-multilib
2424
- name: Run tests with common Catch
2525
run: |
2626
cmake -G Ninja .
@@ -32,12 +32,12 @@ jobs:
3232
linux-latest:
3333
name: Linux Latest Config
3434
needs: [linux-min]
35-
runs-on: ubuntu-22.04
35+
runs-on: ubuntu-24.04
3636
strategy:
3737
matrix:
3838
compiler: [clang++, g++]
3939
steps:
40-
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
40+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4141
- name: Install Dependencies
4242
# Boost must be installed only because the CMake version (3.12) can't
4343
# detect the installed Boost version (1.69)
@@ -64,7 +64,7 @@ jobs:
6464
needs: [linux-min]
6565
runs-on: windows-2022
6666
steps:
67-
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
67+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
6868
- name: Run Tests
6969
shell: powershell
7070
# Delete the exercises that require Boost to avoid issues with Windows setup.
@@ -80,7 +80,7 @@ jobs:
8080
needs: [linux-min]
8181
runs-on: macOS-latest
8282
steps:
83-
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
83+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
8484
- name: Install Boost
8585
run: brew install boost
8686
- name: Run Tests

.github/workflows/hello-world.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Hello World Fails
2222
runs-on: ubuntu-22.04
2323
steps:
24-
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2525
- name: Check Hello World Fails
2626
run: bin/check-hello-world.sh
2727
env:

.github/workflows/pre-commit.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Pre-commit checks
2+
3+
on:
4+
# Run workflow for PRs.
5+
pull_request:
6+
7+
# Whenever we have a new commit on main, run the workflow for that.
8+
push:
9+
branches: [main]
10+
11+
jobs:
12+
pre-commit:
13+
name: Pre-commit checks
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
ref: ${{github.event.pull_request.head.sha}}
20+
repository: ${{github.event.pull_request.head.repo.full_name}}
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
- name: Run pre-commit checks on PR
26+
uses: pre-commit/action@v3.0.1

.github/workflows/verify-code-formatting.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
exclude: 'test/(catch.hpp|tests-main.cpp)'
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/mirrors-clang-format
5+
rev: v18.1.2
6+
hooks:
7+
- id: clang-format
8+
exclude_types: [json]
9+

CMakeLists.txt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
cmake_minimum_required(VERSION 3.5.1)
22
project(exercism CXX)
33

4-
set(alt_exercise_tree ${CMAKE_CURRENT_SOURCE_DIR}/build_exercises/practice)
5-
6-
function(build_fixup exercise_dir alt_exercise_root)
4+
function(build_fixup exercise_dir alt_exercise_root exercise_type example_name)
75
string(REPLACE "-" "_" file ${exercise_dir})
8-
set(source ${CMAKE_CURRENT_SOURCE_DIR}/exercises/practice/${exercise_dir})
6+
set(source ${CMAKE_CURRENT_SOURCE_DIR}/exercises/${exercise_type}/${exercise_dir})
97
if(EXISTS ${source})
108
set(alt_exercise_dir ${alt_exercise_root}/${exercise_dir})
119
file(COPY ${source} DESTINATION ${alt_exercise_root})
12-
if(EXISTS ${alt_exercise_dir}/.meta/example.h)
13-
file(RENAME ${alt_exercise_dir}/.meta/example.h ${alt_exercise_dir}/${file}.h)
10+
if(EXISTS ${alt_exercise_dir}/.meta/${example_name}.h)
11+
file(RENAME ${alt_exercise_dir}/.meta/${example_name}.h ${alt_exercise_dir}/${file}.h)
1412
endif()
15-
if(EXISTS ${alt_exercise_dir}/.meta/example.cpp)
16-
file(RENAME ${alt_exercise_dir}/.meta/example.cpp ${alt_exercise_dir}/${file}.cpp)
13+
if(EXISTS ${alt_exercise_dir}/.meta/${example_name}.cpp)
14+
file(RENAME ${alt_exercise_dir}/.meta/${example_name}.cpp ${alt_exercise_dir}/${file}.cpp)
1715
endif()
1816
endif()
1917
endfunction()
2018

19+
function(add_exercises exercise_type example_name)
20+
file(GLOB exercise_list ${CMAKE_CURRENT_SOURCE_DIR}/exercises/${exercise_type}/*)
21+
set(alt_exercise_tree ${CMAKE_CURRENT_SOURCE_DIR}/build_exercises/${exercise_type})
22+
foreach(exercise_dir ${exercise_list})
23+
get_filename_component(exercise ${exercise_dir} NAME)
24+
build_fixup(${exercise} ${alt_exercise_tree} ${exercise_type} ${example_name})
25+
add_subdirectory(${alt_exercise_tree}/${exercise})
26+
endforeach()
27+
endfunction()
28+
2129
option(EXERCISM_RUN_ALL_TESTS "Run all Exercism tests" On)
2230
option(EXERCISM_COMMON_CATCH "Link against a common Catch2 main lib." On)
2331

@@ -30,10 +38,5 @@ if(EXERCISM_COMMON_CATCH)
3038
)
3139
endif()
3240

33-
file(GLOB exercise_list ${CMAKE_CURRENT_SOURCE_DIR}/exercises/practice/*)
34-
35-
foreach(exercise_dir ${exercise_list})
36-
get_filename_component(exercise ${exercise_dir} NAME)
37-
build_fixup(${exercise} ${alt_exercise_tree})
38-
add_subdirectory(${alt_exercise_tree}/${exercise})
39-
endforeach()
41+
add_exercises("concept" "exemplar")
42+
add_exercises("practice" "example")

bin/check-formatting.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

bin/make-stub-files.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ for exercise_dir in "${exercises_dir}"/*; do
2121
header="$exercise_name.h"
2222
source="$exercise_name.cpp"
2323
if ! test -f "$header"; then
24-
printf "#if !defined(${exercise_name^^}_H)\n" >> $header
25-
printf "#define ${exercise_name^^}_H\n" >> $header
24+
printf "#pragma once\n" >> $header
2625
printf "\nnamespace $exercise_name {\n\n} // namespace $exercise_name\n" >> $header
27-
printf "\n#endif // ${exercise_name^^}_H" >> $header
2826
git add $header
2927
fi
3028
if ! test -f "$source"; then

concepts/literals/introduction.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ auto net_worth_carlisle_cullen{46'000'000'000LL}; // int and uint are not enough
3333
Floating-point numbers usually resolve to `double` during compilation.
3434
This is a good default case and use-cases with the narrower `float` type are less frequent than the unsigned example above.
3535
36+
~~~~exercism/advanced
37+
The [C++23 standard][cpp23-literals] introduces more fine grained control with literals like `f128` or `F16`.
38+
Some compilers allow their own literals.
39+
GCC permits the usage of `d` as a literal, but this is not foreseen in the standard and can hinder cross-platform compatibility.
40+
41+
[cpp23-literals]: https://en.cppreference.com/w/cpp/language/floating_literal
42+
43+
~~~~
44+
3645
```cpp
3746
auto light_year_in_m{9.46073e+15f}; // well in the range of float
3847
auto earth_to_edge_comoving_distance_in_nm{4.32355e+32}; // needs double type for magnitude

concepts/numbers/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Consider also that we are only assigning the value of `width` to `length` at the
6060
Therefore, if the value of `width` changes at a later moment, it will not affect the value taken by `length`.
6161

6262
Assignment operator can be combined with the other operators(arithmetic & bitwise) known as `compound assignment` operators `+=`, `-=`, `*=`, `/=`, `%=`.
63-
These operators modifies the current value of a variable by performing an operation on it.
63+
These operators modify the current value of a variable by performing an operation on it.
6464

6565
```cpp
6666
// we start with 0 people

0 commit comments

Comments
 (0)