Paste: aoc15

Author: jon
Mode: factor
Date: Fri, 15 Dec 2017 16:33:06
Plain Text |
! Copyright (C) 2017 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math ;
IN: aoc.2017.15

: p1 ( -- n )
0 883 879
40000000 [
  16807 48271
  [ * 2147483647 mod ] bi-curry@ bi*
  2dup [ 0xffff bitand ] bi@ = [ [ 1 + ] 2dip ] when
] times 2drop ;

: p2 ( -- n )
0 883 879
5000000 [
  4 8 [ dupd mod 0 = ] bi-curry@ 
  16807 48271 [ * 2147483647 mod ] bi-curry@
  [ do until ] bi-curry@ bi-curry*
  bi*
  2dup [ 0xffff bitand ] bi@ = [ [ 1 + ] 2dip ] when
] times 2drop ;

New Annotation

Summary:
Author:
Mode:
Body: