-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding space-age * adding space-age
- Loading branch information
Showing
12 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Instructions | ||
|
||
Given an age in seconds, calculate how old someone would be on: | ||
|
||
- Mercury: orbital period 0.2408467 Earth years | ||
- Venus: orbital period 0.61519726 Earth years | ||
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds | ||
- Mars: orbital period 1.8808158 Earth years | ||
- Jupiter: orbital period 11.862615 Earth years | ||
- Saturn: orbital period 29.447498 Earth years | ||
- Uranus: orbital period 84.016846 Earth years | ||
- Neptune: orbital period 164.79132 Earth years | ||
|
||
So if you were told someone were 1,000,000,000 seconds old, you should | ||
be able to say that they're 31.69 Earth-years old. | ||
|
||
If you're wondering why Pluto didn't make the cut, go watch [this | ||
YouTube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Introduction | ||
|
||
Given an age in seconds, calculate how old someone would be on: | ||
|
||
- Mercury: orbital period 0.2408467 Earth years | ||
- Venus: orbital period 0.61519726 Earth years | ||
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds | ||
- Mars: orbital period 1.8808158 Earth years | ||
- Jupiter: orbital period 11.862615 Earth years | ||
- Saturn: orbital period 29.447498 Earth years | ||
- Uranus: orbital period 84.016846 Earth years | ||
- Neptune: orbital period 164.79132 Earth years | ||
|
||
So if you were told someone were 1,000,000,000 seconds old, you should | ||
be able to say that they're 31.69 Earth-years old. | ||
|
||
If you're wondering why Pluto didn't make the cut, go watch [this | ||
YouTube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"authors": [ | ||
"kapitaali" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/space-age.cob" | ||
], | ||
"test": [ | ||
"tst/space-age/space-age.cut" | ||
], | ||
"example": [ | ||
".meta/proof.ci.cob" | ||
], | ||
"invalidator": [ | ||
"test.sh", | ||
"test.ps1" | ||
] | ||
}, | ||
"blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", | ||
"source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", | ||
"source_url": "https://pine.fm/LearnToProgram/?Chapter=01" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
IDENTIFICATION DIVISION. | ||
PROGRAM-ID. SPACE-AGE. | ||
AUTHOR. kapitaali. | ||
ENVIRONMENT DIVISION. | ||
DATA DIVISION. | ||
WORKING-STORAGE SECTION. | ||
01 WS-INPUT PIC 9(30). | ||
01 WS-WHICH-PLANET PIC X(30). | ||
01 WS-RESULT PIC 9(4)V99. | ||
01 WS-ERROR PIC X(30). | ||
01 TEMP PIC 9(4)V99. | ||
|
||
PROCEDURE DIVISION. | ||
|
||
ROUNDS-TO. | ||
COMPUTE TEMP ROUNDED = WS-INPUT / 31557600. | ||
EVALUATE WS-WHICH-PLANET | ||
WHEN "Mercury" | ||
COMPUTE TEMP ROUNDED = TEMP / 0.2408467 | ||
WHEN "Venus" | ||
COMPUTE TEMP = TEMP / 0.61519726 | ||
WHEN "Earth" | ||
COMPUTE TEMP ROUNDED = TEMP | ||
WHEN "Mars" | ||
COMPUTE TEMP ROUNDED = TEMP / 1.8808158 | ||
WHEN "Jupiter" | ||
COMPUTE TEMP ROUNDED = TEMP / 11.862615 | ||
WHEN "Saturn" | ||
COMPUTE TEMP ROUNDED = TEMP / 29.447498 | ||
WHEN "Uranus" | ||
COMPUTE TEMP ROUNDED = TEMP / 84.016846 | ||
WHEN "Neptune" | ||
COMPUTE TEMP ROUNDED = TEMP / 164.79132 | ||
WHEN OTHER | ||
MOVE "not a planet" TO WS-ERROR | ||
END-EVALUATE. | ||
MOVE TEMP TO WS-RESULT. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This file is a copy of the | ||
# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. | ||
# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. | ||
|
||
# set -eo pipefail | ||
|
||
readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' | ||
|
||
case "$(uname)" in | ||
Darwin*) os='mac' ;; | ||
Linux*) os='linux' ;; | ||
Windows*) os='windows' ;; | ||
MINGW*) os='windows' ;; | ||
MSYS_NT-*) os='windows' ;; | ||
*) os='linux' ;; | ||
esac | ||
|
||
case "${os}" in | ||
windows*) ext='.exe' ;; | ||
*) ext='' ;; | ||
esac | ||
|
||
arch="$(uname -m)" | ||
|
||
curlopts=( | ||
--silent | ||
--show-error | ||
--fail | ||
--location | ||
--retry 3 | ||
) | ||
|
||
if [[ -n "${GITHUB_TOKEN}" ]]; then | ||
curlopts+=(--header "authorization: Bearer ${GITHUB_TOKEN}") | ||
fi | ||
|
||
suffix="${os}-${arch}${ext}" | ||
|
||
get_download_url() { | ||
curl "${curlopts[@]}" --header 'Accept: application/vnd.github.v3+json' "${LATEST}" | | ||
grep "\"browser_download_url\": \".*/download/.*/cobol-check.*${suffix}\"$" | | ||
cut -d'"' -f4 | ||
} | ||
|
||
main() { | ||
if [[ -d ./bin ]]; then | ||
output_dir="./bin" | ||
elif [[ $PWD == */bin ]]; then | ||
output_dir="$PWD" | ||
else | ||
echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 | ||
return 1 | ||
fi | ||
|
||
output_path="${output_dir}/cobolcheck${ext}" | ||
download_url="$(get_download_url)" | ||
curl "${curlopts[@]}" --output "${output_path}" "${download_url}" | ||
chmod +x "${output_path}" | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This file is a copy of the | ||
# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. | ||
# Please submit bugfixes/improvements to the above file to ensure that all tracks | ||
# benefit from the changes. | ||
|
||
$ErrorActionPreference = "Stop" | ||
$ProgressPreference = "SilentlyContinue" | ||
|
||
$requestOpts = @{ | ||
Headers = If ($env:GITHUB_TOKEN) { @{ Authorization = "Bearer ${env:GITHUB_TOKEN}" } } Else { @{ } } | ||
MaximumRetryCount = 3 | ||
RetryIntervalSec = 1 | ||
} | ||
|
||
$arch = If ([Environment]::Is64BitOperatingSystem) { "amd64" } Else { "x86" } | ||
$fileName = "cobol-check-windows-$arch.exe" | ||
|
||
Function Get-DownloadUrl { | ||
$latestUrl = "https://api.github.com/repos/0xE282B0/cobol-check/releases/latest" | ||
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts | ||
| Select-Object -ExpandProperty assets | ||
| Where-Object { $_.browser_download_url -match $FileName } | ||
| Select-Object -ExpandProperty browser_download_url | ||
} | ||
|
||
$downloadUrl = Get-DownloadUrl | ||
$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" | ||
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
# Configuration settings for Cobol Check | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# This configuration - echoed to console when Cobol Check is executed, for information only. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
config.loaded = production | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Prefix for field names and paragraph names in the test management code that cobol-check | ||
# inserts into programs to be tested. The default is "UT-". If this conflicts with names | ||
# in the programs to be tested, you can override it with a value you specify here. | ||
# The value must be 3 characters or less. Cannot be empty. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.prefix = UT- | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Tags written in the generated test code in the form of a comment, when a code injection starts and ends. | ||
# Default is null, which will prevent the tags from appearing. Any other value will appear as comments | ||
# surrounding the injected code. | ||
# Examples: | ||
# cobolcheck.injectedCodeTag.start = ###INJECT START### | ||
# cobolcheck.injectedCodeTag.end = ###INJECT END### | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.injectedCodeTag.start = null | ||
cobolcheck.injectedCodeTag.end = null | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# A tag written at the start of entities stubbed by default. Recommended value-length <= 4. | ||
# Note: The tag will appear only when cobolcheck stubs lines by default. | ||
# This is the case for CALLs and batch file IO verbs. | ||
# Default is null, which will prevent the tag from appearing. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.stub.comment.tag = null | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Determines if cobolcheck should generate code, such that decimal point is comma. | ||
# The default is "false". The value should be set to "true" if the compiler is set to | ||
# read decimal points as commas. If the cobol source program sets DECIMAL-POINT IS COMMA, | ||
# this configuration will be overwritten. | ||
# Example: 1,385,481.00 (decimalPointIsComma = false) | ||
# Example: 1.385.481,00 (decimalPointIsComma = true) | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.decimalPointIsComma = false | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# If the source program contains rules as the first line follwed by CBL, the given value will be appended | ||
# to this. | ||
# If no CBL is found in source, it will be added along with the given value | ||
# default is null, which will make no changes. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.append.rules = null | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Path for the generated Cobol test code | ||
# Default: ./ | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.test.program.path = ./ | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Suffix to append to the name of each program under test to produce the name of the corresponding | ||
# test program that contains the merged test code. | ||
# Example: For program ABCXYZ4, if suffix is T.CBL then the test program name will be ABCXYZ4T.CBL. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.test.program.name = test.cob | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Path for the generated testsuite parse error log | ||
# Default: ./ | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
testsuite.parser.error.log.path = ./ | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Name of the generated testsuite parse error log file - with extension | ||
# Default: ParserErrorLog.txt | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
testsuite.parser.error.log.name = ParserErrorLog.txt | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# The charset that cobolcheck will use when reading- and writing to files. | ||
# See https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html, for a list of | ||
# valid values. | ||
# Default value for each OS is <default>, which will use the default encoding for the OS. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.file.encoding.linux = default | ||
cobolcheck.file.encoding.macosx = default | ||
cobolcheck.file.encoding.windows = default | ||
cobolcheck.file.encoding.zos = default | ||
cobolcheck.file.encoding.unix = default | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Sets permissions for all files generated by Cobol Check, for all users. | ||
# If read, write and execute permissions are set, all users can perform said actions on all files | ||
# that Cobol Check generates. | ||
# Value can be any permutation of the letters: 'rwx' (read, write, execute) or none - meaning no permissions. | ||
# Default value: rx | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
generated.files.permission.all = rx | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Determines if Cobol Check should run the generated test program. | ||
# Default is true. | ||
# If set to false, Cobol Check will generate the code, but not run it. If more than one program | ||
# is given as a command line option, the generated test file will be overwritten. Thus if set to false, | ||
# only one program should be given at a time. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
cobolcheck.test.run = false | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# These settings are to locate the application code under test in *your* Cobol project directory tree. | ||
# Can be absolute path or relative to project root. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
application.source.directory = src | ||
application.copybook.directory = cpy | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Location of test suite input file(s). This can also be passed on command-line option --test-suite-path. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
test.suite.directory = tst | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Location of test output. File extension is determined by a given format. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
test.results.file = output/testResults | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Determines the format of the test results written to the output file. | ||
# Supported formats: txt, xml, html. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
test.results.format = txt | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Determines the format style of the test results written to the output file. | ||
# The style controls the hierarchy and structure of data and naming of the 'object' that is written | ||
# in a given format. Format: txt and style: directOutput are exclusive. txt cannot use any other style | ||
# than directOutput, and directOutput cannot be used with any other format than txt. | ||
# Other formats and styles can be used interchangeably. | ||
# Supported styles: directOutput, JUnit, tableDocument, tableEmbed | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
test.results.format.style = directOutput | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# If application source filenames have a suffix, specify it here without the period or dot. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
application.source.filename.suffix = CBL,cbl,COB,cob | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# If application copybook filenames have a suffix, specify it here without the period or dot | ||
# e.g. application.copybook.filename.suffix = CBL | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
application.copybook.filename.suffix = CBL,cbl,COB,cob | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Optional override of system default Locale for log messages and exception messages. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
#locale.language = ja | ||
#locale.country = | ||
#locale.variant = | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Cobol Check concatenates multiple test suite input files into a single file for the Generator. | ||
# This is the relative or absolute path of the concatenated file. If not specified, the default | ||
# is "./ALLTESTS" relative to the directory in which Cobol Check was started. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
concatenated.test.suites = ./ALLTESTS | ||
|
||
#--------------------------------------------------------------------------------------------------------------------- | ||
# Shell scripts and JCL files for executing your test suites. | ||
# Cobol Check will invoke one of these after creating the copy of the program under test that contains | ||
# test code generated from your test suites. | ||
# Unix and Mac OS X are both treated as unix. Most unices can run the linux script. | ||
# Unix is the default. | ||
# You can write custom scripts/JCL for your environment, for instance if you are using a different Cobol compiler. | ||
# The first element in these names reflects the first few characters returned by Java's System.getProperty("os.name"). | ||
# Cobol Check will select one of these entries based on which platform it thinks it's running on. | ||
#--------------------------------------------------------------------------------------------------------------------- | ||
|
||
cobolcheck.script.directory = scripts | ||
linux.process = linux_gnucobol_run_tests | ||
osx.process = linux_gnucobol_run_tests | ||
freebsd.process = linux_gnucobol_run_tests | ||
windows.process = windows_gnucobol_run_tests.cmd | ||
zos.process = | ||
unix.process = linux_gnucobol_run_tests |
Oops, something went wrong.