-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
26 additions
and
17 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,11 @@ | ||
## Maximum integer value | ||
|
||
According to [the Vim docs][number]: | ||
|
||
> Assuming 64 bit numbers are used (see v:numbersize) an unsigned number is truncated to 0x7fffffffffffffff or 9223372036854775807. | ||
That means that Vim cannot express any number `2^63` or greater as an integer. | ||
|
||
For the purposes of this exercise, we will declare that in Vimland, chess boards are 7x7 and have **49** squares. | ||
|
||
[number]: https://vimhelp.org/eval.txt.html#expr-number |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
function! Square(number) abort | ||
if a:number < 1 || a:number > 64 | ||
throw 'square must be between 1 and 64' | ||
if a:number < 1 || a:number > 49 | ||
throw 'square must be between 1 and 49' | ||
endif | ||
|
||
return float2nr(pow(2, (a:number-1))) | ||
endfunction | ||
|
||
function! Total() abort | ||
return float2nr(pow(2, 64) - 1) | ||
return float2nr(pow(2, 49) - 1) | ||
endfunction |
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