challenges

my solutions to various "programming challenge" problems
git clone https://wehaveforgeathome.hates.computer/challenges.git
Log | Files | Refs | LICENSE

009.pez (416B)


      1 #! /usr/bin/env pez
      2 # real  0m0.032s
      3 # user  0m0.032s
      4 # sys 0m0.004s
      5 
      6 : square dup * ;
      7 
      8 : pythagoreanTriplet? ( a b c -- a b c bool )
      9   dup square 2 pick square 4 pick square + =
     10 ;
     11 
     12 : findTriplet
     13   999 335 do
     14     i 1000 over 1 + - 333 swap do
     15       i 2dup + 1000 swap -
     16         pythagoreanTriplet? if
     17           * * . quit
     18         else
     19           drop drop
     20         then
     21     -1 +loop
     22     drop
     23   -1 +loop
     24 ;
     25 
     26 findTriplet