Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grains error message and test cases updated #67

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions exercises/practice/grains/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Independent of other languages

Batch supports only up to 31 bits so we need to use a different approach to solve, Instead of writing code according to the range 1 to 64, the range `1 to 31` is important for us.
2 changes: 1 addition & 1 deletion exercises/practice/grains/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The king promised to pay whatever the servant could dream up.
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
One grain on the first square of a chess board, with the number of grains doubling on each successive square.

There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).
There are 64 _(But because of language limitations, we take 31 in batch testing)_ squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).

Write code that shows:

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/grains/.meta/Example.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ setlocal EnableDelayedExpansion
set "input=%~1"

if %input% LSS 1 (
echo square must be between 1 and 64
echo square must be between 1 and 31
exit /b 1
)

if %input% GTR 64 (
echo square must be between 1 and 64
if %input% GTR 31 (
echo square must be between 1 and 31
exit /b 1
)

Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/grains/GrainsTest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if "%1" == "test-runner" (
set "if_failed=Test failed: grains on square 31."
CALL :Assert "31"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square 0 is invalid."
CALL :Assert "0"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: negative square is invalid."
CALL :Assert "-1"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square greater than 64 is invalid."
set "if_failed=Test failed: square greater than 31 is invalid."
CALL :Assert "65"

REM --------------------
Expand Down