├── .appends └── .github │ └── labels.yml ├── .gitattributes ├── .github ├── CODEOWNERS ├── labels.yml └── workflows │ ├── configlet.yml │ ├── no-important-files-changed.yml │ ├── pause-community-contributions.yml │ ├── sync-labels.yml │ ├── test-windows.yml │ └── test.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── bin ├── exercise_test.ps1 ├── exercise_test.sh ├── fetch-cobolcheck ├── fetch-cobolcheck.ps1 ├── fetch-configlet ├── fetch-configlet.ps1 ├── setup-environment.ps1 ├── sync-exercise-files ├── test └── test.ps1 ├── concepts └── .keep ├── config.json ├── docs ├── ABOUT.md ├── INSTALLATION.md ├── LEARNING.md ├── RESOURCES.md ├── SNIPPET.txt ├── TESTS.md └── config.json └── exercises ├── .keep ├── concept └── .keep ├── practice ├── .keep ├── acronym │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── acronym.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── acronym │ │ └── acronym.cut ├── all-your-base │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── all-your-base.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── all-your-base │ │ └── all-your-base.cut ├── allergies │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ ├── proof.ci.cob │ │ └── tests.toml │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── allergies.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── allergies │ │ └── allergies.cut ├── anagram │ ├── .docs │ │ ├── instructions.append.md │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ ├── proof.ci.cob │ │ └── tests.toml │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── anagram.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── anagram │ │ └── anagram.cut ├── armstrong-numbers │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── armstrong-numbers.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── armstrong-numbers │ │ └── armstrong-numbers.cut ├── atbash-cipher │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── atbash-cipher.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── atbash-cipher │ │ └── atbash-cipher.cut ├── binary-search │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── binary-search.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── binary-search │ │ └── binary-search.cut ├── binary │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── binary.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── binary │ │ └── binary.cut ├── bob │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── bob.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── bob │ │ └── bob.cut ├── circular-buffer │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── circular-buffer.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── circular-buffer │ │ └── circular-buffer.cut ├── collatz-conjecture │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── collatz-conjecture.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── collatz-conjecture │ │ └── collatz-conjecture.cut ├── complex-numbers │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── complex-numbers.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── complex-numbers │ │ └── complex-numbers.cut ├── darts │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── darts.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── darts │ │ └── darts.cut ├── diamond │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── diamond.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── diamond │ │ └── diamond.cut ├── difference-of-squares │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── difference-of-squares.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── difference-of-squares │ │ └── difference-of-squares.cut ├── eliuds-eggs │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── eliuds-eggs.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── eliuds-eggs │ │ └── eliuds-eggs.cut ├── grade-school │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── grade-school.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── grade-school │ │ └── grade-school.cut ├── hamming │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── hamming.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── hamming │ │ └── hamming.cut ├── hello-world │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ ├── proof.ci.cob │ │ └── tests.toml │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── hello-world.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── hello-world │ │ └── hello-world.cut ├── high-scores │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ ├── proof.ci.cob │ │ └── tests.toml │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── high-scores.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── high-scores │ │ └── high-scores.cut ├── isogram │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── isogram.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── isogram │ │ └── isogram.cut ├── knapsack │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── knapsack.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── knapsack │ │ └── knapsack.cut ├── leap │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── leap.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── leap │ │ └── leap.cut ├── luhn │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── luhn.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── luhn │ │ └── luhn.cut ├── matching-brackets │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── matching-brackets.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── matching-brackets │ │ └── matching-brackets.cut ├── meetup │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── meetup.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── meetup │ │ └── meetup.cut ├── nucleotide-count │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── nucleotide-count.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── nucleotide-count │ │ └── nucleotide-count.cut ├── pangram │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── pangram.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── pangram │ │ └── pangram.cut ├── pascals-triangle │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── pascals-triangle.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── pascals-triangle │ │ └── pascals-triangle.cut ├── pig-latin │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── pig-latin.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── pig-latin │ │ └── pig-latin.cut ├── protein-translation │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── protein-translation.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── protein-translation │ │ └── protein-translation.cut ├── queen-attack │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── queen-attack.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── queen-attack │ │ └── queen-attack.cut ├── raindrops │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── raindrops.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── raindrops │ │ └── raindrops.cut ├── reverse-string │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ ├── proof.ci.cob │ │ └── tests.toml │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── reverse-string.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── reverse-string │ │ └── reverse-string.cut ├── rna-transcription │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── rna-transcription.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── rna-transcription │ │ └── rna-transcription.cut ├── robot-simulator │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── robot-simulator.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── robot-simulator │ │ └── robot-simulator.cut ├── roman-numerals │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── roman-numerals.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── roman-numerals │ │ └── roman-numerals.cut ├── rotational-cipher │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── rotational-cipher.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── rotational-cipher │ │ └── rotational-cipher.cut ├── scrabble-score │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── scrabble-score.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── scrabble-score │ │ └── scrabble-score.cut ├── secret-handshake │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── secret-handshake.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── secret-handshake │ │ └── secret-handshake.cut ├── sieve │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── sieve.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── sieve │ │ └── sieve.cut ├── space-age │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── space-age.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── space-age │ │ └── space-age.cut ├── square-root │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── square-root.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── square-root │ │ └── square-root.cut ├── triangle │ ├── .docs │ │ └── instructions.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── triangle.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── triangle │ │ └── triangle.cut ├── two-fer │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ ├── .meta │ │ ├── config.json │ │ └── proof.ci.cob │ ├── bin │ │ ├── fetch-cobolcheck │ │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ │ └── two-fer.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ │ └── two-fer │ │ └── two-fer.cut └── yacht │ ├── .docs │ ├── instructions.md │ └── introduction.md │ ├── .meta │ ├── config.json │ └── proof.ci.cob │ ├── bin │ ├── fetch-cobolcheck │ └── fetch-cobolcheck.ps1 │ ├── config.properties │ ├── src │ └── yacht.cob │ ├── test.ps1 │ ├── test.sh │ └── tst │ └── yacht │ └── yacht.cut └── shared └── .docs ├── help.md └── tests.md /.appends/.github/labels.yml: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------------------- # 2 | # These are the repository-specific labels that augment the Exercise-wide labels defined in # 3 | # https://github.com/exercism/org-wide-files/blob/main/global-files/.github/labels.yml. # 4 | # ----------------------------------------------------------------------------------------- # 5 | 6 | - name: "duplicate" 7 | description: "" 8 | color: "cccccc" 9 | 10 | - name: "enhancement" 11 | description: "" 12 | color: "84b6eb" 13 | 14 | - name: "invalid" 15 | description: "" 16 | color: "e6e6e6" 17 | 18 | - name: "needs maintainer" 19 | description: "" 20 | color: "fc2929" 21 | 22 | - name: "new track" 23 | description: "" 24 | color: "159818" 25 | 26 | - name: "question" 27 | description: "" 28 | color: "cc317c" 29 | 30 | - name: "wontfix" 31 | description: "" 32 | color: "ffffff" 33 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners 2 | .github/CODEOWNERS @exercism/maintainers-admin 3 | 4 | # Changes to `fetch-configlet` should be made in the `exercism/configlet` repo 5 | bin/fetch-configlet @exercism/maintainers-admin 6 | bin/fetch-configlet.ps1 @exercism/maintainers-admin 7 | -------------------------------------------------------------------------------- /.github/workflows/configlet.yml: -------------------------------------------------------------------------------- 1 | name: Configlet 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | configlet: 15 | uses: exercism/github-actions/.github/workflows/configlet.yml@main 16 | -------------------------------------------------------------------------------- /.github/workflows/no-important-files-changed.yml: -------------------------------------------------------------------------------- 1 | name: No important files changed 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | branches: [main] 7 | paths: 8 | - "exercises/concept/**" 9 | - "exercises/practice/**" 10 | - "!exercises/*/*/.approaches/**" 11 | - "!exercises/*/*/.articles/**" 12 | - "!exercises/*/*/.docs/**" 13 | - "!exercises/*/*/.meta/**" 14 | 15 | permissions: 16 | pull-requests: write 17 | 18 | jobs: 19 | check: 20 | uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main 21 | with: 22 | repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} 23 | ref: ${{ github.head_ref }} 24 | -------------------------------------------------------------------------------- /.github/workflows/pause-community-contributions.yml: -------------------------------------------------------------------------------- 1 | name: Pause Community Contributions 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | pull_request_target: 8 | types: 9 | - opened 10 | paths-ignore: 11 | - 'exercises/*/*/.approaches/**' 12 | - 'exercises/*/*/.articles/**' 13 | 14 | permissions: 15 | issues: write 16 | pull-requests: write 17 | 18 | jobs: 19 | pause: 20 | if: github.repository_owner == 'exercism' # Stops this job from running on forks 21 | uses: exercism/github-actions/.github/workflows/community-contributions.yml@main 22 | with: 23 | forum_category: cobol 24 | secrets: 25 | github_membership_token: ${{ secrets.COMMUNITY_CONTRIBUTIONS_WORKFLOW_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Tools 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - .github/labels.yml 9 | - .github/workflows/sync-labels.yml 10 | workflow_dispatch: 11 | schedule: 12 | - cron: 0 0 1 * * # First day of each month 13 | 14 | permissions: 15 | issues: write 16 | 17 | jobs: 18 | sync-labels: 19 | uses: exercism/github-actions/.github/workflows/labels.yml@main 20 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of the dependencies and run tests across different versions 2 | # 3 | # Replace with the track name 4 | # Replace with an image to run the jobs on 5 | # Replace with a github action to setup tooling on the image 6 | # Replace with a cli command to install the dependencies 7 | # 8 | # Find Github Actions to setup tooling here: 9 | # - https://github.com/actions/?q=setup&type=&language= 10 | # - https://github.com/actions/starter-workflows/tree/main/ci 11 | # - https://github.com/marketplace?type=actions&query=setup 12 | # 13 | # Requires scripts: 14 | # - bin/test 15 | 16 | name: COBOL / Test 17 | 18 | on: 19 | push: 20 | branches: [main] 21 | pull_request: 22 | workflow_dispatch: 23 | 24 | jobs: 25 | ci: 26 | runs-on: ubuntu-20.04 27 | 28 | steps: 29 | - name: Checkout repository 30 | uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 31 | 32 | - name: Setup COBOL 33 | run: sudo apt update && sudo apt install -y gnucobol 34 | 35 | - name: Fetch CobolCheck 36 | run: bin/fetch-cobolcheck 37 | 38 | - name: Run tests for all exercises 39 | run: bin/test 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | bin/configlet 4 | bin/configlet.exe 5 | cobolcheck 6 | cobolcheck.exe 7 | ALLTESTS 8 | test.cob 9 | test 10 | test.exe 11 | output 12 | *Log.txt 13 | cobolcheck.exe 14 | *.cob.bak -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Exercism 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 | -------------------------------------------------------------------------------- /bin/exercise_test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /bin/exercise_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /bin/setup-environment.ps1: -------------------------------------------------------------------------------- 1 | $gnucobolDir = "${HOME}\gnucobol" 2 | $cobolcheckDir = "${HOME}\cobolcheck" 3 | $env:Path = "${gnucobolDir}\bin;${cobolcheckDir};${env:Path}" 4 | [System.Environment]::SetEnvironmentVariable('COB_CONFIG_DIR', "${gnucobolDir}\config") 5 | [System.Environment]::SetEnvironmentVariable('COB_COPY_DIR', "${gnucobolDir}\copy") 6 | [System.Environment]::SetEnvironmentVariable('COB_CFLAGS', "-I ${gnucobolDir}\include") 7 | [System.Environment]::SetEnvironmentVariable('COB_LDFLAGS', "-L ${gnucobolDir}\lib") 8 | [System.Environment]::SetEnvironmentVariable('COB_LIBRARY_PATH', "${gnucobolDir}\lib") 9 | [System.Environment]::SetEnvironmentVariable('COB_LIBS', "${gnucobolDir}\bin\libcob-4.dll") 10 | -------------------------------------------------------------------------------- /bin/sync-exercise-files: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | shopt -s nullglob 6 | for test_dir in exercises/{concept,practice}/*; do 7 | for file in fetch-cobolcheck fetch-cobolcheck.ps1; do 8 | cp "bin/${file}" "${test_dir}/bin/${file}" 9 | done 10 | cp "bin/exercise_test.sh" "${test_dir}/test.sh" 11 | cp "bin/exercise_test.ps1" "${test_dir}/test.ps1" 12 | done 13 | -------------------------------------------------------------------------------- /bin/test.ps1: -------------------------------------------------------------------------------- 1 | function verify_exercise ($practiceExerciseDir) { 2 | $dir=[System.IO.Path]::GetFullPath($practiceExerciseDir) 3 | $slug=Split-Path $dir -Leaf 4 | $implementationFile="$dir/.meta/proof.ci.cob" 5 | $stubFile="$dir/src/$slug.cob" 6 | $stubBackupFile="$stubFile.bak" 7 | Copy-Item $stubFile -Destination $stubBackupFile 8 | Copy-Item $implementationFile -Destination $stubFile 9 | 10 | Invoke-Expression "$dir/test.ps1" 11 | 12 | if ($Lastexitcode -ne 0) { 13 | Write-Output $slug": proof solution did not pass the tests" 14 | exit 1 15 | } 16 | 17 | Copy-Item $stubBackupFile -Destination $stubFile 18 | } 19 | 20 | Get-ChildItem -Directory ./exercises/concept/ | 21 | ForEach-Object { 22 | Write-Output "Checking $_ exercise..."$_ 23 | verify_exercise $_ 24 | } 25 | Get-ChildItem -Directory ./exercises/practice/ | 26 | ForEach-Object { 27 | Write-Output "Checking $_ exercise..." 28 | verify_exercise $_ 29 | } -------------------------------------------------------------------------------- /concepts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/cobol/116ab9f05835f8ef72e34e5e067de7d7563133d9/concepts/.keep -------------------------------------------------------------------------------- /docs/INSTALLATION.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | Unlike newer languages, COBOL has multiple well-maintained compilers, though each has their own benefits. 4 | 5 | ## GnuCobol 6 | 7 | GnuCOBOL is the Free Software Foundation's Free and Open Source COBOL Compiler. It transpiles COBOL into a C program before using GCC to compile that into an executable. Instructions for installation can be found [here][GnuCOBOL]. 8 | 9 | ## IBM Cobol 10 | 11 | As a mainframe vendor, IBM maintains its own dialect of COBOL that works on its z/OS as well as other modern operating systems. IBM COBOL can be obtained free of charge through applying for the [COBOL environment for VSCode][IBM COBOL], which is part of the [Open Mainframe Project][Open Mainframe]. 12 | 13 | [GnuCOBOL]: https://gnucobol.sourceforge.io/faq/index.html#using-gnucobol 14 | [IBM COBOL]: https://www-40.ibm.com/events/wwe/ast/mtm/cobolvscode.nsf/enrollall?openform 15 | [Open Mainframe]: https://www.openmainframeproject.org/all-projects/cobolprogrammingcourse 16 | 17 | 21 | 22 | -------------------------------------------------------------------------------- /docs/RESOURCES.md: -------------------------------------------------------------------------------- 1 | # Useful Resources 2 | 3 | If you need some help you can visit these resources: 4 | 5 | * [COBOL 2014 ISO Standard](https://www.iso.org/standard/51416.html) 6 | * [Stack Overflow Questions](https://stackoverflow.com/questions/tagged/cobol), 7 | * [The COBOL subreddit](https://www.reddit.com/r/cobol), 8 | * [gnuCOBOL documentation (recommended for this track)](https://gnucobol.sourceforge.io/faq/index.html), 9 | * [Enterprise COBOL documentation](https://www.ibm.com/support/pages/enterprise-cobol-zos-documentation-library), 10 | * [Visual COBOL documentation](https://www.microfocus.com/documentation/visual-cobol/vc80/). 11 | * [Awesome COBOL](https://github.com/addisaden/awesome-cobol/) 12 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | HELLO * COBOL source code snippet 2 | IDENTIFICATION DIVISION. 3 | PROGRAM-ID. Hello. 4 | DATA DIVISION. 5 | PROCEDURE DIVISION. 6 | DISPLAY "Hello World!" 7 | STOP RUN. 8 | -------------------------------------------------------------------------------- /docs/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "docs": [ 3 | { 4 | "uuid": "451396ba-e0f6-46e4-83ac-f0e9ba1bf921", 5 | "slug": "installation", 6 | "path": "docs/INSTALLATION.md", 7 | "title": "Installing COBOL locally", 8 | "blurb": "Learn how to install COBOL locally to solve Exercism's exercises on your own machine" 9 | }, 10 | { 11 | "uuid": "7652cfc2-f79e-4074-aa64-3b751ac4cc52", 12 | "slug": "learning", 13 | "path": "docs/LEARNING.md", 14 | "title": "How to learn COBOL", 15 | "blurb": "An overview of how to get started from scratch with COBOL" 16 | }, 17 | { 18 | "uuid": "af96f86a-c11a-439c-ab9a-6178466d1c5b", 19 | "slug": "tests", 20 | "path": "docs/TESTS.md", 21 | "title": "Testing on the COBOL track", 22 | "blurb": "Learn how to test your COBOL exercises on Exercism" 23 | }, 24 | { 25 | "uuid": "b9e2bd02-f2ca-4830-89a8-108f3d546d3e", 26 | "slug": "resources", 27 | "path": "docs/RESOURCES.md", 28 | "title": "Useful COBOL resources", 29 | "blurb": "A collection of useful resources to help you master COBOL" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /exercises/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/cobol/116ab9f05835f8ef72e34e5e067de7d7563133d9/exercises/.keep -------------------------------------------------------------------------------- /exercises/concept/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/cobol/116ab9f05835f8ef72e34e5e067de7d7563133d9/exercises/concept/.keep -------------------------------------------------------------------------------- /exercises/practice/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/cobol/116ab9f05835f8ef72e34e5e067de7d7563133d9/exercises/practice/.keep -------------------------------------------------------------------------------- /exercises/practice/acronym/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Convert a phrase to its acronym. 4 | 5 | Techies love their TLA (Three Letter Acronyms)! 6 | 7 | Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). 8 | 9 | Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. 10 | 11 | For example: 12 | 13 | |Input|Output| 14 | |-|-| 15 | |As Soon As Possible|ASAP| 16 | |Liquid-crystal display|LCD| 17 | |Thank George It's Friday!|TGIF| 18 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/acronym.cob" 8 | ], 9 | "test": [ 10 | "tst/acronym/acronym.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Convert a phrase to its acronym.", 24 | "source": "Julien Vanier", 25 | "source_url": "https://github.com/monkbroc" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/acronym/src/acronym.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. acronym. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | 6 | WORKING-STORAGE SECTION. 7 | 01 WS-ACRONYM PIC X(80). 8 | 01 WS-RESULT PIC X(20). 9 | 10 | PROCEDURE DIVISION. 11 | ABBREVIATE. 12 | -------------------------------------------------------------------------------- /exercises/practice/acronym/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/acronym/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a sequence of digits in one base, representing a number, into a sequence of digits in another base, representing the same number. 4 | 5 | ~~~~exercism/note 6 | Try to implement the conversion yourself. 7 | Do not use something else to perform the conversion for you. 8 | ~~~~ 9 | 10 | ## About [Positional Notation][positional-notation] 11 | 12 | In positional notation, a number in base **b** can be understood as a linear combination of powers of **b**. 13 | 14 | The number 42, _in base 10_, means: 15 | 16 | `(4 × 10¹) + (2 × 10⁰)` 17 | 18 | The number 101010, _in base 2_, means: 19 | 20 | `(1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (0 × 2²) + (1 × 2¹) + (0 × 2⁰)` 21 | 22 | The number 1120, _in base 3_, means: 23 | 24 | `(1 × 3³) + (1 × 3²) + (2 × 3¹) + (0 × 3⁰)` 25 | 26 | _Yes. Those three numbers above are exactly the same. Congratulations!_ 27 | 28 | [positional-notation]: https://en.wikipedia.org/wiki/Positional_notation 29 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've just been hired as professor of mathematics. 4 | Your first week went well, but something is off in your second week. 5 | The problem is that every answer given by your students is wrong! 6 | Luckily, your math skills have allowed you to identify the problem: the student answers _are_ correct, but they're all in base 2 (binary)! 7 | Amazingly, it turns out that each week, the students use a different base. 8 | To help you quickly verify the student answers, you'll be building a tool to translate between bases. 9 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/all-your-base.cob" 8 | ], 9 | "test": [ 10 | "tst/all-your-base/all-your-base.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/src/all-your-base.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ALL-YOUR-BASE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUTBASE PIC 999. 7 | 01 WS-OUTPUTBASE PIC 999. 8 | 01 WS-DIGITS PIC X(60). 9 | 01 WS-RESULT PIC X(60). 10 | 01 WS-ERROR PIC X(60). 11 | 12 | PROCEDURE DIVISION. 13 | REBASE. 14 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies. 4 | 5 | An allergy test produces a single numeric score which contains the information about all the allergies the person has (that they were tested for). 6 | 7 | The list of items (and their value) that were tested are: 8 | 9 | - eggs (1) 10 | - peanuts (2) 11 | - shellfish (4) 12 | - strawberries (8) 13 | - tomatoes (16) 14 | - chocolate (32) 15 | - pollen (64) 16 | - cats (128) 17 | 18 | So if Tom is allergic to peanuts and chocolate, he gets a score of 34. 19 | 20 | Now, given just that score of 34, your program should be able to say: 21 | 22 | - Whether Tom is allergic to any one of those allergens listed above. 23 | - All the allergens Tom is allergic to. 24 | 25 | Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.). 26 | Your program should ignore those components of the score. 27 | For example, if the allergy score is 257, your program should only report the eggs (1) allergy. 28 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "glennj" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/allergies.cob" 8 | ], 9 | "test": [ 10 | "tst/allergies/allergies.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", 24 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 25 | "source_url": "https://turing.edu" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/allergies/src/allergies.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. allergies. 3 | 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-SCORE PIC 999. 7 | 01 WS-ITEM PIC X(12). 8 | 01 WS-RESULT PIC A. 9 | 01 WS-RESULT-LIST PIC X(108). 10 | 11 | PROCEDURE DIVISION. 12 | ALLERGIC-TO. 13 | * Code this paragraph 14 | CONTINUE. 15 | 16 | LIST-ALLERGENS. 17 | * Code this paragraph 18 | CONTINUE. 19 | -------------------------------------------------------------------------------- /exercises/practice/allergies/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/allergies/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | The result should be a string with anagrams separated by a comma (e.g., `"hello,world"`). 4 | 5 | You must return the anagrams in the same order as they are listed in the candidate words. 6 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to, given a target word and a set of candidate words, to find the subset of the candidates that are anagrams of the target. 4 | 5 | An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`. 6 | A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`. 7 | 8 | The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`). 9 | Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`. 10 | The anagram set is the subset of the candidate set that are anagrams of the target (in any order). 11 | Words in the anagram set should have the same letter case as in the candidate set. 12 | 13 | Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`. 14 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | At a garage sale, you find a lovely vintage typewriter at a bargain price! 4 | Excitedly, you rush home, insert a sheet of paper, and start typing away. 5 | However, your excitement wanes when you examine the output: all words are garbled! 6 | For example, it prints "stop" instead of "post" and "least" instead of "stale." 7 | Carefully, you try again, but now it prints "spot" and "slate." 8 | After some experimentation, you find there is a random delay before each letter is printed, which messes up the order. 9 | You now understand why they sold it for so little money! 10 | 11 | You realize this quirk allows you to generate anagrams, which are words formed by rearranging the letters of another word. 12 | Pleased with your finding, you spend the rest of the day generating hundreds of anagrams. 13 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "SimaDovakin" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "src/anagram.cob" 11 | ], 12 | "test": [ 13 | "tst/anagram/anagram.cut" 14 | ], 15 | "example": [ 16 | ".meta/proof.ci.cob" 17 | ] 18 | }, 19 | "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", 20 | "source": "Inspired by the Extreme Startup game", 21 | "source_url": "https://github.com/rchatley/extreme_startup" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/anagram/src/anagram.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ANAGRAM. 3 | 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-SUBJECT PIC X(20). 7 | 01 WS-CANDIDATES-COUNT PIC 9. 8 | 01 WS-CANDIDATES-TABLE. 9 | 02 WS-CANDIDATES OCCURS 1 TO 20 10 | DEPENDING ON WS-CANDIDATES-COUNT. 11 | 05 WS-CANDIDATE PIC X(20). 12 | 01 WS-RESULT-LIST PIC X(48). 13 | 14 | PROCEDURE DIVISION. 15 | 16 | FIND-ANAGRAMS. 17 | -------------------------------------------------------------------------------- /exercises/practice/anagram/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/anagram/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. 4 | 5 | For example: 6 | 7 | - 9 is an Armstrong number, because `9 = 9^1 = 9` 8 | - 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1` 9 | - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` 10 | - 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` 11 | 12 | Write some code to determine whether a number is an Armstrong number. 13 | 14 | [armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number 15 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/armstrong-numbers.cob" 8 | ], 9 | "test": [ 10 | "tst/armstrong-numbers/armstrong-numbers.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Determine if a number is an Armstrong number.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. armstrong-numbers. 3 | ENVIRONMENT DIVISION. 4 | CONFIGURATION SECTION. 5 | REPOSITORY. FUNCTION ALL INTRINSIC. 6 | DATA DIVISION. 7 | WORKING-STORAGE SECTION. 8 | 01 WS-NUMBER PIC X(8). 9 | 01 WS-DIGIT PIC 9(1). 10 | 01 WS-ARMSTRONG PIC 9(8). 11 | 01 WS-RESULT PIC 9. 12 | 01 WS-INDEX PIC 9(4). 13 | 14 | PROCEDURE DIVISION. 15 | ARMSTRONG-NUMBERS. 16 | INITIALIZE WS-ARMSTRONG. 17 | PERFORM VARYING WS-INDEX FROM 1 BY 1 18 | UNTIL WS-INDEX > LENGTH(TRIM(WS-NUMBER)) 19 | IF WS-NUMBER (WS-INDEX:1) EQUAL 0 20 | EXIT PERFORM CYCLE 21 | END-IF 22 | MOVE WS-NUMBER (WS-INDEX:1) TO WS-DIGIT 23 | COMPUTE WS-ARMSTRONG = 24 | WS-ARMSTRONG + WS-DIGIT ** LENGTH(TRIM(WS-NUMBER)) 25 | END-PERFORM. 26 | 27 | IF FUNCTION NUMVAL ( WS-NUMBER ) IS EQUAL TO WS-ARMSTRONG 28 | MOVE 1 TO WS-RESULT 29 | ELSE 30 | MOVE 0 TO WS-RESULT 31 | END-IF. 32 | 33 | * DISPLAY WS-ARMSTRONG. 34 | * DISPLAY WS-NUMBER. 35 | 36 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/src/armstrong-numbers.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. armstrong-numbers. 3 | ENVIRONMENT DIVISION. 4 | CONFIGURATION SECTION. 5 | REPOSITORY. FUNCTION ALL INTRINSIC. 6 | DATA DIVISION. 7 | WORKING-STORAGE SECTION. 8 | 01 WS-NUMBER PIC X(8). 9 | 01 WS-RESULT PIC 9. 10 | 11 | PROCEDURE DIVISION. 12 | ARMSTRONG-NUMBERS. -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/atbash-cipher.cob" 8 | ], 9 | "test": [ 10 | "tst/atbash-cipher/atbash-cipher.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Atbash" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/src/atbash-cipher.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ATBASH-CIPHER. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-PHRASE PIC X(60). 7 | 01 WS-RESULT PIC X(60). 8 | 9 | PROCEDURE DIVISION. 10 | 11 | ENCODE. 12 | 13 | 14 | DECODE. -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/binary-search.cob" 8 | ], 9 | "test": [ 10 | "tst/binary-search/binary-search.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Implement a binary search algorithm.", 21 | "source": "Wikipedia", 22 | "source_url": "http://en.wikipedia.org/wiki/Binary_search_algorithm" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/src/binary-search.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. BINARY-SEARCH. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-ITEM PIC 9999. 7 | 01 WS-RESULT PIC 99. 8 | 01 WS-ERROR PIC X(40). 9 | 01 WS-COUNT PIC 99. 10 | 01 WS-ARRAY-TABLE. 11 | 02 WS-ARRAY OCCURS 1 TO 20 DEPENDING ON WS-COUNT. 12 | 05 ROWELEM PIC 9(4). 13 | 14 | PROCEDURE DIVISION. 15 | 16 | BINARY-SEARCH. 17 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/binary/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles. 4 | 5 | Implement binary to decimal conversion. Given a binary input 6 | string, your program should produce a decimal output. The 7 | program should handle invalid inputs. 8 | 9 | ## Note 10 | 11 | - Implement the conversion yourself. 12 | Do not use something else to perform the conversion for you. 13 | 14 | ## About Binary (Base-2) 15 | 16 | Decimal is a base-10 system. 17 | 18 | A number 23 in base 10 notation can be understood 19 | as a linear combination of powers of 10: 20 | 21 | - The rightmost digit gets multiplied by 10^0 = 1 22 | - The next number gets multiplied by 10^1 = 10 23 | - ... 24 | - The *n*th number gets multiplied by 10^*(n-1)*. 25 | - All these values are summed. 26 | 27 | So: `23 => 2*10^1 + 3*10^0 => 2*10 + 3*1 = 23 base 10` 28 | 29 | Binary is similar, but uses powers of 2 rather than powers of 10. 30 | 31 | So: `101 => 1*2^2 + 0*2^1 + 1*2^0 => 1*4 + 0*2 + 1*1 => 4 + 1 => 5 base 10`. 32 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/binary.cob" 8 | ], 9 | "test": [ 10 | "tst/binary/binary.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles.", 24 | "source": "All of Computer Science", 25 | "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/binary/src/binary.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. BINARY. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-BINARY PIC X(60). 7 | 01 WS-RESULT PIC 9999. 8 | 01 WS-ERROR PIC X(60). 9 | 10 | PROCEDURE DIVISION. 11 | 12 | DECIMAL. 13 | -------------------------------------------------------------------------------- /exercises/practice/binary/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/binary/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what Bob will reply to someone when they say something to him or ask him a question. 4 | 5 | Bob only ever answers one of five things: 6 | 7 | - **"Sure."** 8 | This is his response if you ask him a question, such as "How are you?" 9 | The convention used for questions is that it ends with a question mark. 10 | - **"Whoa, chill out!"** 11 | This is his answer if you YELL AT HIM. 12 | The convention used for yelling is ALL CAPITAL LETTERS. 13 | - **"Calm down, I know what I'm doing!"** 14 | This is what he says if you yell a question at him. 15 | - **"Fine. Be that way!"** 16 | This is how he responds to silence. 17 | The convention used for silence is nothing, or various combinations of whitespace characters. 18 | - **"Whatever."** 19 | This is what he answers to anything else. 20 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Bob is a [lackadaisical][] teenager. 4 | He likes to think that he's very cool. 5 | And he definitely doesn't get excited about things. 6 | That wouldn't be cool. 7 | 8 | When people talk to him, his responses are pretty limited. 9 | 10 | [lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical 11 | -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/bob.cob" 8 | ], 9 | "test": [ 10 | "tst/bob/bob.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", 24 | "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", 25 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/bob/src/bob.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. BOB. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-HEYBOB PIC X(60). 7 | 01 WS-RESULT PIC X(40). 8 | BOB. -------------------------------------------------------------------------------- /exercises/practice/bob/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/bob/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/circular-buffer.cob" 8 | ], 9 | "test": [ 10 | "tst/circular-buffer/circular-buffer.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "A circular buffer, cyclic buffer or ring buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/src/circular-buffer.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. CIRCULAR-BUFFER. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-CAPACITY PIC 999. 7 | 01 WS-ITEM PIC 9. 8 | 01 WS-RESULT PIC 9. 9 | 01 WS-SUCCESS PIC 9. 10 | 11 | PROCEDURE DIVISION. 12 | CREATE-BUFFER. 13 | 14 | 15 | READ-BUFFER. 16 | 17 | 18 | WRITE-BUFFER. 19 | 20 | 21 | OVERWRITE-BUFFER. 22 | 23 | 24 | CLEAR-BUFFER. 25 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The Collatz Conjecture or 3x+1 problem can be summarized as follows: 4 | 5 | Take any positive integer n. 6 | If n is even, divide n by 2 to get n / 2. 7 | If n is odd, multiply n by 3 and add 1 to get 3n + 1. 8 | Repeat the process indefinitely. 9 | The conjecture states that no matter which number you start with, you will always reach 1 eventually. 10 | 11 | Given a number n, return the number of steps required to reach 1. 12 | 13 | ## Examples 14 | 15 | Starting with n = 12, the steps would be as follows: 16 | 17 | 0. 12 18 | 1. 6 19 | 2. 3 20 | 3. 10 21 | 4. 5 22 | 5. 16 23 | 6. 8 24 | 7. 4 25 | 8. 2 26 | 9. 1 27 | 28 | Resulting in 9 steps. 29 | So for input n = 12, the return value would be 9. 30 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/collatz-conjecture.cob" 8 | ], 9 | "test": [ 10 | "tst/collatz-conjecture/collatz-conjecture.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.", 24 | "source": "An unsolved problem in mathematics named after mathematician Lothar Collatz", 25 | "source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. collatz-conjecture. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC S9(8). 6 | 01 WS-STEPS PIC 9(4). 7 | 01 WS-ERROR PIC X(35). 8 | 9 | PROCEDURE DIVISION. 10 | COLLATZ-CONJECTURE. 11 | 12 | PERFORM UNTIL WS-NUMBER EQUAL 1 13 | 14 | IF WS-NUMBER IS LESS THAN 1 15 | MOVE "Only positive integers are allowed" 16 | TO WS-ERROR 17 | EXIT PERFORM 18 | END-IF 19 | 20 | IF FUNCTION MOD(WS-NUMBER, 2) EQUAL 1 21 | COMPUTE WS-NUMBER = WS-NUMBER * 3 + 1 22 | ELSE 23 | COMPUTE WS-NUMBER = WS-NUMBER / 2 24 | END-IF 25 | 26 | ADD 1 TO WS-STEPS 27 | END-PERFORM. 28 | 29 | *DISPLAY WS-STEPS. 30 | *DISPLAY WS-ERROR. 31 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/src/collatz-conjecture.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. collatz-conjecture. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC S9(8). 6 | 01 WS-STEPS PIC 9(4). 7 | 01 WS-ERROR PIC X(35). 8 | 9 | PROCEDURE DIVISION. 10 | COLLATZ-CONJECTURE. 11 | 12 | 13 | DISPLAY WS-STEPS. 14 | DISPLAY WS-ERROR. 15 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/tst/collatz-conjecture/collatz-conjecture.cut: -------------------------------------------------------------------------------- 1 | TESTSUITE 'Tests for collatz-conjecture' 2 | 3 | BEFORE-EACH 4 | MOVE 0 TO WS-STEPS 5 | END-BEFORE 6 | 7 | TestCase "zero steps for one" 8 | MOVE 1 TO WS-NUMBER 9 | PERFORM COLLATZ-CONJECTURE 10 | EXPECT WS-STEPS = 0000 11 | 12 | TestCase "divide if even" 13 | MOVE 16 TO WS-NUMBER 14 | PERFORM COLLATZ-CONJECTURE 15 | EXPECT WS-STEPS = 0004 16 | 17 | TestCase "even and odd steps" 18 | MOVE 12 TO WS-NUMBER 19 | PERFORM COLLATZ-CONJECTURE 20 | EXPECT WS-STEPS = 0009 21 | 22 | TestCase "large number of even and odd steps" 23 | MOVE 1000000 TO WS-NUMBER 24 | PERFORM COLLATZ-CONJECTURE 25 | EXPECT WS-STEPS = 0152 26 | 27 | TestCase "zero is an error" 28 | MOVE 0 TO WS-NUMBER 29 | PERFORM COLLATZ-CONJECTURE 30 | EXPECT WS-ERROR = "Only positive integers are allowed" 31 | 32 | TestCase "negative value is an error" 33 | MOVE -15 TO WS-NUMBER 34 | PERFORM COLLATZ-CONJECTURE 35 | EXPECT WS-ERROR = "Only positive integers are allowed" 36 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/complex-numbers.cob" 8 | ], 9 | "test": [ 10 | "tst/complex-numbers/complex-numbers.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "A complex number is a number in the form a + b * i where a and b are real and i satisfies i^2 = -1.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Complex_number" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/src/complex-numbers.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. COMPLEX-NUMBERS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 Z1-RE PIC S99999. 7 | 01 Z1-IM PIC S99999. 8 | 01 Z2-RE PIC S99999. 9 | 01 Z2-IM PIC S99999. 10 | 01 RESULT-RE PIC S99999V9999. 11 | 01 RESULT-IM PIC S99999V9999. 12 | 13 | 14 | PROCEDURE DIVISION. 15 | 16 | C-REAL. 17 | 18 | 19 | 20 | C-IMAGINARY. 21 | 22 | 23 | 24 | C-ADD. 25 | 26 | 27 | 28 | C-SUB. 29 | 30 | 31 | 32 | C-MUL. 33 | 34 | 35 | 36 | C-DIV. 37 | 38 | 39 | 40 | C-ABS. 41 | 42 | 43 | 44 | C-CONJUGATE. 45 | 46 | 47 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/darts.cob" 8 | ], 9 | "test": [ 10 | "tst/darts/darts.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Write a function that returns the earned points in a single toss of a Darts game.", 24 | "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. DARTS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-POINT. 7 | 03 WS-X usage float-short. 8 | 03 WS-Y usage float-short. 9 | 01 WS-RADIUS usage float-short. 10 | 01 WS-RESULT PIC 99. 11 | PROCEDURE DIVISION. 12 | DARTS. 13 | COMPUTE WS-RADIUS = FUNCTION SQRT(WS-X * WS-X + WS-Y * WS-Y). 14 | IF WS-RADIUS > 10 15 | MOVE 0 TO WS-RESULT 16 | ELSE IF WS-RADIUS > 5 17 | MOVE 1 TO WS-RESULT 18 | ELSE IF WS-RADIUS > 1 19 | MOVE 5 TO WS-RESULT 20 | ELSE 21 | MOVE 10 TO WS-RESULT. 22 | -------------------------------------------------------------------------------- /exercises/practice/darts/src/darts.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. DARTS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-X PIC 99V9. 7 | 01 WS-Y PIC 99V9. 8 | 01 WS-RESULT PIC 99. 9 | PROCEDURE DIVISION. 10 | DARTS. 11 | -------------------------------------------------------------------------------- /exercises/practice/darts/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/darts/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/diamond.cob" 8 | ], 9 | "test": [ 10 | "tst/diamond/diamond.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.", 24 | "source": "Seb Rose", 25 | "source_url": "http://claysnow.co.uk/recycling-tests-in-tdd/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/diamond/src/diamond.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. DIAMOND. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUTVARS. 7 | 05 WS-LETTER PIC X. 8 | 05 WS-ROWS PIC 99. 9 | 01 WS-OUTPUTTABLE. 10 | 05 WS-TABLEROW OCCURS 1 TO 50 DEPENDING ON WS-ROWS. 11 | 10 WS-LINE PIC X(60). 12 | 13 | PROCEDURE DIVISION. 14 | 15 | DIAMOND. -------------------------------------------------------------------------------- /exercises/practice/diamond/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/diamond/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. 4 | 5 | The square of the sum of the first ten natural numbers is 6 | (1 + 2 + ... + 10)² = 55² = 3025. 7 | 8 | The sum of the squares of the first ten natural numbers is 9 | 1² + 2² + ... + 10² = 385. 10 | 11 | Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640. 12 | 13 | You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged. 14 | Finding the best algorithm for the problem is a key skill in software engineering. 15 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/difference-of-squares.cob" 8 | ], 9 | "test": [ 10 | "tst/difference-of-squares/difference-of-squares.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", 24 | "source": "Problem 6 at Project Euler", 25 | "source_url": "https://projecteuler.net/problem=6" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. difference-of-squares. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-DIFFERENCE-OF-SQUARES PIC 9(8). 6 | 01 WS-SUM-OF-SQUARES PIC 9(8). 7 | 01 WS-SQUARE-OF-SUM PIC 9(8). 8 | 01 WS-NUMERATOR PIC 9(8). 9 | 01 WS-NUMBER PIC 9(8). 10 | 01 WS-SUM PIC 9(8). 11 | 12 | PROCEDURE DIVISION. 13 | 14 | SQUARE-OF-SUM. 15 | COMPUTE WS-SUM = WS-NUMBER * (WS-NUMBER + 1) / 2. 16 | COMPUTE WS-SQUARE-OF-SUM = WS-SUM * WS-SUM. 17 | 18 | SUM-OF-SQUARES. 19 | COMPUTE WS-NUMERATOR = 20 | WS-NUMBER * (WS-NUMBER + 1) * (2 * WS-NUMBER + 1). 21 | COMPUTE WS-SUM-OF-SQUARES = WS-NUMERATOR / 6. 22 | 23 | DIFFERENCE-OF-SQUARES. 24 | COMPUTE WS-DIFFERENCE-OF-SQUARES = 25 | WS-SQUARE-OF-SUM - WS-SUM-OF-SQUARES. 26 | 27 | SHOW-RESULTS. 28 | *DISPLAY WS-SQUARE-OF-SUM. 29 | *DISPLAY WS-SUM-OF-SQUARES. 30 | *DISPLAY WS-DIFFERENCE-OF-SQUARES. 31 | 32 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/src/difference-of-squares.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. difference-of-squares. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-DIFFERENCE-OF-SQUARES PIC 9(8). 6 | 01 WS-SUM-OF-SQUARES PIC 9(8). 7 | 01 WS-SQUARE-OF-SUM PIC 9(8). 8 | 01 WS-NUMBER PIC 9(8). 9 | 10 | PROCEDURE DIVISION. 11 | 12 | SQUARE-OF-SUM. 13 | 14 | 15 | SUM-OF-SQUARES. 16 | 17 | 18 | DIFFERENCE-OF-SQUARES. 19 | 20 | 21 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/tst/difference-of-squares/difference-of-squares.cut: -------------------------------------------------------------------------------- 1 | TestCase "square of sum 1" 2 | MOVE 1 TO WS-NUMBER 3 | PERFORM SQUARE-OF-SUM 4 | EXPECT WS-SQUARE-OF-SUM = 00000001 5 | 6 | TestCase "square of sum 5" 7 | MOVE 5 TO WS-NUMBER 8 | PERFORM SQUARE-OF-SUM 9 | EXPECT WS-SQUARE-OF-SUM = 00000225 10 | 11 | TestCase "square of sum 100" 12 | MOVE 100 TO WS-NUMBER 13 | PERFORM SQUARE-OF-SUM 14 | EXPECT WS-SQUARE-OF-SUM = 25502500 15 | 16 | TestCase "sum of squares 1" 17 | MOVE 1 TO WS-NUMBER 18 | PERFORM SUM-OF-SQUARES 19 | EXPECT WS-SUM-OF-SQUARES = 00000001 20 | 21 | TestCase "sum of squares 5" 22 | MOVE 5 TO WS-NUMBER 23 | PERFORM SUM-OF-SQUARES 24 | EXPECT WS-SUM-OF-SQUARES = 00000055 25 | 26 | TestCase "sum of squares 100" 27 | MOVE 100 TO WS-NUMBER 28 | PERFORM SUM-OF-SQUARES 29 | EXPECT WS-SUM-OF-SQUARES = 00338350 30 | 31 | TestCase "difference of squares 1" 32 | MOVE 1 TO WS-NUMBER 33 | PERFORM SQUARE-OF-SUM 34 | PERFORM SUM-OF-SQUARES 35 | PERFORM DIFFERENCE-OF-SQUARES 36 | EXPECT WS-DIFFERENCE-OF-SQUARES = 00000000 37 | 38 | TestCase "difference of squares 100" 39 | MOVE 100 TO WS-NUMBER 40 | PERFORM SQUARE-OF-SUM 41 | PERFORM SUM-OF-SQUARES 42 | PERFORM DIFFERENCE-OF-SQUARES 43 | EXPECT WS-DIFFERENCE-OF-SQUARES = 25164150 44 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to count the number of 1 bits in the binary representation of a number. 4 | 5 | ## Restrictions 6 | 7 | Keep your hands off that bit-count functionality provided by your standard library! 8 | Solve this one yourself using other basic tools instead. -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your friend Eliud inherited a farm from her grandma Tigist. 4 | Her granny was an inventor and had a tendency to build things in an overly complicated manner. 5 | The chicken coop has a digital display showing an encoded number representing the positions of all eggs that could be picked up. 6 | 7 | Eliud is asking you to write a program that shows the actual number of eggs in the coop. 8 | 9 | The position information encoding is calculated as follows: 10 | 11 | 1. Scan the potential egg-laying spots and mark down a `1` for an existing egg or a `0` for an empty spot. 12 | 2. Convert the number from binary to decimal. 13 | 3. Show the result on the display. 14 | 15 | Example 1: 16 | 17 | ```text 18 | Chicken Coop: 19 | _ _ _ _ _ _ _ 20 | |E| |E|E| | |E| 21 | 22 | Resulting Binary: 23 | 1 0 1 1 0 0 1 24 | 25 | Decimal number on the display: 26 | 89 27 | 28 | Actual eggs in the coop: 29 | 4 30 | ``` 31 | 32 | Example 2: 33 | 34 | ```text 35 | Chicken Coop: 36 | _ _ _ _ _ _ _ _ 37 | | | | |E| | | | | 38 | 39 | Resulting Binary: 40 | 0 0 0 1 0 0 0 0 41 | 42 | Decimal number on the display: 43 | 16 44 | 45 | Actual eggs in the coop: 46 | 1 47 | ``` -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/eliuds-eggs.cob" 8 | ], 9 | "test": [ 10 | "tst/eliuds-eggs/eliuds-eggs.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Help Eliud count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", 24 | "source": "Christian Willner, Eric Willigers", 25 | "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ELIUDS-EGGS. 3 | AUTHOR. kapitaali. 4 | ENVIRONMENT DIVISION. 5 | DATA DIVISION. 6 | WORKING-STORAGE SECTION. 7 | 01 WS-INPUTVARS. 8 | 05 WS-INPUT PIC 9(10). 9 | 01 WS-OUTPUTVARS. 10 | 05 WS-RESULT PIC 9999. 11 | 12 | 01 MY-WORKVARS. 13 | 05 REMAIN PIC 9. 14 | 15 | PROCEDURE DIVISION. 16 | 17 | EGG-COUNT. 18 | MOVE ZERO TO WS-RESULT. 19 | PERFORM UNTIL WS-INPUT = 0 20 | DIVIDE WS-INPUT BY 2 GIVING WS-INPUT REMAINDER REMAIN 21 | IF REMAIN = 1 22 | ADD 1 TO WS-RESULT 23 | END-IF 24 | END-PERFORM. 25 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/src/eliuds-eggs.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ELIUDS-EGGS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUTVARS. 7 | 05 WS-INPUT PIC 9(10). 8 | 01 WS-OUTPUTVARS. 9 | 05 WS-RESULT PIC 9999. 10 | 11 | PROCEDURE DIVISION. 12 | 13 | EGG-COUNT. 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/tst/eliuds-eggs/eliuds-eggs.cut: -------------------------------------------------------------------------------- 1 | TestCase "0 eggs" 2 | MOVE 0 TO WS-INPUT 3 | PERFORM EGG-COUNT 4 | EXPECT WS-RESULT = 0 5 | 6 | TestCase "1 egg" 7 | MOVE 16 TO WS-INPUT 8 | PERFORM EGG-COUNT 9 | EXPECT WS-RESULT = 1 10 | 11 | TestCase "4 eggs" 12 | MOVE 89 TO WS-INPUT 13 | PERFORM EGG-COUNT 14 | EXPECT WS-RESULT = 4 15 | 16 | TestCase "13 eggs" 17 | MOVE 2000000000 TO WS-INPUT 18 | PERFORM EGG-COUNT 19 | EXPECT WS-RESULT = 13 20 | 21 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/grade-school.cob" 8 | ], 9 | "test": [ 10 | "tst/grade-school/grade-school.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", 24 | "source": "A pairing session with Phil Battos at gSchool" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/src/grade-school.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. GRADE-SCHOOL. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-STUDENTNAME PIC X(60). 7 | 01 WS-STUDENTGRADE PIC 9. 8 | 01 WS-RESULT PIC X(5). 9 | 10 | 01 STUDENTROSTER. 11 | 02 ROSTER OCCURS 10 TIMES. 12 | 05 ST-NAME PIC X(60). 13 | 05 ST-GRADE PIC 9. 14 | 15 | PROCEDURE DIVISION. 16 | 17 | INIT-ROSTER. 18 | 19 | 20 | ADD-STUDENT. 21 | 22 | 23 | GET-GRADE. 24 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the Hamming Distance between two DNA strands. 4 | 5 | Your body is made up of cells that contain DNA. 6 | Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. 7 | In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! 8 | 9 | When cells divide, their DNA replicates too. 10 | Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. 11 | If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. 12 | This is known as the "Hamming Distance". 13 | 14 | We read DNA using the letters C,A,G and T. 15 | Two strands might look like this: 16 | 17 | GAGCCTACTAACGGGAT 18 | CATCGTAATGACGGCCT 19 | ^ ^ ^ ^ ^ ^^ 20 | 21 | They have 7 differences, and therefore the Hamming Distance is 7. 22 | 23 | The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) 24 | 25 | ## Implementation notes 26 | 27 | The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. 28 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/hamming.cob" 8 | ], 9 | "test": [ 10 | "tst/hamming/hamming.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Calculate the Hamming difference between two DNA strands.", 24 | "source": "The Calculating Point Mutations problem at Rosalind", 25 | "source_url": "https://rosalind.info/problems/hamm/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. hamming. 3 | ENVIRONMENT DIVISION. 4 | CONFIGURATION SECTION. 5 | REPOSITORY. FUNCTION ALL INTRINSIC. 6 | DATA DIVISION. 7 | WORKING-STORAGE SECTION. 8 | 01 WS-DNA-1 PIC X(32). 9 | 01 WS-DNA-2 PIC X(32). 10 | 01 WS-HAMMING PIC 9(2). 11 | 01 WS-DNA-INDEX PIC 9(5). 12 | 01 WS-ERROR PIC X(31). 13 | 14 | PROCEDURE DIVISION. 15 | HAMMING. 16 | 17 | PERFORM VARYING WS-DNA-INDEX FROM 1 BY 1 18 | UNTIL WS-DNA-INDEX > FUNCTION LENGTH(WS-DNA-1) 19 | 20 | IF FUNCTION LENGTH(TRIM(WS-DNA-1 TRAILING)) IS 21 | NOT EQUAL TO LENGTH(TRIM(WS-DNA-2 TRAILING)) 22 | MOVE "Strands must be of equal length" 23 | TO WS-ERROR 24 | EXIT PERFORM 25 | END-IF 26 | 27 | IF WS-DNA-1 (WS-DNA-INDEX:1) IS EQUAL TO SPACE 28 | EXIT PERFORM CYCLE 29 | END-IF 30 | 31 | IF WS-DNA-1 (WS-DNA-INDEX:1) IS NOT 32 | EQUAL TO WS-DNA-2 (WS-DNA-INDEX:1) 33 | ADD 1 TO WS-HAMMING 34 | END-IF 35 | 36 | END-PERFORM. 37 | 38 | *DISPLAY "Hamming Distance is: " WS-HAMMING. 39 | *DISPLAY WS-ERROR. 40 | -------------------------------------------------------------------------------- /exercises/practice/hamming/src/hamming.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. hamming. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-DNA-1 PIC X(32). 6 | 01 WS-DNA-2 PIC X(32). 7 | 01 WS-HAMMING PIC 9(2). 8 | 01 WS-ERROR PIC X(31). 9 | 10 | PROCEDURE DIVISION. 11 | HAMMING. 12 | 13 | 14 | DISPLAY "Hamming Distance is: " WS-HAMMING. 15 | DISPLAY WS-ERROR. 16 | -------------------------------------------------------------------------------- /exercises/practice/hamming/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/hamming/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/hamming/tst/hamming/hamming.cut: -------------------------------------------------------------------------------- 1 | TESTSUITE 'Tests for hamming' 2 | 3 | BEFORE-EACH 4 | MOVE 00 TO WS-HAMMING 5 | END-BEFORE 6 | 7 | TestCase "EMPTY STRANDS" 8 | MOVE " " TO WS-DNA-1 9 | MOVE " " TO WS-DNA-2 10 | PERFORM HAMMING 11 | EXPECT WS-HAMMING = 00 12 | 13 | TestCase "Single letter identical strands" 14 | MOVE "A" TO WS-DNA-1 15 | MOVE "A" TO WS-DNA-2 16 | PERFORM HAMMING 17 | EXPECT WS-HAMMING = 00 18 | 19 | TestCase "Single letter different strands" 20 | MOVE "G" TO WS-DNA-1 21 | MOVE "T" TO WS-DNA-2 22 | PERFORM HAMMING 23 | EXPECT WS-HAMMING = 01 24 | 25 | TestCase "Long identical strands" 26 | MOVE "GGACTGAAATCTG" TO WS-DNA-1 27 | MOVE "GGACTGAAATCTG" TO WS-DNA-2 28 | PERFORM HAMMING 29 | EXPECT WS-HAMMING = 00 30 | 31 | TestCase "long different strands" 32 | MOVE "GGACGGATTCTG" TO WS-DNA-1 33 | MOVE "AGGACGGATTCT" TO WS-DNA-2 34 | PERFORM HAMMING 35 | EXPECT WS-HAMMING = 09 36 | 37 | TestCase "Disallow strands of different length" 38 | MOVE "GGACGGATTCTG" TO WS-DNA-1 39 | MOVE "AGGACG" TO WS-DNA-2 40 | PERFORM HAMMING 41 | EXPECT WS-HAMMING = 00 42 | EXPECT WS-ERROR = "Strands must be of equal length" 43 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The classical introductory exercise. 4 | Just say "Hello, World!". 5 | 6 | ["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. 7 | 8 | The objectives are simple: 9 | 10 | - Modify the provided code so that it produces the string "Hello, World!". 11 | - Run the test suite and make sure that it succeeds. 12 | - Submit your solution and check it at the website. 13 | 14 | If everything goes well, you will be ready to fetch your first real exercise. 15 | 16 | [hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program 17 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "0xE282B0", 4 | "KTSnowy" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/hello-world.cob" 9 | ], 10 | "test": [ 11 | "tst/hello-world/hello-world.cut" 12 | ], 13 | "example": [ 14 | ".meta/proof.ci.cob" 15 | ], 16 | "invalidator": [ 17 | "test.ps1", 18 | "test.sh", 19 | "bin/fetch-cobolcheck", 20 | "bin/fetch-cobolcheck.ps1", 21 | "config.properties" 22 | ] 23 | }, 24 | "blurb": "The classical introductory exercise. Just say \"Hello, World!\".", 25 | "source": "This is an exercise to introduce users to using Exercism", 26 | "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | * Sample COBOL program 2 | IDENTIFICATION DIVISION. 3 | PROGRAM-ID. hello. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-RESULT PIC X(14). 7 | PROCEDURE DIVISION. 8 | HELLO-WORLD. 9 | MOVE "Hello, World!" TO WS-RESULT. 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 13 | description = "Say Hi!" 14 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/src/hello-world.cob: -------------------------------------------------------------------------------- 1 | *Sample COBOL program 2 | IDENTIFICATION DIVISION. 3 | PROGRAM-ID. hello-world. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-RESULT PIC X(14). 7 | PROCEDURE DIVISION. 8 | HELLO-WORLD. 9 | MOVE "Goodbye, Mars!" TO WS-RESULT. 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/tst/hello-world/hello-world.cut: -------------------------------------------------------------------------------- 1 | TestCase "Hello World" 2 | MOVE SPACES TO WS-RESULT 3 | PERFORM HELLO-WORLD 4 | EXPECT WS-RESULT = "Hello, World! " 5 | 6 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage a game player's High Score list. 4 | 5 | Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era. 6 | Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. 7 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "glennj" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/high-scores.cob" 8 | ], 9 | "test": [ 10 | "tst/high-scores/high-scores.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Manage a player's High Score list.", 24 | "source": "Tribute to the eighties' arcade game Frogger" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/src/high-scores.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. high-scores. 3 | 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-PROPERTY PIC A(20). 7 | 01 WS-SCORES. 8 | 02 SCORES PIC X(3) OCCURS 20 TIMES 9 | INDEXED BY IDX. 10 | 11 | 01 WS-RESULT-STRING PIC X(60). 12 | 01 WS-RESULT-VALUE PIC 999. 13 | 14 | PROCEDURE DIVISION. 15 | HIGH-SCORES. 16 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a word or phrase is an isogram. 4 | 5 | An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. 6 | 7 | Examples of isograms: 8 | 9 | - lumberjacks 10 | - background 11 | - downstream 12 | - six-year-old 13 | 14 | The word *isograms*, however, is not an isogram, because the s repeats. 15 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/isogram.cob" 8 | ], 9 | "test": [ 10 | "tst/isogram/isogram.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Determine if a word or phrase is an isogram.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/isogram/src/isogram.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ISOGRAM. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-PHRASE PIC X(60). 7 | 01 WS-RESULT PIC 99. 8 | PROCEDURE DIVISION. 9 | ISOGRAM. 10 | -------------------------------------------------------------------------------- /exercises/practice/isogram/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/isogram/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/knapsack.cob" 8 | ], 9 | "test": [ 10 | "tst/knapsack/knapsack.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Knapsack_problem" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/src/knapsack.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. KNAPSACK. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUTS. 7 | 05 MAXIMUM-WEIGHT PIC 999. 8 | 05 NO-OF-ITEMS PIC 99. 9 | 05 KNAPSACKTABLE OCCURS 1 TO 20 DEPENDING ON NO-OF-ITEMS. 10 | 10 WS-WEIGHT PIC 999. 11 | 10 WS-VALUE PIC 999. 12 | 01 WS-OUTPUTS. 13 | 05 WS-RESULT PIC 99999. 14 | 15 | PROCEDURE DIVISION. 16 | 17 | MAXIMUM-VALUE. -------------------------------------------------------------------------------- /exercises/practice/knapsack/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine whether a given year is a leap year. 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A leap year (in the Gregorian calendar) occurs: 4 | 5 | - In every year that is evenly divisible by 4. 6 | - Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. 7 | 8 | Some examples: 9 | 10 | - 1997 was not a leap year as it's not divisible by 4. 11 | - 1900 was not a leap year as it's not divisible by 400. 12 | - 2000 was a leap year! 13 | 14 | ~~~~exercism/note 15 | For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/leap.cob" 8 | ], 9 | "test": [ 10 | "tst/leap/leap.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Determine whether a given year is a leap year.", 24 | "source": "CodeRanch Cattle Drive, Assignment 3", 25 | "source_url": "https://coderanch.com/t/718816/Leap" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. LEAP. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-MODULUS-VALUES. 7 | 02 WS-MOD400 PIC 999. 8 | 02 WS-MOD100 PIC 999. 9 | 02 WS-MOD004 PIC 999. 10 | 01 WS-RESULT PIC 9. 11 | 01 WS-YEAR PIC 9999. 12 | 01 WS-TEMP PIC 9999. 13 | PROCEDURE DIVISION. 14 | LEAP. 15 | DIVIDE WS-YEAR BY 400 GIVING WS-TEMP REMAINDER WS-MOD400. 16 | DIVIDE WS-YEAR BY 100 GIVING WS-TEMP REMAINDER WS-MOD100. 17 | DIVIDE WS-YEAR BY 4 GIVING WS-TEMP REMAINDER WS-MOD004. 18 | IF WS-MOD400 = 0 OR (WS-MOD100 <> 0 AND WS-MOD004 = 0) 19 | MOVE 1 TO WS-RESULT 20 | ELSE 21 | MOVE 0 TO WS-RESULT 22 | END-IF. 23 | LEAP-EXIT. 24 | EXIT. 25 | -------------------------------------------------------------------------------- /exercises/practice/leap/src/leap.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. LEAP. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | PROCEDURE DIVISION. 7 | LEAP. 8 | * Enter solution here 9 | CONTINUE. 10 | LEAP-EXIT. 11 | EXIT. 12 | -------------------------------------------------------------------------------- /exercises/practice/leap/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/leap/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/luhn.cob" 8 | ], 9 | "test": [ 10 | "tst/luhn/luhn.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", 24 | "source": "The Luhn Algorithm on Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/luhn/src/luhn.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. luhn. 3 | ENVIRONMENT DIVISION. 4 | CONFIGURATION SECTION. 5 | REPOSITORY. FUNCTION ALL INTRINSIC. 6 | DATA DIVISION. 7 | WORKING-STORAGE SECTION. 8 | 01 WS-CARD-NUMBER PIC X(32). 9 | 01 WS-CARD-DIGITS PIC 9(32). 10 | 01 WS-CHECKSUM PIC 9(2). 11 | 01 WS-VALID PIC X(5). 12 | 13 | PROCEDURE DIVISION. 14 | LUHN. 15 | 16 | -------------------------------------------------------------------------------- /exercises/practice/luhn/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/luhn/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, 4 | or any combination thereof, verify that any and all pairs are matched 5 | and nested correctly. 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/matching-brackets.cob" 8 | ], 9 | "test": [ 10 | "tst/matching-brackets/matching-brackets.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", 24 | "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", 25 | "source_url": "http://pine.fm/LearnToProgram/?Chapter=06" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/src/matching-brackets.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. MATCHING-BRACKETS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUT PIC X(100). 7 | 01 WS-RESULT PIC 9. 8 | 9 | PROCEDURE DIVISION. 10 | 11 | ISPAIRED. 12 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to find the exact date of a meetup, given a month, year, weekday and week. 4 | 5 | There are five week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`. 6 | 7 | For example, you might be asked to find the date for the meetup on the first Monday in January 2018 (January 1, 2018). 8 | 9 | Similarly, you might be asked to find: 10 | 11 | - the third Tuesday of August 2019 (August 20, 2019) 12 | - the teenth Wednesday of May 2020 (May 13, 2020) 13 | - the fourth Sunday of July 2021 (July 25, 2021) 14 | - the last Thursday of November 2022 (November 24, 2022) 15 | - the teenth Saturday of August 1953 (August 15, 1953) 16 | 17 | ## Teenth 18 | 19 | The teenth week refers to the seven days in a month that end in '-teenth' (13th, 14th, 15th, 16th, 17th, 18th and 19th). 20 | 21 | If asked to find the teenth Saturday of August, 1953, we check its calendar: 22 | 23 | ```plaintext 24 | August 1953 25 | Su Mo Tu We Th Fr Sa 26 | 1 27 | 2 3 4 5 6 7 8 28 | 9 10 11 12 13 14 15 29 | 16 17 18 19 20 21 22 30 | 23 24 25 26 27 28 29 31 | 30 31 32 | ``` 33 | 34 | From this we find that the teenth Saturday is August 15, 1953. 35 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Every month, your partner meets up with their best friend. 4 | Both of them have very busy schedules, making it challenging to find a suitable date! 5 | Given your own busy schedule, your partner always double-checks potential meetup dates with you: 6 | 7 | - "Can I meet up on the first Friday of next month?" 8 | - "What about the third Wednesday?" 9 | - "Maybe the last Sunday?" 10 | 11 | In this month's call, your partner asked you this question: 12 | 13 | - "I'd like to meet up on the teenth Thursday; is that okay?" 14 | 15 | Confused, you ask what a "teenth" day is. 16 | Your partner explains that a teenth day, a concept they made up, refers to the days in a month that end in '-teenth': 17 | 18 | - 13th (thirteenth) 19 | - 14th (fourteenth) 20 | - 15th (fifteenth) 21 | - 16th (sixteenth) 22 | - 17th (seventeenth) 23 | - 18th (eighteenth) 24 | - 19th (nineteenth) 25 | 26 | As there are also seven weekdays, it is guaranteed that each day of the week has _exactly one_ teenth day each month. 27 | 28 | Now that you understand the concept of a teenth day, you check your calendar. 29 | You don't have anything planned on the teenth Thursday, so you happily confirm the date with your partner. 30 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/meetup.cob" 8 | ], 9 | "test": [ 10 | "tst/meetup/meetup.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Calculate the date of meetups.", 21 | "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/meetup/src/meetup.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. MEETUP. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-YEAR PIC 9999. 7 | 01 WS-MONTH PIC 99. 8 | 01 WS-WEEK PIC X(10). 9 | 01 WS-DAYOFWEEK PIC X(10). 10 | 01 WS-RESULT PIC X(40). 11 | 12 | PROCEDURE DIVISION. 13 | 14 | MEETUP. -------------------------------------------------------------------------------- /exercises/practice/meetup/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/meetup/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Each of us inherits from our biological parents a set of chemical instructions known as DNA that influence how our bodies are constructed. 4 | All known life depends on DNA! 5 | 6 | > Note: You do not need to understand anything about nucleotides or DNA to complete this exercise. 7 | 8 | DNA is a long chain of other chemicals and the most important are the four nucleotides, adenine, cytosine, guanine and thymine. 9 | A single DNA chain can contain billions of these four nucleotides and the order in which they occur is important! 10 | We call the order of these nucleotides in a bit of DNA a "DNA sequence". 11 | 12 | We represent a DNA sequence as an ordered collection of these four nucleotides and a common way to do that is with a string of characters such as "ATTACG" for a DNA sequence of 6 nucleotides. 13 | 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' for thymine. 14 | 15 | Given a string representing a DNA sequence, count how many of each nucleotide is present. 16 | If the string contains characters that aren't A, C, G, or T then it is invalid and you should signal an error. 17 | 18 | For example: 19 | 20 | ```text 21 | "GATTACA" -> 'A': 3, 'C': 1, 'G': 1, 'T': 2 22 | "INVALID" -> error 23 | ``` 24 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/nucleotide-count.cob" 8 | ], 9 | "test": [ 10 | "tst/nucleotide-count/nucleotide-count.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a DNA string, compute how many times each nucleotide occurs in the string.", 24 | "source": "The Calculating DNA Nucleotides_problem at Rosalind", 25 | "source_url": "https://rosalind.info/problems/dna/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/src/nucleotide-count.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. nucleotide-count. 3 | ENVIRONMENT DIVISION. 4 | CONFIGURATION SECTION. 5 | REPOSITORY. FUNCTION ALL INTRINSIC. 6 | DATA DIVISION. 7 | WORKING-STORAGE SECTION. 8 | 01 WS-DNA PIC X(128). 9 | 01 WS-A PIC 9(4). 10 | 01 WS-C PIC 9(4). 11 | 01 WS-G PIC 9(4). 12 | 01 WS-T PIC 9(4). 13 | 01 WS-ERROR PIC X(36). 14 | 15 | PROCEDURE DIVISION. 16 | NUCLEOTIDE-COUNT. 17 | 18 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/tst/nucleotide-count/nucleotide-count.cut: -------------------------------------------------------------------------------- 1 | TESTSUITE 'Tests for Nucleotide Count' 2 | 3 | BEFORE-EACH 4 | MOVE 00 TO WS-A 5 | MOVE 00 TO WS-C 6 | MOVE 00 TO WS-G 7 | MOVE 00 TO WS-T 8 | END-BEFORE 9 | 10 | TestCase "empty strand" 11 | MOVE " " TO WS-DNA 12 | PERFORM NUCLEOTIDE-COUNT 13 | EXPECT WS-A = 00 14 | EXPECT WS-C = 00 15 | EXPECT WS-G = 00 16 | EXPECT WS-T = 00 17 | 18 | TestCase "can count one nucleotide in single-character input" 19 | MOVE "G" TO WS-DNA 20 | PERFORM NUCLEOTIDE-COUNT 21 | EXPECT WS-A = 00 22 | EXPECT WS-C = 00 23 | EXPECT WS-G = 01 24 | EXPECT WS-T = 00 25 | 26 | TestCase "strand with repeated nucleotide" 27 | MOVE "GGGGGGG" TO WS-DNA 28 | PERFORM NUCLEOTIDE-COUNT 29 | EXPECT WS-A = 00 30 | EXPECT WS-C = 00 31 | EXPECT WS-G = 07 32 | EXPECT WS-T = 00 33 | 34 | TestCase "strand with multiple nucleotides" 35 | MOVE "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC" TO WS-DNA 36 | PERFORM NUCLEOTIDE-COUNT 37 | EXPECT WS-A = 20 38 | EXPECT WS-C = 12 39 | EXPECT WS-G = 17 40 | EXPECT WS-T = 21 41 | 42 | TestCase "strand with invalid nucleotides" 43 | MOVE "AGXXACT" TO WS-DNA 44 | PERFORM NUCLEOTIDE-COUNT 45 | EXPECT WS-ERROR = "ERROR: Invalid nucleotide in strand" 46 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to figure out if a sentence is a pangram. 4 | 5 | A pangram is a sentence using every letter of the alphabet at least once. 6 | It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). 7 | 8 | For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that sells fonts through their website. 4 | They'd like to show a different sentence each time someone views a font on their website. 5 | To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. 6 | 7 | They're running a competition to get suggestions for sentences that they can use. 8 | You're in charge of checking the submissions to see if they are valid. 9 | 10 | ~~~~exercism/note 11 | Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". 12 | 13 | The best known English pangram is: 14 | 15 | > The quick brown fox jumps over the lazy dog. 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/pangram.cob" 8 | ], 9 | "test": [ 10 | "tst/pangram/pangram.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Determine if a sentence is a pangram.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Pangram" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/pangram/src/pangram.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. PANGRAM. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-SENTENCE PIC X(60). 7 | 01 WS-RESULT PIC 9. 8 | PROCEDURE DIVISION. 9 | PANGRAM. 10 | -------------------------------------------------------------------------------- /exercises/practice/pangram/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/pangram/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Compute Pascal's triangle up to a given number of rows. 4 | 5 | In Pascal's Triangle each number is computed by adding the numbers to 6 | the right and left of the current position in the previous row. 7 | 8 | ```text 9 | 1 10 | 1 1 11 | 1 2 1 12 | 1 3 3 1 13 | 1 4 6 4 1 14 | # ... etc 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/pascals-triangle.cob" 8 | ], 9 | "test": [ 10 | "tst/pascals-triangle/pascals-triangle.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Compute Pascal's triangle up to a given number of rows.", 24 | "source": "Pascal's Triangle at Wolfram Math World", 25 | "source_url": "http://mathworld.wolfram.com/PascalsTriangle.html" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/src/pascals-triangle.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. PASCALS-TRIANGLE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-COUNT PIC 99. 7 | 8 | 01 WS-RESULT. 9 | 02 WS-ROW OCCURS 1 TO 99 DEPENDING ON WS-COUNT. 10 | 05 ROWELEM PIC X(60). 11 | 12 | PROCEDURE DIVISION. 13 | 14 | ROWS. 15 | 16 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your parents have challenged you and your sibling to a game of two-on-two basketball. 4 | Confident they'll win, they let you score the first couple of points, but then start taking over the game. 5 | Needing a little boost, you start speaking in [Pig Latin][pig-latin], which is a made-up children's language that's difficult for non-children to understand. 6 | This will give you the edge to prevail over your parents! 7 | 8 | [pig-latin]: https://en.wikipedia.org/wiki/Pig_latin 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/pig-latin.cob" 8 | ], 9 | "test": [ 10 | "tst/pig-latin/pig-latin.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Implement a program that translates from English to Pig Latin.", 21 | "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", 22 | "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/src/pig-latin.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. PIG-LATIN. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUT PIC X(60). 7 | 01 WS-RESULT PIC X(60). 8 | 9 | PROCEDURE DIVISION. 10 | 11 | TRANSLATE. -------------------------------------------------------------------------------- /exercises/practice/pig-latin/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/protein-translation.cob" 8 | ], 9 | "test": [ 10 | "tst/protein-translation/protein-translation.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Translate RNA sequences into proteins.", 21 | "source": "Tyler Long" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/src/protein-translation.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. PROTEIN-TRANSLATION. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUT PIC X(60). 7 | 01 WS-PROTEIN PIC X(120). 8 | 01 WS-ERROR PIC X(60). 9 | 10 | PROCEDURE DIVISION. 11 | 12 | TRANSLATE-CODON. 13 | 14 | TRANSLATE-RNA. 15 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given the position of two queens on a chess board, indicate whether or not they are positioned so that they can attack each other. 4 | 5 | In the game of chess, a queen can attack pieces which are on the same row, column, or diagonal. 6 | 7 | A chessboard can be represented by an 8 by 8 array. 8 | 9 | So if you are told the white queen is at `c5` (zero-indexed at column 2, row 3) and the black queen at `f2` (zero-indexed at column 5, row 6), then you know that the set-up is like so: 10 | 11 | ```text 12 | a b c d e f g h 13 | 8 _ _ _ _ _ _ _ _ 8 14 | 7 _ _ _ _ _ _ _ _ 7 15 | 6 _ _ _ _ _ _ _ _ 6 16 | 5 _ _ W _ _ _ _ _ 5 17 | 4 _ _ _ _ _ _ _ _ 4 18 | 3 _ _ _ _ _ _ _ _ 3 19 | 2 _ _ _ _ _ B _ _ 2 20 | 1 _ _ _ _ _ _ _ _ 1 21 | a b c d e f g h 22 | ``` 23 | 24 | You are also able to answer whether the queens can attack each other. 25 | In this case, that answer would be yes, they can, because both pieces share a diagonal. 26 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/queen-attack.cob" 8 | ], 9 | "test": [ 10 | "tst/queen-attack/queen-attack.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ] 15 | }, 16 | "blurb": "Given the position of two queens on a chess board, indicate whether or not they are positioned so that they can attack each other.", 17 | "source": "J Dalbey's Programming Practice problems", 18 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/src/queen-attack.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. QUEEN-ATTACK. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | *Inputs 7 | 01 WS-QUEEN PIC X(9). 8 | 01 WS-WHITE_QUEEN PIC X(9). 9 | 01 WS-BLACK_QUEEN PIC X(9). 10 | 01 WS-PROPERTY PIC X(11). 11 | *Outputs 12 | 01 WS-RESULT PIC 9. 13 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to convert a number into its corresponding raindrop sounds. 4 | 5 | If a given number: 6 | 7 | - is divisible by 3, add "Pling" to the result. 8 | - is divisible by 5, add "Plang" to the result. 9 | - is divisible by 7, add "Plong" to the result. 10 | - **is not** divisible by 3, 5, or 7, the result should be the number as a string. 11 | 12 | ## Examples 13 | 14 | - 28 is divisible by 7, but not 3 or 5, so the result would be `"Plong"`. 15 | - 30 is divisible by 3 and 5, but not 7, so the result would be `"PlingPlang"`. 16 | - 34 is not divisible by 3, 5, or 7, so the result would be `"34"`. 17 | 18 | ~~~~exercism/note 19 | A common way to test if one number is evenly divisible by another is to compare the [remainder][remainder] or [modulus][modulo] to zero. 20 | Most languages provide operators or functions for one (or both) of these. 21 | 22 | [remainder]: https://exercism.org/docs/programming/operators/remainder 23 | [modulo]: https://en.wikipedia.org/wiki/Modulo_operation 24 | ~~~~ 25 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question. 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/raindrops.cob" 8 | ], 9 | "test": [ 10 | "tst/raindrops/raindrops.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Convert a number to a string, the content of which depends on the number's factors.", 24 | "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", 25 | "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. raindrops. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC 9(4). 6 | 01 WS-RESULT PIC X(20). 7 | 8 | PROCEDURE DIVISION. 9 | RAINDROPS. 10 | 11 | IF FUNCTION MOD(WS-NUMBER, 3) EQUAL 0 12 | STRING "Pling" 13 | INTO WS-RESULT 14 | END-IF. 15 | 16 | IF FUNCTION MOD(WS-NUMBER, 5) EQUAL 0 17 | STRING FUNCTION TRIM(WS-RESULT TRAILING) "Plang" 18 | INTO WS-RESULT 19 | END-IF. 20 | 21 | IF FUNCTION MOD(WS-NUMBER, 7) EQUAL 0 22 | STRING FUNCTION TRIM(WS-RESULT TRAILING) "Plong" 23 | INTO WS-RESULT 24 | END-IF. 25 | 26 | IF WS-RESULT EQUAL SPACE 27 | MOVE WS-NUMBER TO WS-RESULT 28 | END-IF. 29 | 30 | *DISPLAY WS-RESULT. 31 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/src/raindrops.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. raindrops. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC 9(4). 6 | 01 WS-RESULT PIC X(20). 7 | 8 | PROCEDURE DIVISION. 9 | RAINDROPS. 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to reverse a given string. 4 | 5 | Some examples: 6 | 7 | - Turn `"stressed"` into `"desserts"`. 8 | - Turn `"strops"` into `"sports"`. 9 | - Turn `"racecar"` into `"racecar"`. 10 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Reversing strings (reading them from right to left, rather than from left to right) is a surprisingly common task in programming. 4 | 5 | For example, in bioinformatics, reversing the sequence of DNA or RNA strings is often important for various analyses, such as finding complementary strands or identifying palindromic sequences that have biological significance. 6 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/reverse-string.cob" 8 | ], 9 | "test": [ 10 | "tst/reverse-string/reverse-string.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Reverse a given string.", 24 | "source": "Introductory challenge to reverse an input string", 25 | "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. reverse-string. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-STRING PIC X(64). 6 | 7 | PROCEDURE DIVISION. 8 | REVERSE-STRING. 9 | 10 | MOVE FUNCTION REVERSE(WS-STRING) 11 | TO WS-STRING. 12 | 13 | MOVE FUNCTION TRIM(WS-STRING LEADING) 14 | TO WS-STRING. 15 | 16 | *DISPLAY WS-STRING. 17 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [c3b7d806-dced-49ee-8543-933fd1719b1c] 13 | description = "an empty string" 14 | 15 | [01ebf55b-bebb-414e-9dec-06f7bb0bee3c] 16 | description = "a word" 17 | 18 | [0f7c07e4-efd1-4aaa-a07a-90b49ce0b746] 19 | description = "a capitalized word" 20 | 21 | [71854b9c-f200-4469-9f5c-1e8e5eff5614] 22 | description = "a sentence with punctuation" 23 | 24 | [1f8ed2f3-56f3-459b-8f3e-6d8d654a1f6c] 25 | description = "a palindrome" 26 | 27 | [b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c] 28 | description = "an even-sized word" 29 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/src/reverse-string.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. reverse-string. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-STRING PIC X(64). 6 | 7 | PROCEDURE DIVISION. 8 | REVERSE-STRING. 9 | 10 | STRING* Reverse a string and display result 11 | 12 | DISPLAY WS-STRING. 13 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/tst/reverse-string/reverse-string.cut: -------------------------------------------------------------------------------- 1 | TestCase "COBOL" 2 | MOVE "COBOL" TO WS-STRING 3 | PERFORM REVERSE-STRING 4 | EXPECT WS-STRING = 'LOBOC' 5 | 6 | TestCase "LOBOC" 7 | MOVE "LOBOC" TO WS-STRING 8 | PERFORM REVERSE-STRING 9 | EXPECT WS-STRING = 'COBOL' 10 | 11 | TestCase "EMPTY" 12 | MOVE " " TO WS-STRING 13 | PERFORM REVERSE-STRING 14 | EXPECT WS-STRING = ' ' 15 | 16 | TestCase "Robot" 17 | MOVE "ROBOT" TO WS-STRING 18 | PERFORM REVERSE-STRING 19 | EXPECT WS-STRING = 'TOBOR' 20 | 21 | TestCase "Ramen" 22 | MOVE "Ramen" TO WS-STRING 23 | PERFORM REVERSE-STRING 24 | EXPECT WS-STRING = 'nemaR' 25 | 26 | TestCase "I'm hungry!" 27 | MOVE "I'm hungry!" TO WS-STRING 28 | PERFORM REVERSE-STRING 29 | EXPECT WS-STRING = "!yrgnuh m'I" 30 | 31 | TestCase "EMPTY" 32 | MOVE "drawer" TO WS-STRING 33 | PERFORM REVERSE-STRING 34 | EXPECT WS-STRING = 'reward' 35 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is determine the RNA complement of a given DNA sequence. 4 | 5 | Both DNA and RNA strands are a sequence of nucleotides. 6 | 7 | The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**). 8 | 9 | The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**). 10 | 11 | Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: 12 | 13 | - `G` -> `C` 14 | - `C` -> `G` 15 | - `T` -> `A` 16 | - `A` -> `U` 17 | 18 | ~~~~exercism/note 19 | If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. 20 | ~~~~ 21 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a bioengineering company that specializes in developing therapeutic solutions. 4 | 5 | Your team has just been given a new project to develop a targeted therapy for a rare type of cancer. 6 | 7 | ~~~~exercism/note 8 | It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein. 9 | That can cause all sorts of havoc. 10 | 11 | But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced. 12 | 13 | This technique is called [RNA Interference][rnai]. 14 | 15 | [rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/ 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/rna-transcription.cob" 8 | ], 9 | "test": [ 10 | "tst/rna-transcription/rna-transcription.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a DNA strand, return its RNA Complement Transcription.", 24 | "source": "Hyperphysics", 25 | "source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. rna-transcription. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-COMPLEMENT PIC X(64). 6 | 01 WS-DNA PIC X(4) VALUE "ACGT". 7 | 01 WS-RNA PIC X(4) VALUE "UGCA". 8 | 9 | PROCEDURE DIVISION. 10 | RNA-TRANSCRIPTION. 11 | 12 | INSPECT WS-COMPLEMENT CONVERTING WS-DNA 13 | TO WS-RNA. 14 | 15 | *DISPLAY WS-COMPLEMENT. 16 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/src/rna-transcription.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. rna-transcription. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-COMPLEMENT PIC X(64). 6 | 01 WS-DNA PIC X(4) VALUE "ACGT". 7 | 8 | PROCEDURE DIVISION. 9 | RNA-TRANSCRIPTION. 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/tst/rna-transcription/rna-transcription.cut: -------------------------------------------------------------------------------- 1 | TestCase "Empty" 2 | MOVE " " TO WS-COMPLEMENT 3 | PERFORM RNA-TRANSCRIPTION 4 | EXPECT WS-COMPLEMENT = ' ' 5 | 6 | TestCase "RNA complement of cytosine is guanine" 7 | MOVE "C" TO WS-COMPLEMENT 8 | PERFORM RNA-TRANSCRIPTION 9 | EXPECT WS-COMPLEMENT = 'G' 10 | 11 | TestCase "RNA complement of guanine is cytosine" 12 | MOVE "G" TO WS-COMPLEMENT 13 | PERFORM RNA-TRANSCRIPTION 14 | EXPECT WS-COMPLEMENT = 'C' 15 | 16 | TestCase "RNA complement of thymine is adenine" 17 | MOVE "T" TO WS-COMPLEMENT 18 | PERFORM RNA-TRANSCRIPTION 19 | EXPECT WS-COMPLEMENT = 'A' 20 | 21 | TestCase "RNA complement of adenine is uracil" 22 | MOVE "A" TO WS-COMPLEMENT 23 | PERFORM RNA-TRANSCRIPTION 24 | EXPECT WS-COMPLEMENT = 'U' 25 | 26 | TestCase "RNA complement" 27 | MOVE "ACGTGGTCTTAA" TO WS-COMPLEMENT 28 | PERFORM RNA-TRANSCRIPTION 29 | EXPECT WS-COMPLEMENT = 'UGCACCAGAAUU' 30 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Write a robot simulator. 4 | 5 | A robot factory's test facility needs a program to verify robot movements. 6 | 7 | The robots have three possible movements: 8 | 9 | - turn right 10 | - turn left 11 | - advance 12 | 13 | Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of {x,y} coordinates, 14 | e.g., {3,8}, with coordinates increasing to the north and east. 15 | 16 | The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing. 17 | 18 | - The letter-string "RAALAL" means: 19 | - Turn right 20 | - Advance twice 21 | - Turn left 22 | - Advance once 23 | - Turn left yet again 24 | - Say a robot starts at {7, 3} facing north. 25 | Then running this stream of instructions should leave it at {9, 4} facing west. 26 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/robot-simulator.cob" 8 | ], 9 | "test": [ 10 | "tst/robot-simulator/robot-simulator.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Write a robot simulator.", 21 | "source": "Inspired by an interview question at a famous company." 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/src/robot-simulator.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ROBOT-SIMULATOR. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-X-COORD PIC S999. 7 | 01 WS-Y-COORD PIC S999. 8 | 01 WS-DIRECTION PIC X(20). 9 | 01 WS-INSTRUCTIONS PIC X(60). 10 | 11 | PROCEDURE DIVISION. 12 | 13 | CREATE-ROBOT. 14 | 15 | 16 | MOVE-ROBOT. -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your task is to convert a number from Arabic numerals to Roman numerals. 4 | 5 | For this exercise, we are only concerned about traditional Roman numerals, in which the largest number is MMMCMXCIX (or 3,999). 6 | 7 | ~~~~exercism/note 8 | There are lots of different ways to convert between Arabic and Roman numerals. 9 | We recommend taking a naive approach first to familiarise yourself with the concept of Roman numerals and then search for more efficient methods. 10 | 11 | Make sure to check out our Deep Dive video at the end to explore the different approaches you can take! 12 | ~~~~ 13 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/roman-numerals.cob" 8 | ], 9 | "test": [ 10 | "tst/roman-numerals/roman-numerals.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Convert modern Arabic numbers into Roman numerals.", 24 | "source": "The Roman Numeral Kata", 25 | "source_url": "https://codingdojo.org/kata/RomanNumerals/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/src/roman-numerals.cob: -------------------------------------------------------------------------------- 1 | 000001 IDENTIFICATION DIVISION. 2 | PROGRAM-ID. ROMAN-NUMERALS. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-NUMBER PIC 9999. 7 | 01 WS-RESULT PIC X(20). 8 | PROCEDURE DIVISION. 9 | ROMAN-NUMERALS. 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/rotational-cipher.cob" 8 | ], 9 | "test": [ 10 | "tst/rotational-cipher/rotational-cipher.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Caesar_cipher" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/src/rotational-cipher.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. rotational-cipher. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-KEY PIC 9(2). 6 | 01 WS-TEXT PIC X(128). 7 | 01 WS-CIPHER PIC X(128). 8 | 9 | PROCEDURE DIVISION. 10 | ROTATIONAL-CIPHER. 11 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to compute a word's Scrabble score by summing the values of its letters. 4 | 5 | The letters are valued as follows: 6 | 7 | | Letter | Value | 8 | | ---------------------------- | ----- | 9 | | A, E, I, O, U, L, N, R, S, T | 1 | 10 | | D, G | 2 | 11 | | B, C, M, P | 3 | 12 | | F, H, V, W, Y | 4 | 13 | | K | 5 | 14 | | J, X | 8 | 15 | | Q, Z | 10 | 16 | 17 | For example, the word "cabbage" is worth 14 points: 18 | 19 | - 3 points for C 20 | - 1 point for A 21 | - 3 points for B 22 | - 3 points for B 23 | - 1 point for A 24 | - 2 points for G 25 | - 1 point for E 26 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. 4 | Each letter has a value. 5 | A word's score is the sum of its letters' values. 6 | 7 | [wikipedia]: https://en.wikipedia.org/wiki/Scrabble 8 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/scrabble-score.cob" 8 | ], 9 | "test": [ 10 | "tst/scrabble-score/scrabble-score.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ] 15 | }, 16 | "blurb": "Given a word, compute the Scrabble score for that word.", 17 | "source": "Inspired by the Extreme Startup game", 18 | "source_url": "https://github.com/rchatley/extreme_startup" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/src/scrabble-score.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. SCRABBLE-SCORE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | *Inputs 7 | 01 WS-WORD PIC X(60). 8 | *Outputs 9 | 01 WS-RESULT PIC 99. -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | > There are 10 types of people in the world: Those who understand 4 | > binary, and those who don't. 5 | 6 | You and your fellow cohort of those in the "know" when it comes to 7 | binary decide to come up with a secret "handshake". 8 | 9 | ```text 10 | 00001 = wink 11 | 00010 = double blink 12 | 00100 = close your eyes 13 | 01000 = jump 14 | 15 | 16 | 10000 = Reverse the order of the operations in the secret handshake. 17 | ``` 18 | 19 | Given a decimal number, convert it to the appropriate sequence of events for a secret handshake. 20 | 21 | Here's a couple of examples: 22 | 23 | Given the decimal input 3, the function would return the array 24 | ["wink", "double blink"] because the decimal number 3 is 2+1 in powers of two and thus `11` in binary. 25 | 26 | Let's now examine the input 19 which is 16+2+1 in powers of two and thus `10011` in binary. 27 | Recalling that the addition of 16 (`10000` in binary) reverses an array and that we already know what array is returned given input 3, the array returned for input 19 is ["double blink", "wink"]. 28 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/secret-handshake.cob" 8 | ], 9 | "test": [ 10 | "tst/secret-handshake/secret-handshake.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.", 21 | "source": "Bert, in Mary Poppins", 22 | "source_url": "http://www.imdb.com/title/tt0058331/quotes/qt0437047" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/src/secret-handshake.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. SECRET-HANDSHAKE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUT PIC 999. 7 | 01 WS-RESULT PIC X(60). 8 | 9 | PROCEDURE DIVISION. 10 | 11 | COMMANDS. -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You bought a big box of random computer parts at a garage sale. 4 | You've started putting the parts together to build custom computers. 5 | 6 | You want to test the performance of different combinations of parts, and decide to create your own benchmarking program to see how your computers compare. 7 | You choose the famous "Sieve of Eratosthenes" algorithm, an ancient algorithm, but one that should push your computers to the limits. 8 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/sieve.cob" 8 | ], 9 | "test": [ 10 | "tst/sieve/sieve.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 24 | "source": "Sieve of Eratosthenes at Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/sieve/src/sieve.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. SIEVE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-LIMIT PIC 9999. 7 | 01 WS-RESULT PIC 999 OCCURS 1000 TIMES. 8 | 01 WS-COUNT PIC 9999. 9 | PROCEDURE DIVISION. 10 | SIEVE. 11 | -------------------------------------------------------------------------------- /exercises/practice/sieve/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/sieve/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given an age in seconds, calculate how old someone would be on: 4 | 5 | - Mercury: orbital period 0.2408467 Earth years 6 | - Venus: orbital period 0.61519726 Earth years 7 | - Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds 8 | - Mars: orbital period 1.8808158 Earth years 9 | - Jupiter: orbital period 11.862615 Earth years 10 | - Saturn: orbital period 29.447498 Earth years 11 | - Uranus: orbital period 84.016846 Earth years 12 | - Neptune: orbital period 164.79132 Earth years 13 | 14 | So if you were told someone were 1,000,000,000 seconds old, you should 15 | be able to say that they're 31.69 Earth-years old. 16 | 17 | If you're wondering why Pluto didn't make the cut, go watch [this 18 | YouTube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs). 19 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kapitaali" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/space-age.cob" 8 | ], 9 | "test": [ 10 | "tst/space-age/space-age.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.sh", 17 | "test.ps1" 18 | ] 19 | }, 20 | "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", 21 | "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", 22 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/space-age/src/space-age.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. SPACE-AGE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | 01 WS-INPUT PIC 9(30). 7 | 01 WS-WHICH-PLANET PIC X(30) 8 | 01 WS-RESULT PIC 9(4)V99. 9 | 01 WS-ERROR PIC X(30). 10 | 11 | PROCEDURE DIVISION. 12 | 13 | ROUNDS-TO. 14 | -------------------------------------------------------------------------------- /exercises/practice/space-age/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/space-age/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a natural radicand, return its square root. 4 | 5 | Note that the term "radicand" refers to the number for which the root is to be determined. 6 | That is, it is the number under the root symbol. 7 | 8 | Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots]. 9 | 10 | Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up). 11 | 12 | [square-root]: https://en.wikipedia.org/wiki/Square_root 13 | [computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots 14 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/square-root.cob" 8 | ], 9 | "test": [ 10 | "tst/square-root/square-root.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Given a natural radicand, return its square root.", 24 | "source": "wolf99", 25 | "source_url": "https://github.com/exercism/problem-specifications/pull/1582" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. square-root. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC 9(32). 6 | 01 WS-SQRT PIC 9(32). 7 | 8 | PROCEDURE DIVISION. 9 | SQUARE-ROOT. 10 | COMPUTE WS-SQRT = WS-NUMBER ** 0.5. 11 | -------------------------------------------------------------------------------- /exercises/practice/square-root/src/square-root.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. square-root. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NUMBER PIC 9(32). 6 | 01 WS-SQRT PIC 9(32). 7 | 8 | PROCEDURE DIVISION. 9 | SQUARE-ROOT. 10 | -------------------------------------------------------------------------------- /exercises/practice/square-root/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/square-root/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/square-root/tst/square-root/square-root.cut: -------------------------------------------------------------------------------- 1 | TESTSUITE 'Tests for Square Root' 2 | 3 | BEFORE-EACH 4 | MOVE 0 TO WS-SQRT 5 | END-BEFORE 6 | 7 | TestCase "root of 1" 8 | MOVE 1 TO WS-NUMBER 9 | PERFORM SQUARE-ROOT 10 | EXPECT WS-SQRT = 1 11 | 12 | TestCase "root of 4" 13 | MOVE 4 TO WS-NUMBER 14 | PERFORM SQUARE-ROOT 15 | EXPECT WS-SQRT = 2 16 | 17 | TestCase "root of 25" 18 | MOVE 25 TO WS-NUMBER 19 | PERFORM SQUARE-ROOT 20 | EXPECT WS-SQRT = 5 21 | 22 | TestCase "root of 81" 23 | MOVE 81 TO WS-NUMBER 24 | PERFORM SQUARE-ROOT 25 | EXPECT WS-SQRT = 9 26 | 27 | TestCase "root of 196" 28 | MOVE 196 TO WS-NUMBER 29 | PERFORM SQUARE-ROOT 30 | EXPECT WS-SQRT = 14 31 | 32 | TestCase "root of 65025" 33 | MOVE 65025 TO WS-NUMBER 34 | PERFORM SQUARE-ROOT 35 | EXPECT WS-SQRT = 255 36 | 37 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a triangle is equilateral, isosceles, or scalene. 4 | 5 | An _equilateral_ triangle has all three sides the same length. 6 | 7 | An _isosceles_ triangle has at least two sides the same length. 8 | (It is sometimes specified as having exactly two sides the same length, but for the purposes of this exercise we'll say at least two.) 9 | 10 | A _scalene_ triangle has all sides of different lengths. 11 | 12 | ## Note 13 | 14 | For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side. 15 | 16 | In equations: 17 | 18 | Let `a`, `b`, and `c` be sides of the triangle. 19 | Then all three of the following expressions must be true: 20 | 21 | ```text 22 | a + b ≥ c 23 | b + c ≥ a 24 | a + c ≥ b 25 | ``` 26 | 27 | See [Triangle Inequality][triangle-inequality] 28 | 29 | [triangle-inequality]: https://en.wikipedia.org/wiki/Triangle_inequality 30 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/triangle.cob" 8 | ], 9 | "test": [ 10 | "tst/triangle/triangle.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ] 15 | }, 16 | "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", 17 | "source": "The Ruby Koans triangle project, parts 1 & 2", 18 | "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/triangle/src/triangle.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. TRIANGLE. 3 | ENVIRONMENT DIVISION. 4 | DATA DIVISION. 5 | WORKING-STORAGE SECTION. 6 | *Incoming 7 | 01 WS-SIDES PIC X(20). 8 | 01 WS-PROPERTY PIC X(11). 9 | *Outgoing 10 | 01 WS-RESULT PIC 9. 11 | PROCEDURE DIVISION. 12 | TRIANGLE. 13 | -------------------------------------------------------------------------------- /exercises/practice/triangle/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/triangle/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what you will say as you give away the extra cookie. 4 | 5 | If you know the person's name (e.g. if they're named Do-yun), then you will say: 6 | 7 | ```text 8 | One for Do-yun, one for me. 9 | ``` 10 | 11 | If you don't know the person's name, you will say _you_ instead. 12 | 13 | ```text 14 | One for you, one for me. 15 | ``` 16 | 17 | Here are some examples: 18 | 19 | | Name | Dialogue | 20 | | :----- | :-------------------------- | 21 | | Alice | One for Alice, one for me. | 22 | | Bohdan | One for Bohdan, one for me. | 23 | | | One for you, one for me. | 24 | | Zaphod | One for Zaphod, one for me. | 25 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In some English accents, when you say "two for" quickly, it sounds like "two fer". 4 | Two-for-one is a way of saying that if you buy one, you also get one for free. 5 | So the phrase "two-fer" often implies a two-for-one offer. 6 | 7 | Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). 8 | You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. 9 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "KTSnowy" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/two-fer.cob" 8 | ], 9 | "test": [ 10 | "tst/two-fer/two-fer.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 24 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/proof.ci.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. two-fer. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NAME PIC X(16). 6 | 01 WS-RESULT PIC X(64). 7 | 8 | PROCEDURE DIVISION. 9 | TWO-FER. 10 | 11 | IF WS-NAME EQUAL SPACE THEN 12 | MOVE "One for you, one for me." TO WS-RESULT 13 | ELSE 14 | MOVE FUNCTION CONCATENATE("One for ", 15 | FUNCTION TRIM(WS-NAME TRAILING),", one for me.") 16 | TO WS-RESULT 17 | END-IF. 18 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/src/two-fer.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. two-fer. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-NAME PIC X(16). 6 | 01 WS-RESULT PIC X(64). 7 | 8 | PROCEDURE DIVISION. 9 | TWO-FER. 10 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/tst/two-fer/two-fer.cut: -------------------------------------------------------------------------------- 1 | TESTSUITE 'Tests for Two-Fer' 2 | 3 | TestCase "No name given" 4 | PERFORM TWO-FER 5 | EXPECT WS-RESULT = "One for you, one for me." 6 | 7 | TestCase "A name given" 8 | MOVE "Alice" TO WS-NAME 9 | PERFORM TWO-FER 10 | EXPECT WS-RESULT = "One for Alice, one for me." 11 | 12 | TestCase "Another name given" 13 | MOVE "Keith" TO WS-NAME 14 | PERFORM TWO-FER 15 | EXPECT WS-RESULT = "One for Keith, one for me." 16 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Each year, something new is "all the rage" in your high school. 4 | This year it is a dice game: [Yacht][yacht]. 5 | 6 | The game of Yacht is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. 7 | The game consists of twelve rounds. 8 | In each, five dice are rolled and the player chooses one of twelve categories. 9 | The chosen category is then used to score the throw of the dice. 10 | 11 | [yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) 12 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "axtens" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/yacht.cob" 8 | ], 9 | "test": [ 10 | "tst/yacht/yacht.cut" 11 | ], 12 | "example": [ 13 | ".meta/proof.ci.cob" 14 | ], 15 | "invalidator": [ 16 | "test.ps1", 17 | "test.sh", 18 | "bin/fetch-cobolcheck", 19 | "bin/fetch-cobolcheck.ps1", 20 | "config.properties" 21 | ] 22 | }, 23 | "blurb": "Score a single throw of dice in the game Yacht.", 24 | "source": "James Kilfiger, using wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/yacht/src/yacht.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. YACHT. 3 | DATA DIVISION. 4 | WORKING-STORAGE SECTION. 5 | 01 WS-RESULT PIC 99 VALUE 0. 6 | 01 WS-CATEGORY PIC X(15). 7 | 01 WS-DICE PIC 9(5). 8 | PROCEDURE DIVISION. 9 | YACHT. 10 | -------------------------------------------------------------------------------- /exercises/practice/yacht/test.ps1: -------------------------------------------------------------------------------- 1 | $slug=Split-Path $PSScriptRoot -Leaf 2 | $cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" 3 | $cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue 4 | 5 | if ($cobolcheckCmd) { 6 | $cobolcheck = $cobolcheckCmd.Path 7 | Write-Output "Found cobolcheck, using $cobolcheck" 8 | } elseif (![System.IO.File]::Exists("$cobolcheck")){ 9 | $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" 10 | echo $fetchCobolcheckPath 11 | Write-Output "Cobolcheck not found. Trying to fetch it." 12 | & "${fetchCobolcheckPath}" 13 | } 14 | 15 | Write-Output "Run cobolcheck." 16 | Set-Location $PSScriptRoot 17 | 18 | Invoke-Expression "$cobolcheck -p $slug" 19 | Invoke-Expression "cobc -xj test.cob" 20 | 21 | if ($Lastexitcode -ne 0) { 22 | exit $Lastexitcode 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/yacht/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ 3 | SLUG=${1:-$(basename "${SCRIPT_DIR}")} 4 | COBOLCHECK="${HOME}/cobolcheck/cobolcheck" 5 | 6 | WHICH_COBOLCHECK=$(which cobolcheck) 7 | if [[ $? -eq 0 ]] ; then 8 | echo "Found cobolcheck, using $COBOLCHECK" 9 | COBOLCHECK=$WHICH_COBOLCHECK 10 | elif [ ! -f "${COBOLCHECK}" ]; then 11 | echo "Cobolcheck not found, try to fetch it." 12 | cd $SCRIPT_DIR/bin/ 13 | bash fetch-cobolcheck 14 | fi 15 | cd $SCRIPT_DIR 16 | $COBOLCHECK -p $SLUG 17 | 18 | # compile and run 19 | echo "COMPILE AND RUN TEST" 20 | cobc -xj test.cob 21 | -------------------------------------------------------------------------------- /exercises/shared/.docs/help.md: -------------------------------------------------------------------------------- 1 | # Help 2 | 3 | ## Useful Resources 4 | 5 | If you need some help you can visit these resources: 6 | 7 | * [Stack Overflow Questions](https://stackoverflow.com/questions/tagged/cobol), 8 | * [The COBOL subreddit](https://www.reddit.com/r/cobol), 9 | * [gnuCOBOL documentation (recommended for this track)](https://gnucobol.sourceforge.io/faq/index.html), 10 | * [Enterprise COBOL documentation](https://www.ibm.com/support/pages/enterprise-cobol-zos-documentation-library), 11 | * [Visual COBOL documentation](https://www.microfocus.com/documentation/visual-cobol/vc80/). 12 | --------------------------------------------------------------------------------