How to resolve the algorithm Numbers with equal rises and falls step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Numbers with equal rises and falls step by step in the Quackery programming language

Table of Contents

Problem Statement

When a number is written in base 10,   adjacent digits may "rise" or "fall" as the number is read   (usually from left to right).

Given the decimal digits of the number are written as a series   d:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Numbers with equal rises and falls step by step in the Quackery programming language

Source code in the quackery programming language

  [ [] swap
    [ 10 /mod
      rot join swap
      dup 0 = until ]
    drop ]                    is digits ( n --> [ )

  [ stack ] is rises
  [ stack ] is falls

  [ 0 rises put
    0 falls put
    digits
    behead swap witheach
      [ tuck 2dup < iff
          [ 1 rises tally
            2drop ] done
        > if
          [ 1 falls tally ] ]
    drop
    rises take
    falls take = ]            is equal ( n --> b )

  [] 0
  [ 1+ dup equal if
      [ tuck join swap ]
    over size 200 = until ]
  drop
  echo
  cr cr
  0 0
  [ 1+ dup equal if
      [ dip 1+ ]
    over 10000000 = until ]
  nip
  echo

  

You may also check:How to resolve the algorithm Gray code step by step in the Julia programming language
You may also check:How to resolve the algorithm Cholesky decomposition step by step in the Groovy programming language
You may also check:How to resolve the algorithm Statistics/Basic step by step in the Stata programming language
You may also check:How to resolve the algorithm Wordle comparison step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Picat programming language