This file contains hidden or 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
( easter.fs 2015-02-21T18.23 by fbwright ) | |
( An implementation of the Butcher's algorithm ) | |
: easter { year -- year month day } | |
year 19 mod { a } year 100 / { b } year 100 mod { c } | |
19 a * b + b 4 / - 15 + b b 8 + 25 / - 1 + 3 / - 30 mod { d } | |
32 b 4 mod 2 * + c 4 / 2 * + d - c 4 mod - 7 mod { e } | |
d e + 114 + d 11 * a + e 22 * + 451 / 7 * - { f } | |
f 31 mod 1+ ( day ) f 31 / ( month ) year ; | |
: test ( -- ) cr | |
2014 easter . . . cr ( Should be 2014 4 20 ) |
This file contains hidden or 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
( ch202.fs 2015-02-22T19.49 by fbwright ) | |
1024 CONSTANT buffer-size | |
CREATE buffer-in buffer-size CHARS ALLOT | |
CREATE index-in 1 CELLS ALLOT | |
CREATE buffer-out buffer-size 8 / CHARS ALLOT | |
CREATE index-out 1 CELLS ALLOT | |
( Iterates over buffer-in: every 8 cells it pushes a char to ) | |
( buffer-out and increases index-out by 1 ) | |
: parse-buffer ( -- ) 0 index-out ! 0 index-in @ 0 u+do | |
7 i 8 mod - buffer-in i + c@ case |
This file contains hidden or 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
## [2015-01-12] Challenge #197 [Easy] ISBN Validator | |
## 2015-01-21 15:08 - by Frankie Brogan | |
import strutils, parseopt2, version, strfmt, math, unittest | |
type | |
TISBNKind* = enum | |
ISBN10, ISBN13 | |
TISBN* = object | |
case kind*: TISBNKind | |
of ISBN10: isbn_10*: array[0..9, int] | |
of ISBN13: isbn_13*: array[0..12, int] |
NewerOlder