Skip to main content
deleted 252 characters in body
Source Link
chunes
  • 26.8k
  • 3
  • 24
  • 53

Factor + math.extras math.unicode project-euler.common, 8383 81 bytes

[ 0 swap [ [ dup+ ,] keep number>digits differences vabs digits>number ] until-zero ] f make Σ ]

Attempt This Online!Attempt This Online!

  • [ ... ] f make Allows us to build a sequence. f is the exemplar and is a shorter way to write {0 }, meaning the result should be an array. Inside the make quotation, ,swap adds an element toInitialize the sequence we're buildingsum.
  • [ ... ] until-zero Call a quotation until its result is 0, dropping the 0 from the stack.
  • dup[ ,+ ] keep Add the current numbersummand to the sequence we're buildingour sum.
  • number>digits differences vabs digits>number Get the next summand.
  • Σ Sum of a sequence.

Factor + math.extras math.unicode project-euler.common, 83 bytes

[ [ [ dup , number>digits differences vabs digits>number ] until-zero ] f make Σ ]

Attempt This Online!

  • [ ... ] f make Allows us to build a sequence. f is the exemplar and is a shorter way to write { }, meaning the result should be an array. Inside the make quotation, , adds an element to the sequence we're building.
  • [ ... ] until-zero Call a quotation until its result is 0, dropping the 0 from the stack.
  • dup , Add the current number to the sequence we're building.
  • number>digits differences vabs digits>number Get the next summand.
  • Σ Sum of a sequence.

Factor + math.extras project-euler.common, 83 81 bytes

[ 0 swap [ [ + ] keep number>digits differences vabs digits>number ] until-zero ]

Attempt This Online!

  • 0 swap Initialize the sum.
  • [ ... ] until-zero Call a quotation until its result is 0, dropping the 0 from the stack.
  • [ + ] keep Add the current summand to our sum.
  • number>digits differences vabs digits>number Get the next summand.
Source Link
chunes
  • 26.8k
  • 3
  • 24
  • 53

Factor + math.extras math.unicode project-euler.common, 83 bytes

[ [ [ dup , number>digits differences vabs digits>number ] until-zero ] f make Σ ]

Attempt This Online!

  • [ ... ] f make Allows us to build a sequence. f is the exemplar and is a shorter way to write { }, meaning the result should be an array. Inside the make quotation, , adds an element to the sequence we're building.
  • [ ... ] until-zero Call a quotation until its result is 0, dropping the 0 from the stack.
  • dup , Add the current number to the sequence we're building.
  • number>digits differences vabs digits>number Get the next summand.
  • Σ Sum of a sequence.