function Invoke-Rpn
{
  <#
    .SYNOPSIS
        A stack-based evaluator for an expression in reverse Polish notation.
    .DESCRIPTION
        A stack-based evaluator for an expression in reverse Polish notation.

        All methods in the Math and Decimal classes are available.
    .PARAMETER Expression
        A space separated, string of tokens.
    .PARAMETER DisplayState
        This switch shows the changes in the stack as each individual token is processed as a table.
    .EXAMPLE
        Invoke-Rpn -Expression "3 4 Max"
    .EXAMPLE
        Invoke-Rpn -Expression "3 4 Log2"
    .EXAMPLE
        Invoke-Rpn -Expression "3 4 2 * 1 5 - 2 3 ^ ^ / +"
    .EXAMPLE
        Invoke-Rpn -Expression "3 4 2 * 1 5 - 2 3 ^ ^ / +" -DisplayState
#>
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory=$true)]
        [AllowEmptyString()]
        [string]
        $Expression,

        [Parameter(Mandatory=$false)]
        [switch]
        $DisplayState
    )
    Begin
    {
        function Out-State ([System.Collections.Stack]$Stack)
        {
            $array = $Stack.ToArray()
            [Array]::Reverse($array)
            $array | ForEach-Object -Process { Write-Host ("{0,-8:F3}" -f $_) -NoNewline } -End { Write-Host }
        }

        function New-RpnEvaluation
        {
            $stack = New-Object -Type System.Collections.Stack

            $shortcuts = @{
                "+" = "Add"; "-" = "Subtract"; "/" = "Divide"; "*" = "Multiply"; "%" = "Remainder"; "^" = "Pow"
            }

            :ARGUMENT_LOOP foreach ($argument in $args)
            {
                if ($DisplayState -and $stack.Count)
                {
                    Out-State $stack
                }

                if ($shortcuts[$argument])
                {
                    $argument = $shortcuts[$argument]
                }

                try
                {
                    $stack.Push([decimal]$argument)
                    continue
                }
                catch
                {
                }

                $argCountList = $argument -replace "(\D+)(\d*)",‘$2’
                $operation = $argument.Substring(0, $argument.Length – $argCountList.Length)

                foreach($type in [Decimal],[Math])
                {
                    if ($definition = $type::$operation)
                    {
                        if (-not $argCountList)
                        {
                            $argCountList = $definition.OverloadDefinitions |
                                Foreach-Object { ($_ -split ", ").Count } |
                                Sort-Object -Unique
                        }

                        foreach ($argCount in $argCountList)
                        {
                            try
                            {
                                $methodArguments = $stack.ToArray()[($argCount–1)..0]
                                $result = $type::$operation.Invoke($methodArguments)

                                $null = 1..$argCount | Foreach-Object { $stack.Pop() }

                                $stack.Push($result)

                                continue ARGUMENT_LOOP
                            }
                            catch
                            {
                                ## If error, try with the next number of arguments
                            }
                        }
                    }
                }
            }

            if ($DisplayState -and $stack.Count)
            {
                Out-State $stack
                if ($stack.Count)
                {
                    Write-Host "`nResult = $($stack.Peek())"
                }
            }
            else
            {
                $stack
            }
        }
    }
    Process
    {
        Invoke-Expression -Command "New-RpnEvaluation $Expression"
    }
    End
    {
    }
}

Invoke-Rpn -Expression "3 4 2 * 1 5 - 2 3 ^ ^ / +" -DisplayState


rpn(L) :-
	writeln('Token  Action                             Stack'),
	parse(L, [],[X] ,[]),
	format('~nThe final output value is ~w~n', [X]).

% skip spaces
parse([X|L], St) -->
	{char_type(X, white)},
	parse(L, St).

% detect operators
parse([Op|L], [Y, X | St]) -->
	{ is_op(Op, X, Y, V),
	  writef('    %s', [[Op]]),
	  with_output_to(atom(Str2), writef('Apply %s on top of stack', [[Op]])),
	  writef('  %35l', [Str2]),
	  writef('%w\n', [[V | St]])},
	parse(L, [V | St]).

% detect number
parse([N|L], St) -->
	{char_type(N, digit)},
	parse_number(L, [N], St).

% string is finished
parse([], St) --> St.

% compute numbers
parse_number([N|L], NC, St) -->
	{char_type(N, digit)},
	parse_number(L, [N|NC], St).

parse_number(S, NC, St) -->
	{ reverse(NC, RNC),
	  number_chars(V, RNC),
	  writef('%5r', [V]),
	  with_output_to(atom(Str2), writef('Push num %w on top of stack', [V])),
	  writef('  %35l', [Str2]),
	  writef('%w\n', [[V | St]])},
	parse(S, [V|St]).

% defining operations
is_op(42, X, Y, V) :-	V is X*Y.
is_op(43, X, Y, V) :-	V is X+Y.
is_op(45, X, Y, V) :-	V is X-Y.
is_op(47, X, Y, V) :-	V is X/Y.
is_op(94, X, Y, V) :-	V is X**Y.


def op_pow(stack):
    b = stack.pop(); a = stack.pop()
    stack.append( a ** b )
def op_mul(stack):
    b = stack.pop(); a = stack.pop()
    stack.append( a * b )
def op_div(stack):
    b = stack.pop(); a = stack.pop()
    stack.append( a / b )
def op_add(stack):
    b = stack.pop(); a = stack.pop()
    stack.append( a + b )
def op_sub(stack):
    b = stack.pop(); a = stack.pop()
    stack.append( a - b )
def op_num(stack, num):
    stack.append( num )

ops = {
 '^': op_pow,
 '*': op_mul,
 '/': op_div,
 '+': op_add,
 '-': op_sub,
 }

def get_input(inp = None):
    'Inputs an expression and returns list of tokens'

    if inp is None:
        inp = input('expression: ')
    tokens = inp.strip().split()
    return tokens

def rpn_calc(tokens):
    stack = []
    table = ['TOKEN,ACTION,STACK'.split(',')]
    for token in tokens:
        if token in ops:
            action = 'Apply op to top of stack'
            ops[token](stack)
            table.append( (token, action, ' '.join(str(s) for s in stack)) )
        else:
            action = 'Push num onto top of stack'
            op_num(stack, eval(token))
            table.append( (token, action, ' '.join(str(s) for s in stack)) )
    return table

if __name__ == '__main__':
    rpn = '3 4 2 * 1 5 - 2 3 ^ ^ / +'
    print( 'For RPN expression: %r\n' % rpn )
    rp = rpn_calc(get_input(rpn))
    maxcolwidths = [max(len(y) for y in x) for x in zip(*rp)]
    row = rp[0]
    print( ' '.join('{cell:^{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row)))
    for row in rp[1:]:
        print( ' '.join('{cell:<{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row)))

    print('\n The final output value is: %r' % rp[-1][2])


[ stack ]                                 is switch.arg (     --> [ )

[ switch.arg put ]                        is switch     (   x -->   )

[ switch.arg release ]                    is otherwise  (     -->   )

[ switch.arg share
  != iff ]else[ done
  otherwise
  ]'[ do ]done[ ]                         is case       (   x -->   )

[ say "Applying: "
  swap echo$ sp
  temp take
  temp take
  swap rot do
  temp put ]                              is apply      ( $ x -->   )

[ say "Pushing:  " dup echo$ sp
  $->n drop temp put ]                    is isnumber   (   $ -->   )

[ temp copy echo cr ]                     is display    (     -->   )

[ nest$ witheach
    [ dup switch
      [ $ '+' case [ ' +  apply ]
        $ '-' case [ ' -  apply ]
        $ '*' case [ ' *  apply ]
        $ '/' case [ ' /  apply ]
        $ '^' case [ ' ** apply ]
        otherwise  [ isnumber ] ]
      display ]
  temp take ]                             is rpncalc    (   $ --> n )

$ "3 4 2 * 1 5 - 2 3 ^ ^ / +" rpncalc
say "Result: " echo


#lang racket

(define (calculate-RPN expr)
  (for/fold ([stack '()]) ([token expr])
    (printf "~a\t -> ~a~N" token stack)
    (match* (token stack)
     [((? number? n) s) (cons n s)]
     [('+ (list x y s ___)) (cons (+ x y) s)]
     [('- (list x y s ___)) (cons (- y x) s)]
     [('* (list x y s ___)) (cons (* x y) s)]
     [('/ (list x y s ___)) (cons (/ y x) s)]
     [('^ (list x y s ___)) (cons (expt y x) s)]
     [(x s) (error "calculate-RPN: Cannot calculate the expression:"
                   (reverse (cons x s)))])))


my $proggie = '3 4 2 * 1 5 - 2 3 ^ ^ / +';

class RPN is Array {

    method binop(&op) { self.push: self.pop R[&op] self.pop }

    method run($p) {
        for $p.words {
            say "$_ ({self})";
            when /\d/ { self.push: $_ }
            when '+'  { self.binop: &[+] }
            when '-'  { self.binop: &[-] }
            when '*'  { self.binop: &[*] }
            when '/'  { self.binop: &[/] }
            when '^'  { self.binop: &[**] }
            default   { die "$_ is bogus" }
        }
        say self;
    }
}

RPN.new.run($proggie);


/* REXX ***************************************************************
* 09.11.2012 Walter Pachl  translates from PL/I
**********************************************************************/
fid='rpl.txt'
ex=linein(fid)
Say 'Input:' ex
/* ex=' 3 4 2 * 1 5 - 2 3 ^ ^ / +' */
Numeric Digits 15
expr=''
st.=0
Say 'Stack contents:'
do While ex<>''
  Parse Var ex ch +1 ex
  expr=expr||ch;
  if ch<>' ' then do
    select
      When pos(ch,'0123456789')>0 Then Do
        Call stack ch
        Iterate
        End
      when ch='+' Then do; operand=getstack(); st.sti = st.sti +  operand; end;
      when ch='-' Then do; operand=getstack(); st.sti = st.sti -  operand; end;
      when ch='*' Then do; operand=getstack(); st.sti = st.sti *  operand; end;
      when ch='/' Then do; operand=getstack(); st.sti = st.sti /  operand; end;
      when ch='^' Then do; operand=getstack(); st.sti = st.sti ** operand; end;
      end;
    call show_stack
    end
  end
Say 'The reverse polish expression = 'expr
Say 'The evaluated expression = 'st.1
Exit
stack: Procedure Expose st.
/* put the argument on top of the stack */
  z=st.0+1
  st.z=arg(1)
  st.0=z
  Return
getstack: Procedure Expose st. sti
/* remove and return the stack's top element */
  z=st.0
  stk=st.z
  st.0=st.0-1
  sti=st.0
  Return stk
show_stack: procedure Expose st.
/* show the stack's contents */
  ol=''
  do i=1 To st.0
    ol=ol format(st.i,5,10)
    End
  Say ol
  Return


rpn = RPNExpression("3 4 2 * 1 5 - 2 3 ^ ^ / +")
value = rpn.eval


prn$ = "3 4 2 * 1 5 - 2 3 ^ ^ / + "

j = 0
while word$(prn$,i + 1," ") <> ""
i = i + 1
  n$ = word$(prn$,i," ")
  if n$ < "0" or n$ > "9" then
    num1   = val(word$(stack$,s," "))
    num2   = val(word$(stack$,s-1," "))
    n      = op(n$,num2,num1)
    s      = s - 1
    stack$ = stk$(stack$,s -1,str$(n))
   print "Push Opr ";n$;" to stack:  ";stack$
 else
  s = s + 1
  stack$ = stack$ + n$ + " "
  print "Push Num ";n$;" to stack:  ";stack$
end if
wend

function stk$(stack$,s,a$)
for i = 1 to s
  stk$ = stk$ + word$(stack$,i," ") + " "
next i
stk$ = stk$ + a$ + " "
end function

FUNCTION op(op$,a,b)
if op$ = "*" then op = a * b
if op$ = "/" then op = a / b
if op$ = "^" then op = a ^ b
if op$ = "+" then op = a + b
if op$ = "-" then op = a - b
end function


fn rpn(text: &str) -> f64 {
    let tokens = text.split_whitespace();
    let mut stack: Vec<f64> = vec![];
    println!("input operation stack");

    for token in tokens {
        print!("{:^5} ", token);
        match token.parse() {
            Ok(num) => {
                stack.push(num);
                println!("push      {:?}", stack);
            }
            Err(_) => {
                match token {
                    "+" => {
                        let b = stack.pop().expect("missing first operand");
                        let a = stack.pop().expect("missing second operand");
                        stack.push(a + b);
                    }
                    "-" => {
                        let b = stack.pop().expect("missing first operand");
                        let a = stack.pop().expect("missing second operand");
                        stack.push(a - b);
                    }
                    "*" => {
                        let b = stack.pop().expect("missing first operand");
                        let a = stack.pop().expect("missing second operand");
                        stack.push(a * b);
                    }
                    "/" => {
                        let b = stack.pop().expect("missing first operand");
                        let a = stack.pop().expect("missing second operand");
                        stack.push(a / b);
                    }
                    "^" => {
                        let b = stack.pop().expect("missing first operand");
                        let a = stack.pop().expect("missing second operand");
                        stack.push(a.powf(b));
                    }
                    _ => panic!("unknown operator {}", token),
                }
                println!("calculate {:?}", stack);
            }
        }
    }

    stack.pop().unwrap_or(0.0)
}

fn main() {
    let text = "3 4 2 * 1 5 - 2 3 ^ ^ / +";

    println!("\nresult: {}", rpn(text));
}


object RPN {
  val PRINT_STACK_CONTENTS: Boolean = true

  def main(args: Array[String]): Unit = {
    val result = evaluate("3 4 2 * 1 5 - 2 3 ^ ^ / +".split(" ").toList)
    println("Answer: " + result)
  }

  def evaluate(tokens: List[String]): Double = {
    import scala.collection.mutable.Stack
    val stack: Stack[Double] = new Stack[Double]
    for (token <- tokens) {
      if (isOperator(token)) token match {
        case "+" => stack.push(stack.pop + stack.pop)
        case "-" => val x = stack.pop; stack.push(stack.pop - x)
        case "*" => stack.push(stack.pop * stack.pop)
        case "/" => val x = stack.pop; stack.push(stack.pop / x)
        case "^" => val x = stack.pop; stack.push(math.pow(stack.pop, x))
        case _ => throw new RuntimeException( s""""$token" is not an operator""")
      }
      else stack.push(token.toDouble)

      if (PRINT_STACK_CONTENTS) {
        print("Input: " + token)
        print(" Stack: ")
        for (element <- stack.seq.reverse) print(element + " ");
        println("")
      }
    }

    stack.pop
  }

  def isOperator(token: String): Boolean = {
    token match {
      case "+" => true; case "-" => true; case "*" => true; case "/" => true; case "^" => true
      case _ => false
    }
  }
}


var proggie = '3 4 2 * 1 5 - 2 3 ^ ^ / +'

class RPN(arr=[]) {

    method binop(op) {
        var x = arr.pop
        var y = arr.pop
        arr << y.(op)(x)
    }

    method run(p) {
        p.each_word { |w|
            say "#{w} (#{arr})"
            given (w) {
                when (/\d/) {
                    arr << Num(w)
                }
                when (<+ - * />) {
                    self.binop(w)
                }
                when ('^') {
                    self.binop('**')
                }
                default {
                    die "#{w} is bogus"
                }
            }
        }
        say arr[0]
    }
}

RPN.new.run(proggie)


let opa = [
    "^": (prec: 4, rAssoc: true),
    "*": (prec: 3, rAssoc: false),
    "/": (prec: 3, rAssoc: false),
    "+": (prec: 2, rAssoc: false),
    "-": (prec: 2, rAssoc: false),
]

func rpn(tokens: [String]) -> [String] {
    var rpn : [String] = []
    var stack : [String] = [] // holds operators and left parenthesis

    for tok in tokens {
        switch tok {
        case "(":
            stack += [tok] // push "(" to stack
        case ")":
            while !stack.isEmpty {
                let op = stack.removeLast() // pop item from stack
                if op == "(" {
                    break // discard "("
                } else {
                    rpn += [op] // add operator to result
                }
            }
        default:
            if let o1 = opa[tok] { // token is an operator?
                for op in stack.reverse() {
                    if let o2 = opa[op] {
                        if !(o1.prec > o2.prec || (o1.prec == o2.prec && o1.rAssoc)) {
                            // top item is an operator that needs to come off
                            rpn += [stack.removeLast()] // pop and add it to the result
                            continue
                        }
                    }
                    break
                }

                stack += [tok] // push operator (the new one) to stack
            } else { // token is not an operator
                rpn += [tok] // add operand to result
            }
        }
    }

    return rpn + stack.reverse()
}

func parseInfix(e: String) -> String {
    let tokens = e.characters.split{ $0 == " " }.map(String.init)
    return rpn(tokens).joinWithSeparator(" ")
}

var input : String

input = "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3"
"infix: \(input)"
"postfix: \(parseInfix(input))"


# Helper
proc pop stk {
    upvar 1 $stk s
    set val [lindex $s end]
    set s [lreplace $s end end]
    return $val
}

proc evaluate rpn {
    set stack {}
    foreach token $rpn {
	set act "apply"
	switch $token {
	    "^" {
		# Non-commutative operation
		set a [pop stack]
		lappend stack [expr {[pop stack] ** $a}]
	    }
	    "/" {
		# Non-commutative, special float handling
		set a [pop stack]
		set b [expr {[pop stack] / double($a)}]
		if {$b == round($b)} {set b [expr {round($b)}]}
		lappend stack $b
	    }
	    "*" {
		# Commutative operation
		lappend stack [expr {[pop stack] * [pop stack]}]
	    }
	    "-" {
		# Non-commutative operation
		set a [pop stack]
		lappend stack [expr {[pop stack] - $a}]
	    }
	    "+" {
		# Commutative operation
		lappend stack [expr {[pop stack] + [pop stack]}]
	    }
	    default {
		set act "push"
		lappend stack $token
	    }
	}
	puts "$token\t$act\t$stack"
    }
    return [lindex $stack end]
}

puts [evaluate {3 4 2 * 1 5 - 2 3 ^ ^ / +}]


Global stack$

Function RPN(expr$)
Debug.Print "Expression:"
Debug.Print expr$
Debug.Print "Input", "Operation", "Stack after"

stack$ = ""
token$ = "#"
i = 1
token$ = Split(expr$)(i - 1) 'split is base 0
token2$ = " " + token$ + " "

Do
    Debug.Print "Token "; i; ": "; token$,
    'operation
    If InStr("+-*/^", token$) <> 0 Then
        Debug.Print "operate",
        op2$ = pop$()
        op1$ = pop$()
        If op1$ = "" Then
            Debug.Print "Error: stack empty for "; i; "-th token: "; token$
            End
        End If

        op1 = Val(op1$)
        op2 = Val(op2$)

        Select Case token$
        Case "+"
            res = CDbl(op1) + CDbl(op2)
        Case "-"
            res = CDbl(op1) - CDbl(op2)
        Case "*"
            res = CDbl(op1) * CDbl(op2)
        Case "/"
            res = CDbl(op1) / CDbl(op2)
        Case "^"
            res = CDbl(op1) ^ CDbl(op2)
        End Select

        Call push2(str$(res))
    'default:number
    Else
        Debug.Print "push",
        Call push2(token$)
    End If
    Debug.Print "Stack: "; reverse$(stack$)
    i = i + 1
    If i > Len(Join(Split(expr, " "), "")) Then
        token$ = ""
    Else
        token$ = Split(expr$)(i - 1) 'base 0
        token2$ = " " + token$ + " "
    End If
Loop Until token$ = ""

Debug.Print
Debug.Print "Result:"; pop$()
'extra$ = pop$()
If stack <> "" Then
    Debug.Print "Error: extra things on a stack: "; stack$
End If
End
End Function

'---------------------------------------
Function reverse$(s$)
    reverse$ = ""
    token$ = "#"
    While token$ <> ""
        i = i + 1
        token$ = Split(s$, "|")(i - 1) 'split is base 0
        reverse$ = token$ & " " & reverse$
    Wend
End Function
'---------------------------------------
Sub push2(s$)
    stack$ = s$ + "|" + stack$ 'stack
End Sub

Function pop$()
    'it does return empty on empty stack
    pop$ = Split(stack$, "|")(0)
    stack$ = Mid$(stack$, InStr(stack$, "|") + 1)
End Function


import math

const (
    supported_operations = ['+', '-', '*', '/', '^']
    max_depth = 256
)

struct Stack {
mut:
	data  []f32 = [f32(0)].repeat(max_depth)
	depth int
}

fn (mut stack Stack) push(value f32) {
	if stack.depth >= max_depth {
		println('Stack Overflow!!')
		return
	}
	stack.data[stack.depth] = value
	stack.depth++
}

fn (mut stack Stack) pop() ?f32 {
	if stack.depth > 0 {
		stack.depth--
		result := stack.data[stack.depth]
		return result
	}
	return error('Stack Underflow!!')
}

fn (stack Stack) peek() ?f32 {
	if stack.depth > 0 {
		result := stack.data[0]
		return result
	}
	return error('Out of Bounds...')
}

fn (mut stack Stack) rpn(input string) ?f32 {
	println('Input: $input')
	tokens := input.split(' ')
	mut a := f32(0)
	mut b := f32(0)
	println('Token     Stack')
	for token in tokens {
		if token.str.is_digit() {
			stack.push(token.f32())
		} else if token in supported_operations {
			b = stack.pop() or { f32(0) }
			a = stack.pop() or { f32(0) }
			match token {
				'+' {
					stack.push(a + b)
				}
				'-' {
					stack.push(a - b)
				}
				'*' {
					stack.push(a * b)
				}
				'/' {
					stack.push(a / b)
				}
				'^' {
					stack.push(f32(math.pow(a, b)))
				}
				else {
					println('Oofffff')
				}
			}
		}
		print('${token:5s}     ')
		for i := 0; i < stack.depth; i++ {
			if i == stack.depth - 1 {
				println('${stack.data[i]:0.6f} |>')
			} else {
				print('${stack.data[i]:0.6f}, ')
			}
		}
	}
	return stack.peek()
}

fn main() {
	mut calc := Stack{}
	result := calc.rpn('3 4 2 * 1 5 - 2 3 ^ ^ / +') or { return }
	println('\nResult:   $result')
}


import "/seq" for Stack

var rpnCalculate = Fn.new { |expr|
    if (expr == "") Fiber.abort("Expression cannot be empty.")
    System.print("For expression = %(expr)\n")
    System.print("Token           Action             Stack")
    var tokens = expr.split(" ").where { |t| t != "" }
    var stack = Stack.new()
    for (token in tokens) {
        var d = Num.fromString(token)
        if (d) {
            stack.push(d)
            System.print(" %(d)     Push num onto top of stack  %(stack)")
        } else if ((token.count > 1) || !"+-*/^".contains(token)) {
            Fiber.abort("%(token) is not a valid token.")
        } else if (stack.count < 2) {
            Fiber.abort("Stack contains too few operands.")
        } else {
            var d1 = stack.pop()
            var d2 = stack.pop()
            stack.push(token == "+" ? d2 + d1 :
                       token == "-" ? d2 - d1 :
                       token == "*" ? d2 * d1 :
                       token == "/" ? d2 / d1 : d2.pow(d1))
            System.print(" %(token)     Apply op to top of stack    %(stack)")
        }
    }
    System.print("\nThe final value is %(stack.pop())")
}

var expr = "3 4 2 * 1 5 - 2 3 ^ ^ / +"
rpnCalculate.call(expr)


Function RPN(expr As String) As String

  Dim tokenArray() As String
  Dim stack() As String

  Dim Wert1 As Double
  Dim Wert2 As Double

  'Initialize array (removed later)
  ReDim tokenArray(1)
  ReDim stack(1)

  tokenArray = Split(expr, " ")

  Dim i As integer
  i = 0

  While i <= tokenArray.Ubound

    If  tokenArray(i) = "+" Then
      Wert2 = Val(stack.pop)
      Wert1 = Val(stack.pop)
      stack.Append(Str(Wert1+Wert2))
    ElseIf tokenArray(i) = "-" Then
      Wert2 = Val(stack.pop)
      Wert1 = Val(stack.pop)
      stack.Append(Str(Wert1-Wert2))
    ElseIf tokenArray(i) = "*" Then
      Wert2 = Val(stack.pop)
      Wert1 = Val(stack.pop)
      stack.Append(Str(Wert1*Wert2))
    ElseIf tokenArray(i) = "/" Then
      Wert2 = Val(stack.pop)
      Wert1 = Val(stack.pop)
      stack.Append(Str(Wert1/Wert2))
    ElseIf tokenArray(i) = "^" Then
      Wert2 = Val(stack.pop)
      Wert1 = Val(stack.pop)
      stack.Append(Str(pow(Wert1,Wert2)))
    Else
      stack.Append(tokenArray(i))
    End If

    i = i +1

  Wend

  Return stack(2)

End Function


var ops=D("^",True,  "*",'*,  "/",'/,  "+",'+,  "-",'-);

fcn parseRPN(e){
   println("\npostfix: ", e);
   stack:=L();
   foreach tok in (e.split()){
      op:=ops.find(tok);
      if(op){
	 y := stack.pop(); x := stack.pop();
	 if(True==op) x=x.pow(y);
	 else	      x=op(x,y);
	 stack.append(x);
      }
      else stack.append(tok.toFloat());
      println(tok," --> ",stack);
   }
   println("result: ", stack[0])
}


# syntax: GAWK -f PANCAKE_NUMBERS.AWK
# converted from C
BEGIN {
    for (i=0; i<4; i++) {
      for (j=1; j<6; j++) {
        n = i * 5 + j
        printf("p(%2d) = %2d  ",n,main(n))
      }
      printf("\n")
    }
    exit(0)
}
function main(n,  adj,gap,sum) {
    gap = 2
    sum = 2
    adj = -1
    while (sum < n) {
      adj++
      gap = gap * 2 - 1
      sum += gap
    }
    return(n + adj)
}


#include <stdio.h>

int pancake(int n) {
    int gap = 2, sum = 2, adj = -1;
    while (sum < n) {
        adj++;
        gap = gap * 2 - 1;
        sum += gap;
    }
    return n + adj;
}

int main() {
    int i, j;
    for (i = 0; i < 4; i++) {
        for (j = 1; j < 6; j++) {
            int n = i * 5 + j;
            printf("p(%2d) = %2d  ", n, pancake(n));
        }
        printf("\n");
    }
    return 0;
}


#include <iomanip>
#include <iostream>

int pancake(int n) {
    int gap = 2, sum = 2, adj = -1;
    while (sum < n) {
        adj++;
        gap = gap * 2 - 1;
        sum += gap;
    }
    return n + adj;
}

int main() {
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < 6; j++) {
            int n = i * 5 + j;
            std::cout << "p(" << std::setw(2) << n << ") = " << std::setw(2) << pancake(n) << "  ";
        }
        std::cout << '\n';
    }
    return 0;
}


include "cowgol.coh";

sub pancake(n: uint8): (r: uint8) is
    var gap: uint8 := 2;
    var sum: uint8 := 2;
    var adj: int8 := -1;

    while sum < n loop
        adj := adj + 1;
        gap := gap * 2 - 1;
        sum := sum + gap;
    end loop;

    r := n + adj as uint8;
end sub;

# print 2-digit number
sub print2(n: uint8) is
    if n<10 then
        print_char(' ');
    else
        print_char(n/10 + '0');
    end if;
    print_char(n%10 + '0');
end sub;

# print item
sub print_item(n: uint8) is
    print("p(");
    print2(n);
    print(") = ");
    print2(pancake(n));
    print("  ");
end sub;

var i: uint8 := 0;
while i < 4 loop
    var j: uint8 := 1;
    while j < 6 loop
        print_item(i*5 + j);
        j := j + 1;
    end loop;
    print_nl();
    i := i + 1;
end loop;


import std.stdio;

int pancake(int n) {
    int gap = 2, sum = 2, adj = -1;
    while (sum < n) {
        adj++;
        gap = 2 * gap - 1;
        sum += gap;
    }
    return n + adj;
}

void main() {
    foreach (i; 0..4) {
        foreach (j; 1..6) {
            int n = 5 * i + j;
            writef("p(%2d) = %2d  ", n, pancake(n));
        }
        writeln;
    }
}


// Pancake numbers. Nigel Galloway: October 28th., 2020
let pKake z=let n=[for n in 1..z-1->Array.ofList([n.. -1..0]@[n+1..z-1])]
            let e=let rec fG n g=match g with 0->n |_->fG (n*g) (g-1) in fG 1 z
            let rec fN i g l=match (Set.count g)-e with 0->(i,List.last l)
                                                       |_->let l=l|>List.collect(fun g->[for n in n->List.permute(fun g->n.[g]) g])|>Set.ofList
                                                           fN (i+1) (Set.union g l) (Set.difference l g|>Set.toList)
            fN 0 (set[[1..z]]) [[1..z]]

[1..9]|>List.iter(fun n->let i,g=pKake n in printfn "Maximum number of flips to sort %d elements is %d. e.g %A->%A" n i g [1..n])


Function pancake(n As Integer) As Integer
    Dim As Integer gap = 2, sum = 2, adj = -1
    While (sum < n)
        adj += 1
        gap = gap * 2 - 1
        sum += gap
    Wend
    Return n + adj
End Function

For n As Integer = 1 To 20
    Print Using "p(##) = ##  "; n; pancake(n);
    If n Mod 5 = 0 Then ?
Next n
Sleep


package main

import "fmt"

func pancake(n int) int {
    gap, sum, adj := 2, 2, -1
    for sum < n {
        adj++
        gap = gap*2 - 1
        sum += gap
    }
    return n + adj
}

func main() {
    for i := 0; i < 4; i++ {
        for j := 1; j < 6; j++ {
            n := i*5 + j
            fmt.Printf("p(%2d) = %2d  ", n, pancake(n))
        }
        fmt.Println()
    }
}


public class Pancake {
    private static int pancake(int n) {
        int gap = 2;
        int sum = 2;
        int adj = -1;
        while (sum < n) {
            adj++;
            gap = 2 * gap - 1;
            sum += gap;
        }
        return n + adj;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 6; j++) {
                int n = 5 * i + j;
                System.out.printf("p(%2d) = %2d  ", n, pancake(n));
            }
            System.out.println();
        }
    }
}


function pancake(len)
    gap, gapsum, adj = 2, 2, -1
    while gapsum < len
        adj += 1
        gap = gap * 2 - 1
        gapsum += gap
    end
    return len + adj
end

for i in 1:25
    print("pancake(", lpad(i, 2), ") = ", rpad(pancake(i), 5))
    i % 5 == 0 && println()
end


fun pancake(n: Int): Int {
    var gap = 2
    var sum = 2
    var adj = -1
    while (sum < n) {
        adj++
        gap = gap * 2 - 1
        sum += gap
    }
    return n + adj
}

fun main() {
    (1 .. 20).map {"p(%2d) = %2d".format(it, pancake(it))}
    val lines = results.chunked(5).map { it.joinToString("  ") }
    lines.forEach { println(it) }
}


            NORMAL MODE IS INTEGER
            VECTOR VALUES ROW = $5(2HP[,I2,4H] = ,I2,S2)*$

            INTERNAL FUNCTION(N)
            ENTRY TO P.
            GAP = 2
            ADJ = -1
            THROUGH LOOP, FOR SUM=2, GAP, SUM.GE.N
            ADJ = ADJ + 1
LOOP        GAP = GAP * 2 - 1
            FUNCTION RETURN N + ADJ
            END OF FUNCTION

            THROUGH OUTP, FOR R=1, 5, R.G.20
OUTP        PRINT FORMAT ROW, R,P.(R), R+1,P.(R+1), R+2,P.(R+2),
          0     R+3,P.(R+3), R+4,P.(R+4), R+5,P.(R+5)

            END OF PROGRAM


import strformat, strutils

func pancake(n: int): int =
  var
    gap, sumGaps = 2
    pg = 1
    adj = -1
  while sumGaps < n:
    inc adj
    inc pg, gap
    swap pg, gap
    inc sumGaps, gap
  result = n + adj

var line = ""
for n in 1..20:
  line.addSep("   ")
  line.add &"p({n:>2}) = {pancake(n):>2}"
  if n mod 5 == 0: (echo line; line.setLen(0))


use strict;
use warnings;
use feature 'say';

sub pancake {
    my($n) = @_;
    my ($gap, $sum, $adj) = (2, 2, -1);
    while ($sum < $n) { $sum += $gap = $gap * 2 - 1 and $adj++ }
    $n + $adj;
}

my $out;
$out .= sprintf "p(%2d) = %2d ", $_, pancake $_ for 1..20;
say $out =~ s/.{1,55}\K /\n/gr;

# Maximum number of flips plus examples using exhaustive search
sub pancake2 {
    my ($n) = @_;
    my $numStacks = 1;
    my @goalStack = 1 .. $n;
    my %newStacks = my %stacks = (join(' ',@goalStack), 0);
    for my $k (1..1000) {
        my %nextStacks;
        for my $pos (2..$n) {
            for my $key (keys %newStacks) {
                my @arr = split ' ', $key;
                my $cakes = join ' ', (reverse @arr[0..$pos-1]), @arr[$pos..$#arr];
                $nextStacks{$cakes} = $k unless $stacks{$cakes};
            }
        }
        %stacks = (%stacks, (%newStacks = %nextStacks));
        my $perms    = scalar %stacks;
        my %inverted = reverse %stacks;
        return $k-1, $inverted{(sort keys %inverted)[-1]} if $perms == $numStacks;
        $numStacks = $perms;
   }
}

say "\nThe maximum number of flips to sort a given number of elements is:";
for my $n (1..9) {
    my ($a,$b) = pancake2($n);
    say "pancake($n) = $a example: $b";
}


with javascript_semantics
function pancake(integer n)
    integer gap = 2, sum_gaps = gap, adj = -1
    while sum_gaps<n do
        adj += 1
        gap = gap*2-1
        sum_gaps += gap
    end while
    n += adj
    return n
end function
sequence t = tagset(20),
         r = columnize({t,apply(t,pancake)}),
         p = apply(true,sprintf,{{"p(%2d) = %2d"},r})
printf(1,"%s\n",join_by(p,1,5))


"""Pancake numbers. Requires Python>=3.7."""
import time

from collections import deque
from operator import itemgetter
from typing import Tuple

Pancakes = Tuple[int, ...]

def flip(pancakes: Pancakes, position: int) -> Pancakes:
    """Flip the stack of pancakes at the given position."""
    return tuple([*reversed(pancakes[:position]), *pancakes[position:]])

def pancake(n: int) -> Tuple[Pancakes, int]:
    """Return the nth pancake number."""
    init_stack = tuple(range(1, n + 1))
    stack_flips = {init_stack: 0}
    queue = deque([init_stack])

    while queue:
        stack = queue.popleft()
        flips = stack_flips[stack] + 1

        for i in range(2, n + 1):
            flipped = flip(stack, i)
            if flipped not in stack_flips:
                stack_flips[flipped] = flips
                queue.append(flipped)

    return max(stack_flips.items(), key=itemgetter(1))

if __name__ == "__main__":
    start = time.time()

    for n in range(1, 10):
        pancakes, p = pancake(n)
        print(f"pancake({n}) = {p:>2}. Example: {list(pancakes)}")

    print(f"\nTook {time.time() - start:.3} seconds.")


# 20201110 Raku programming solution

sub pancake(\n) {
   my ($gap,$sum,$adj) = 2, 2, -1;
   while ($sum < n) { $sum += $gap = $gap * 2 - 1 and $adj++ }
   return n + $adj;
}

for (1..20).rotor(5) { say [~] @_».&{ sprintf "p(%2d) = %2d ",$_,pancake $_ } }


/*REXX program calculates/displays  ten  pancake  numbers   (from 1 ──► 20, inclusive). */
     pad= center(''        , 10)                                         /*indentation. */
say  pad  center('pancakes', 10     )  center('pancake flips', 15     )  /*show the hdr.*/
say  pad  center(''        , 10, "─")  center('',              15, "─")  /*  "   "  sep.*/

         do #=1  for 20;  say pad  center(#, 10) center( pancake(#), 15) /*index, flips.*/
         end   /*#*/
exit 0                                           /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
pancake: procedure; parse arg n;          gap= 2 /*obtain  N;  initialize the GAP.      */
                                          sum= 2 /*            initialize the SUM.      */
                          do adj=0  while sum <n /*perform while  SUM is less than  N.  */
                          gap= gap*2 - 1         /*calculate the GAP.                   */
                          sum= sum + gap         /*add the  GAP  to the  SUM.           */
                          end   /*adj*/
         return n +adj -1                        /*return an adjusted adjustment sum.   */


for n = 1 to 9
    see "p(" + n + ") = " + pancake(n) + nl
next
return 0

func pancake(n)
     gap = 2
     sum = 2
     adj = -1;
     while (sum < n)
            adj = adj + 1
            gap = gap * 2 - 1
            sum = sum + gap
     end
     return n + adj


def pancake(n)
    gap = 2
    sum = 2
    adj = -1
    while sum < n
        adj = adj + 1
        gap = gap * 2 - 1
        sum = sum + gap
    end
    return n + adj
end

for i in 0 .. 3
    for j in 1 .. 5
        n = i * 5 + j
        print "p(%2d) = %2d  " % [n, pancake(n)]
    end
    print "\n"
end


import "/fmt" for Fmt

var pancake = Fn.new { |n|
    var gap = 2
    var sum = 2
    var adj = -1
    while (sum < n) {
        adj = adj + 1
        gap = gap*2 - 1
        sum = sum + gap
    }
    return n + adj
}

for (i in 0..3) {
    for (j in 1..5) {
        var n = i*5 + j
        Fmt.write("p($2d) = $2d  ", n, pancake.call(n))
    }
    System.print()
}


F is_pangram(sentence)
   R Set(sentence.lowercase().filter(ch -> ch C ‘a’..‘z’)).len == 26

L(sentence) [‘The quick brown fox jumps over the lazy dog.’,
             ‘The quick brown fox jumped over the lazy dog.’]
   print(‘'#.' is #.a pangram’.format(sentence, ‘not ’ * !is_pangram(sentence)))


*        Pangram RC                11/08/2015
PANGRAM  CSECT
         USING  PANGRAM,R12
         LR     R12,R15
BEGIN    LA     R9,SENTENCE
         LA     R6,4
LOOPI    LA     R10,ALPHABET       loop on sentences
         LA     R7,26
LOOPJ    LA     R5,0               loop on letters
         LR     R11,R9
         LA     R8,60
LOOPK    MVC    BUFFER+1(1),0(R10) loop in sentence
         CLC    0(1,R10),0(R11)    if alphabet[j=sentence[i]
         BNE    NEXTK
         LA     R5,1               found
NEXTK    LA     R11,1(R11)         next character
         BCT    R8,LOOPK
         LTR    R5,R5              if found
         BNZ    NEXTJ
         MVI    BUFFER,C'?'        not found
         B      PRINT
NEXTJ    LA     R10,1(R10)         next letter
         BCT    R7,LOOPJ
         MVC    BUFFER(2),=CL2'OK'
PRINT    MVC    BUFFER+3(60),0(R9)
         XPRNT  BUFFER,80
NEXTI    LA     R9,60(R9)          next sentence
         BCT    R6,LOOPI
RETURN   XR     R15,R15
         BR     R14
ALPHABET DC     CL26'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SENTENCE DC     CL60'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.'
         DC     CL60'THE FIVE BOXING WIZARDS DUMP QUICKLY.'
         DC     CL60'HEAVY BOXES PERFORM WALTZES AND JIGS.'
         DC     CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
BUFFER   DC     CL80' '
         YREGS
         END    PANGRAM


(defun contains-each (needles haystack)
   (if (endp needles)
       t
       (and (member (first needles) haystack)
            (contains-each (rest needles) haystack))))

(defun pangramp (str)
   (contains-each (coerce "abcdefghijklmnopqrstuvwxyz" 'list)
                  (coerce (string-downcase str) 'list)))


INCLUDE "D2:CHARTEST.ACT" ;from the Action! Tool Kit

DEFINE CHAR_COUNT="26"

BYTE FUNC IsPangram(CHAR ARRAY t)
  BYTE ARRAY tab(CHAR_COUNT)
  BYTE i,c

  FOR i=0 TO CHAR_COUNT-1
  DO tab(i)=0 OD

  FOR i=1 TO t(0)
  DO
    c=ToLower(t(i))
    IF c>='a AND c<='z THEN
      tab(c-'a)=1
    FI
  OD

  FOR i=0 TO CHAR_COUNT-1
  DO
    IF tab(i)=0 THEN
      RETURN (0)
    FI
  OD
RETURN (1)

PROC Test(CHAR ARRAY t)
  BYTE res

  res=IsPangram(t)
  PrintF("""%S"" is ",t)
  IF res=0 THEN
    Print("not ")
  FI
  PrintE("a pangram.")
  PutE()
RETURN

PROC Main()
  Put(125) PutE() ;clear screen
  Test("The quick brown fox jumps over the lazy dog.")
  Test("QwErTyUiOpAsDfGhJkLzXcVbNm")
  Test("Not a pangram")
  Test("")
RETURN


function pangram(k:string):Boolean {
  var lowerK:String = k.toLowerCase();
  var has:Object = {}

  for (var i:Number=0; i<=k.length-1; i++) {
    has[lowerK.charAt(i)] = true;
  }

  var result:Boolean = true;

  for (var ch:String='a'; ch <= 'z'; ch=String.fromCharCode(ch.charCodeAt(0)+1)) {
      result = result && has[ch]
  }

  return result || false;
}


with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure pangram is

   function ispangram(txt: String) return Boolean is
     (Is_Subset(To_Set(Span => ('a','z')), To_Set(To_Lower(txt))));

begin
   put_line(Boolean'Image(ispangram("This is a test")));
   put_line(Boolean'Image(ispangram("The quick brown fox jumps over the lazy dog")));
   put_line(Boolean'Image(ispangram("NOPQRSTUVWXYZ  abcdefghijklm")));
   put_line(Boolean'Image(ispangram("abcdefghijklopqrstuvwxyz"))); --Missing m, n
end pangram;


# init pangram: #
INT la = ABS "a", lz = ABS "z";
INT ua = ABS "A", uz = ABS "Z";
IF lz-la+1 > bits width THEN
  put(stand error, "Exception: insufficient bits in word for task");
  stop
FI;

PROC is a pangram = (STRING test)BOOL: (
  BITS a2z := BIN(ABS(2r1 SHL (lz-la))-1); # assume: ASCII & Binary #
  FOR i TO UPB test WHILE
    INT c = ABS test[i];
    IF la <= c AND c <= lz THEN
      a2z := a2z AND NOT(2r1 SHL (c-la))
    ELIF ua <= c AND c <= uz THEN
      a2z := a2z AND NOT(2r1 SHL (c-ua))
    FI;
# WHILE # a2z /= 2r0 DO
    SKIP
  OD;
  a2z = 2r0
);

main:(
  []STRING test list = (
    "Big fjiords vex quick waltz nymph",
    "The quick brown fox jumps over a lazy dog",
    "A quick brown fox jumps over a lazy dog"
  );
  FOR key TO UPB test list DO
    STRING test = test list[key];
    IF is a pangram(test) THEN
      print(("""",test,""" is a pangram!", new line))
    FI
  OD
)


    a←'abcdefghijklmnopqrstuvwxyz'
    A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    Panagram←{∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵}
    Panagram 'This should fail'
0
    Panagram 'The quick brown fox jumps over the lazy dog'
1


use framework "Foundation" -- ( for case conversion function )

--------------------- PANGRAM CHECKER --------------------

-- isPangram :: String -> Bool
on isPangram(s)
    script charUnUsed
        property lowerCaseString : my toLower(s)
        on |λ|(c)
            lowerCaseString does not contain c
        end |λ|
    end script

    0 = length of filter(charUnUsed, ¬
        "abcdefghijklmnopqrstuvwxyz")
end isPangram

--------------------------- TEST -------------------------
on run
    map(isPangram, {¬
        "is this a pangram", ¬
        "The quick brown fox jumps over the lazy dog"})

    --> {false, true}
end run

-------------------- GENERIC FUNCTIONS -------------------

-- filter :: (a -> Bool) -> [a] -> [a]
on filter(f, xs)
    tell mReturn(f)
        set lst to {}
        set lng to length of xs
        repeat with i from 1 to lng
            set v to item i of xs
            if |λ|(v, i, xs) then set end of lst to v
        end repeat
        return lst
    end tell
end filter

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to |λ|(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map

-- Lift 2nd class handler function into
-- 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
    if class of f is script then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

-- toLower :: String -> String
on toLower(str)
    set ca to current application
    ((ca's NSString's stringWithString:(str))'s ¬
        lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toLower


chars: map 97..122 => [to :string to :char]
pangram?: function [sentence][
    every? chars 'ch ->
        in? ch sentence
]

print pangram? "this is a sentence"
print pangram? "The quick brown fox jumps over the lazy dog."


V nMax = 250
V nBranches = 4
V rooted = [BigInt(0)] * (nMax + 1)
V unrooted = [BigInt(0)] * (nMax + 1)
rooted[0] = BigInt(1)
rooted[1] = BigInt(1)
unrooted[0] = BigInt(1)
unrooted[1] = BigInt(1)

F choose(m, k)
   I k == 1
      R m
   V result = m
   L(i) 1 .< k
      result = result * (m + i) I/ (i + 1)
   R result

F tree(br, n, l, sum, cnt)
   V s = 0
   L(b) br + 1 .. :nBranches
      s = sum + (b - br) * n
      I s > :nMax {R}

      V c = choose(:rooted[n], b - br) * cnt

      I l * 2 < s {:unrooted[s] += c}
      I b == :nBranches {R}
      :rooted[s] += c
      L(m) (n - 1 .< 0).step(-1)
         tree(b, m, l, s, c)

F bicenter(s)
   I (s [&] 1) == 0
      :unrooted[s] += :rooted[s I/ 2] * (:rooted[s I/ 2] + 1) I/ 2

L(n) 1 .. nMax
   tree(0, n, n, 1, BigInt(1))
   bicenter(n)
   print(n‘: ’unrooted[n])


(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
#include
"share/HATS/atspre_staload_libats_ML.hats"
//
(* ****** ****** *)
//
fun
letter_check
(
cs: string, c0: char
) : bool = cs.exists()(lam(c) => c0 = c)
//
(* ****** ****** *)

fun
Pangram_check
  (text: string): bool = let
//
val
alphabet = "abcdefghijklmnopqrstuvwxyz"
val
((*void*)) = assertloc(length(alphabet) = 26)
//
in
  alphabet.forall()(lam(c) => letter_check(text, c) || letter_check(text, toupper(c)))
end // end of [Pangram_check]

(* ****** ****** *)

implement
main0 () =
{
//
val
text0 = "The quick brown fox jumps over the lazy dog."
//
val-true = Pangram_check(text0)
val-false = Pangram_check("This is not a pangram sentence.")
//
} (* end of [main0] *)

(* ****** ****** *)


Gui, -MinimizeBox
Gui, Add, Edit, w300 r5 vText
Gui, Add, Button, x105 w100 Default, Check Pangram
Gui, Show,, Pangram Checker
Return

GuiClose:
    ExitApp
Return

ButtonCheckPangram:
    Gui, Submit, NoHide
    Loop, 26
        If Not InStr(Text, Char := Chr(64 + A_Index)) {
            MsgBox,, Pangram, Character %Char% is missing!
            Return
        }
    MsgBox,, Pangram, OK`, this is a Pangram!
Return


#include <stdio.h>

#define MAX_N 33	/* max number of tree nodes */
#define BRANCH 4	/* max number of edges a single node can have */

/* The basic idea: a paraffin molecule can be thought as a simple tree
   with each node being a carbon atom.  Counting molecules is thus the
   problem of counting free (unrooted) trees of given number of nodes.

   An unrooted tree needs to be uniquely represented, so we need a way
   to cannonicalize equivalent free trees.  For that, we need to first
   define the cannonical form of rooted trees.  Since rooted trees can
   be constructed by a root node and up to BRANCH rooted subtrees that
   are arranged in some definite order, we can define it thusly:
     * Given the root of a tree, the weight of each of its branches is
       the number of nodes contained in that branch;
     * A cannonical rooted tree would have its direct subtrees ordered
       in descending order by weight;
     * In case multiple subtrees are the same weight, they are ordered
       by some unstated, but definite, order (this code doesn't really
       care what the ordering is; it only counts the number of choices
       in such a case, not enumerating individual trees.)

   A rooted tree of N nodes can then be constructed by adding smaller,
   cannonical rooted trees to a root node, such that:
     * Each subtree has fewer than BRANCH branches (since it must have
       an empty slot for an edge to connect to the new root);
     * Weight of those subtrees added later are no higher than earlier
       ones;
     * Their weight total N-1.
   A rooted tree so constructed would be itself cannonical.

   For an unrooted tree, we can define the radius of any of its nodes:
   it's the maximum weight of any of the subtrees if this node is used
   as the root.  A node is the center of a tree if it has the smallest
   radius among all the nodes.  A tree can have either one or two such
   centers; if two, they must be adjacent (cf. Knuth, tAoCP 2.3.4.4).

   An important fact is that, a node in a tree is its sole center, IFF
   its radius times 2 is no greater than the sum of the weights of all
   branches (ibid).  While we are making rooted trees, we can add such
   trees encountered to the count of cannonical unrooted trees.

   A bi-centered unrooted tree with N nodes can be made by joining two
   trees, each with N/2 nodes and fewer than BRANCH subtrees, at root.
   The pair must be ordered in aforementioned implicit way so that the
   product is cannonical. */

typedef unsigned long long xint;
#define FMT "llu"

xint rooted[MAX_N] = {1, 1, 0};
xint unrooted[MAX_N] = {1, 1, 0};

/* choose k out of m possible values; chosen values may repeat, but the
   ordering of them does not matter.  It's binomial(m + k - 1, k) */
xint choose(xint m, xint k)
{
	xint i, r;

	if (k == 1) return m;
	for (r = m, i = 1; i < k; i++)
		r = r * (m + i) / (i + 1);
	return r;
}

/* constructing rooted trees of BR branches at root, with at most
   N radius, and SUM nodes in the partial tree already built. It's
   recursive, and CNT and L carry down the number of combinations
   and the tree radius already encountered. */
void tree(xint br, xint n, xint cnt, xint sum, xint l)
{
	xint b, c, m, s;

	for (b = br + 1; b <= BRANCH; b++) {
		s = sum + (b - br) * n;
		if (s >= MAX_N) return;

		/* First B of BR branches are all of weight n; the
		   rest are at most of weight N-1 */
		c = choose(rooted[n], b - br) * cnt;

		/* This partial tree is singly centered as is */
		if (l * 2 < s) unrooted[s] += c;

		/* Trees saturate at root can't be used as building
		   blocks for larger trees, so forget them */
		if (b == BRANCH) return;
		rooted[s] += c;

		/* Build the rest of the branches */
		for (m = n; --m; ) tree(b, m, c, s, l);
	}
}

void bicenter(int s)
{
	if (s & 1) return;

	/* Pick two of the half-size building blocks, allowing
	   repetition. */
	unrooted[s] += rooted[s/2] * (rooted[s/2] + 1) / 2;
}

int main()
{
	xint n;
	for (n = 1; n < MAX_N; n++) {
		tree(0, n, 1, 1, n);
		bicenter(n);
		printf("%"FMT": %"FMT"\n", n, unrooted[n]);
	}

	return 0;
}


Pangram("The quick brown fox jumps over the lazy dog")
Func Pangram($s_String)
For $i = 1 To 26
	IF Not StringInStr($s_String, Chr(64 + $i)) Then
		Return MsgBox(0,"No Pangram", "Character " & Chr(64 + $i) &" is missing")
	EndIf
Next
Return MsgBox(0,"Pangram", "Sentence is a Pangram")
EndFunc


#!/usr/bin/awk -f
BEGIN {
   allChars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   print isPangram("The quick brown fox jumps over the lazy dog.");
   print isPangram("The quick brown fo.");
}

function isPangram(string) {
    delete X;
    for (k=1; k<length(string); k++) {
        X[toupper(substr(string,k,1))]++;  # histogram
    }
    for (k=1; k<=length(allChars); k++) {
        if (!X[substr(allChars,k,1)]) return 0;
    }
    return 1;
}


import std.stdio, std.bigint;

enum uint nMax = 250;
enum uint nBranches = 4;

__gshared BigInt[nMax + 1] rooted = [1.BigInt, 1.BigInt /*...*/],
                           unrooted = [1.BigInt, 1.BigInt /*...*/];

void tree(in uint br, in uint n, in uint l, in uint inSum,
          in BigInt cnt) nothrow {
    __gshared static BigInt[nBranches] c;

    uint sum = inSum;
    foreach (immutable b; br + 1 .. nBranches + 1) {
        sum += n;
        if (sum > nMax || (l * 2 >= sum && b >= nBranches))
            return;
        if (b == br + 1) {
            c[br] = rooted[n] * cnt;
        } else {
            c[br] *= rooted[n] + b - br - 1;
            c[br] /= b - br;
        }
        if (l * 2 < sum)
            unrooted[sum] += c[br];
        if (b < nBranches)
            rooted[sum] += c[br];
        foreach_reverse (immutable m; 1 .. n)
            tree(b, m, l, sum, c[br]);
    }
}

void bicenter(in uint s) nothrow {
    if ((s & 1) == 0)
        unrooted[s] += rooted[s / 2] * (rooted[s / 2] + 1) / 2;
}

void main() {
    foreach (immutable n; 1 .. nMax + 1) {
        tree(0, n, n, 1, 1.BigInt);
        n.bicenter;
        writeln(n, ": ", unrooted[n]);
    }
}


DECLARE FUNCTION IsPangram! (sentence AS STRING)

DIM x AS STRING

x = "My dog has fleas."
GOSUB doIt
x = "The lazy dog jumps over the quick brown fox."
GOSUB doIt
x = "Jackdaws love my big sphinx of quartz."
GOSUB doIt
x = "What's a jackdaw?"
GOSUB doIt

END

doIt:
    PRINT IsPangram!(x), x
    RETURN

FUNCTION IsPangram! (sentence AS STRING)
    'returns -1 (true) if sentence is a pangram, 0 (false) otherwise
    DIM l AS INTEGER, s AS STRING, t AS INTEGER
    DIM letters(25) AS INTEGER

    FOR l = 1 TO LEN(sentence)
        s = UCASE$(MID$(sentence, l, 1))
        SELECT CASE s
            CASE "A" TO "Z"
                t = ASC(s) - 65
                letters(t) = 1
        END SELECT
    NEXT

    FOR l = 0 TO 25
        IF letters(l) < 1 THEN
            IsPangram! = 0
            EXIT FUNCTION
        END IF
    NEXT

    IsPangram! = -1
END FUNCTION


function isPangram$(texto$)
    longitud = Length(texto$)
    if longitud < 26 then return "is not a pangram"
    t$ = lower(texto$)
    print "'"; texto$; "' ";
    for i = 97 to 122
        if instr(t$, chr(i)) = 0 then return "is not a pangram"
    next i
    return "is a pangram"
end function

print isPangram$("The quick brown fox jumps over the lazy dog.")   # --> true
print isPangram$("The quick brown fox jumped over the lazy dog.")  # --> false
print isPangram$("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ")          # --> true


' version 31-12-2016
' compile with: fbc -s console
' uses gmp, translation from pascal

#Include Once "gmp.bi"

Const As Integer max_n = 500, branch = 4

Dim Shared As mpz_ptr rooted(), unrooted(), c()
Dim Shared As mpz_ptr cnt, tmp

Sub tree(br As UInteger, n As UInteger, l As UInteger, sum As UInteger, cnt As mpz_ptr)

  Dim As UInteger b, m

  For b = br +1 To branch
    sum = sum + n
    If sum > max_n Then Return

    ' prevent unneeded long math
    If (l * 2 >= sum) And (b >= branch) Then Return

    If b = (br +1) Then
      mpz_mul(c(br), rooted(n), cnt)
    Else
      mpz_add_ui(tmp, rooted(n), b - br -1)
      mpz_mul(c(br), c(br), tmp)
      mpz_divexact_ui(c(br), c(br), b - br)
    End If

    If l * 2 < sum Then
      mpz_add(unrooted(sum), unrooted(sum), c(br))
    End If
    If b < branch Then
      mpz_add(rooted(sum), rooted(sum), c(br))
      For m = n -1 To 1 Step -1
        tree(b, m, l, sum, c(br))
      Next
    End If
  Next

End Sub

Sub bicenter(s As UInteger)
  If (s And 1) = 1 Then Return
  mpz_add_ui(tmp, rooted(s \ 2), 1)
  mpz_mul(tmp, rooted(s \ 2), tmp)
  mpz_tdiv_q_2exp(tmp, tmp, 1)
  mpz_add(unrooted(s), unrooted(s), tmp)
End Sub

' ------=< MAIN >=------

Dim As UInteger n, sum
Dim As ZString Ptr ans

ReDim rooted(max_n), unrooted(max_n)
For n = 0 To max_n
    rooted(n) = Allocate(Len(__mpz_struct)) : Mpz_init(  rooted(n))
  unrooted(n) = Allocate(Len(__mpz_struct)) : Mpz_init(unrooted(n))
Next
For n = 0 To 1
  mpz_set_ui(  rooted(n), 1)
  mpz_set_ui(unrooted(n), 1)
Next

ReDim c(branch -1)
For n = 0 To branch -1
  c(n) = Allocate(Len(__mpz_struct)) : Mpz_init(c(n))
Next

cnt = Allocate(Len(__mpz_struct)) : Mpz_init_set_ui(cnt, 1)
tmp = Allocate(Len(__mpz_struct)) : Mpz_init(tmp)

sum = 1
For n = 1 To max_n
  tree(0, n, n, sum, cnt)
  bicenter(n)
  'gmp_printf("%d: %Zd"+Chr(13)+Chr(10), n, unrooted(n))
  ans = Mpz_get_str (0, 10, unrooted(n))
  Print Using "###: "; n; : Print *ans
Next

For n = 0 To max_n
  mpz_Clear(  rooted(n))
  mpz_Clear(unrooted(n))
Next

For n = 0 To branch -1
  mpz_clear(c(n))
Next

mpz_clear(cnt)
mpz_clear(tmp)

' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End


@echo off
setlocal enabledelayedexpansion

	%===The Main Thing===%
call :pangram "The quick brown fox jumps over the lazy dog."
call :pangram "The quick brown fox jumped over the lazy dog."
echo.
pause
exit /b 0

	%===The Function===%
:pangram
set letters=abcdefgihjklmnopqrstuvwxyz
set cnt=0
set inp=%~1
set str=!inp: =!

:loop
set chr=!str:~%cnt%,1!
if "!letters!"=="" (
	echo %1 is a pangram^^!
	goto :EOF
)
if "!chr!"=="" (
	echo %1 is not a pangram.
	goto :EOF
)
set letters=!letters:%chr%=!
set /a cnt+=1
goto loop


      FOR test% = 1 TO 2
        READ test$
        PRINT """" test$ """ " ;
        IF FNpangram(test$) THEN
          PRINT "is a pangram"
        ELSE
          PRINT "is not a pangram"
        ENDIF
      NEXT test%
      END

      DATA "The quick brown fox jumped over the lazy dog"
      DATA "The five boxing wizards jump quickly"

      DEF FNpangram(A$)
      LOCAL C%
      A$ = FNlower(A$)
      FOR C% = ASC("a") TO ASC("z")
        IF INSTR(A$, CHR$(C%)) = 0 THEN = FALSE
      NEXT
      = TRUE

      DEF FNlower(A$)
      LOCAL A%, C%
      FOR A% = 1 TO LEN(A$)
        C% = ASCMID$(A$,A%)
        IF C% >= 65 IF C% <= 90 MID$(A$,A%,1) = CHR$(C%+32)
      NEXT
      = A$


get "libhdr"

// Test if s is a pangram. The ASCII character set is assumed.
let pangram(s) = valof
$(  let letters = vec 25
    for i=0 to 25 do letters!i := false
    for i=1 to s%0 do
    $(  let c = (s%i | 32) - 'a'
        if c >= 0 & c < 26 then
            letters!c := true
    $)
    for i=0 to 25 unless letters!i resultis false
    resultis true
$)

// Display s and whether or not it is a pangram.
let check(s) be
$(  writes(s)
    writes(" -> ")
    test pangram(s)
        then writes("yes*N")
        else writes("no*N")
$)

let start() be
$(  check("The quick brown fox jumps over the lazy dog.")
    check("The five boxing wizards dump quickly.")
$)


package main

import (
    "fmt"
    "math/big"
)

const branches = 4
const nMax = 500

var rooted, unrooted [nMax + 1]big.Int
var c [branches]big.Int
var tmp = new(big.Int)
var one = big.NewInt(1)

func tree(br, n, l, sum int, cnt *big.Int) {
    for b := br + 1; b <= branches; b++ {
        sum += n
        if sum > nMax {
            return
        }
        if l*2 >= sum && b >= branches {
            return
        }
        if b == br+1 {
            c[br].Mul(&rooted[n], cnt)
        } else {
            tmp.Add(&rooted[n], tmp.SetInt64(int64(b-br-1)))
            c[br].Mul(&c[br], tmp)
            c[br].Div(&c[br], tmp.SetInt64(int64(b-br)))
        }
        if l*2 < sum {
            unrooted[sum].Add(&unrooted[sum], &c[br])
        }
        if b < branches {
            rooted[sum].Add(&rooted[sum], &c[br])
        }
        for m := n - 1; m > 0; m-- {
            tree(b, m, l, sum, &c[br])
        }
    }
}

func bicenter(s int) {
    if s&1 == 0 {
        tmp.Rsh(tmp.Mul(&rooted[s/2], tmp.Add(&rooted[s/2], one)), 1)
        unrooted[s].Add(&unrooted[s], tmp)
    }
}

func main() {
    rooted[0].SetInt64(1)
    rooted[1].SetInt64(1)
    unrooted[0].SetInt64(1)
    unrooted[1].SetInt64(1)
    for n := 1; n <= nMax; n++ {
        tree(0, n, n, 1, big.NewInt(1))
        bicenter(n)
        fmt.Printf("%d: %d\n", n, &unrooted[n])
    }
}


(isPangram=
  k
.   low$!arg:?arg
  & a:?k
  &   whl
    ' ( @(!arg:? !k ?)
      & chr$(1+asc$!k):?k:~>z
      )
  & !k:>z
  &
);


pangram? = { sentence |
  letters = [:a :b :c :d :e :f :g :h :i :j :k :l :m
    :n :o :p :q :r :s :t :u :v :w :x :y :z]

    sentence.downcase!

    letters.reject! { l |
      sentence.include? l
    }

  letters.empty?
}

p pangram? 'The quick brown fox jumps over the lazy dog.' #Prints true
p pangram? 'Probably not a pangram.'  #Prints false


#include <stdio.h>

int is_pangram(const char *s)
{
	const char *alpha = ""
		"abcdefghjiklmnopqrstuvwxyz"
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	char ch, wasused[26] = {0};
	int total = 0;

	while ((ch = *s++) != '\0') {
		const char *p;
		int idx;

		if ((p = strchr(alpha, ch)) == NULL)
			continue;

		idx = (p - alpha) % 26;

		total += !wasused[idx];
		wasused[idx] = 1;
		if (total == 26)
			return 1;
	}
	return 0;
}

int main(void)
{
	int i;
	const char *tests[] = {
		"The quick brown fox jumps over the lazy dog.",
		"The qu1ck brown fox jumps over the lazy d0g."
	};

	for (i = 0; i < 2; i++)
		printf("\"%s\" is %sa pangram\n",
			tests[i], is_pangram(tests[i])?"":"not ");
	return 0;
}


-- polynomial utils
a `nmul` n = map (*n) a
a `ndiv` n = map (`div` n) a

instance (Integral a) => Num [a] where
  (+) = zipWith (+)
  negate = map negate
  a * b = foldr f undefined b where
    f x z = (a `nmul` x) + (0 : z)
  abs _ = undefined
  signum _ = undefined
  fromInteger n = fromInteger n : repeat 0

-- replace x in polynomial with x^n
repl a n = concatMap (: replicate (n-1) 0) a

-- S2: (a^2 + b)/2
cycleIndexS2 a b = (a*a + b)`ndiv` 2

-- S4: (a^4 + 6 a^2 b + 8 a c + 3 b^2 + 6 d) / 24
cycleIndexS4 a b c d =	((a ^ 4) +
			 (a ^ 2 * b) `nmul` 6 +
			 (a * c) `nmul` 8 +
			 (b ^ 2) `nmul` 3 +
			 d `nmul` 6) `ndiv` 24

a598 = x1
-- A000598: A(x) = 1 + (1/6)*x*(A(x)^3 + 3*A(x)*A(x^2) + 2*A(x^3))
x1 = 1 : ((x1^3) + ((x2*x1)`nmul` 3) + (x3`nmul`2)) `ndiv` 6
x2 = x1`repl`2
x3 = x1`repl`3
x4 = x1`repl`4

-- A000678 = x CycleIndex(S4, A000598(x))
a678 = 0 : cycleIndexS4 x1 x2 x3 x4

-- A000599 = CycleIndex(S2, A000598(x) - 1)
a599 = cycleIndexS2 (0 : tail x1) (0 : tail x2)

-- A000602 = A000678(x) - A000599(x) + A000599(x^2)
a602 = a678 - a599 + x2

main = mapM_ print $ take 200 $ zip [0 ..] a602


using System;
using System.Linq;

static class Program
{
    static bool IsPangram(this string text, string alphabet = "abcdefghijklmnopqrstuvwxyz")
    {
        return alphabet.All(text.ToLower().Contains);
    }

    static void Main(string[] arguments)
    {
        Console.WriteLine(arguments.Any() && arguments.First().IsPangram());
    }
}


#include <algorithm>
#include <cctype>
#include <string>
#include <iostream>

const std::string alphabet("abcdefghijklmnopqrstuvwxyz");

bool is_pangram(std::string s)
{
    std::transform(s.begin(), s.end(), s.begin(), ::tolower);
    std::sort(s.begin(), s.end());
    return std::includes(s.begin(), s.end(), alphabet.begin(), alphabet.end());
}

int main()
{
    const auto examples = {"The quick brown fox jumps over the lazy dog",
                           "The quick white cat jumps over the lazy dog"};

    std::cout.setf(std::ios::boolalpha);
    for (auto& text : examples) {
        std::cout << "Is \"" << text << "\" a pangram? - " << is_pangram(text) << std::endl;
    }
}


import java.math.BigInteger;
import java.util.Arrays;

class Test {
    final static int nMax = 250;
    final static int nBranches = 4;

    static BigInteger[] rooted = new BigInteger[nMax + 1];
    static BigInteger[] unrooted = new BigInteger[nMax + 1];
    static BigInteger[] c = new BigInteger[nBranches];

    static void tree(int br, int n, int l, int inSum, BigInteger cnt) {
        int sum = inSum;
        for (int b = br + 1; b <= nBranches; b++) {
            sum += n;

            if (sum > nMax || (l * 2 >= sum && b >= nBranches))
                return;

            BigInteger tmp = rooted[n];
            if (b == br + 1) {
                c[br] = tmp.multiply(cnt);
            } else {
                c[br] = c[br].multiply(tmp.add(BigInteger.valueOf(b - br - 1)));
                c[br] = c[br].divide(BigInteger.valueOf(b - br));
            }

            if (l * 2 < sum)
                unrooted[sum] = unrooted[sum].add(c[br]);

            if (b < nBranches)
                rooted[sum] = rooted[sum].add(c[br]);

            for (int m = n - 1; m > 0; m--)
                tree(b, m, l, sum, c[br]);
        }
    }

    static void bicenter(int s) {
        if ((s & 1) == 0) {
            BigInteger tmp = rooted[s / 2];
            tmp = tmp.add(BigInteger.ONE).multiply(rooted[s / 2]);
            unrooted[s] = unrooted[s].add(tmp.shiftRight(1));
        }
    }

    public static void main(String[] args) {
        Arrays.fill(rooted, BigInteger.ZERO);
        Arrays.fill(unrooted, BigInteger.ZERO);
        rooted[0] = rooted[1] = BigInteger.ONE;
        unrooted[0] = unrooted[1] = BigInteger.ONE;

        for (int n = 1; n <= nMax; n++) {
            tree(0, n, n, 1, BigInteger.ONE);
            bicenter(n);
            System.out.printf("%d: %s%n", n, unrooted[n]);
        }
    }
}


shared void run() {

	function pangram(String sentence) =>
 		let(alphabet = set('a'..'z'),
			letters = set(sentence.lowercased.filter(alphabet.contains)))
 		letters == alphabet;

 	value sentences = [
 		"The quick brown fox jumps over the lazy dog",
 		"""Watch "Jeopardy!", Alex Trebek's fun TV quiz game.""",
 		"Pack my box with five dozen liquor jugs.",
 		"blah blah blah"
 	];
 	for(sentence in sentences) {
 		print("\"``sentence``\" is a pangram? ``pangram(sentence)``");
 	}
}


(defn pangram? [s]
  (let [letters (into #{} "abcdefghijklmnopqrstuvwxyz")]
    (= (->> s .toLowerCase (filter letters) (into #{})) letters)))


pangram = proc (s: string) returns (bool)
    letters: array[bool] := array[bool]$fill(0,26,false)
    for c: char in string$chars(s) do
        if c>='a' & c<='z' then
            c := char$i2c(char$c2i(c) - 32)
        end
        if c>='A' & c<='Z' then
            letters[char$c2i(c) - 65] := true
        end
    end
    for seen: bool in array[bool]$elements(letters) do
        if ~seen then return(false) end
    end
    return(true)
end pangram

start_up = proc ()
    po: stream := stream$primary_output()
    examples: array[string] := array[string]$[
        "The quick brown fox jumps over the lazy dog.",
        "The five boxing wizards dump quickly.",
        "abcdefghijklmnopqrstuvwxyz"
    ]

    for example: string in array[string]$elements(examples) do
        stream$puts(po, "\"" || example || "\" is")
        if ~pangram(example) then
            stream$puts(po, " not")
        end
        stream$putl(po, " a pangram.")
    end
end start_up


def MAX_N: 500;  # imprecision begins at 46
def BRANCH: 4;

# state: [unrooted, ra]
# tree(br; n; l; sum; cnt) where initially: l=n, sum=1 and cnt=1
def tree(br; n; l; sum; cnt):

  # The inner function is used to implement the range(b+1; BRANCH) loop
  # as there are early exits.
  # On completion, _tree returns [unrooted, ra]
  def _tree: # state [ (b, c, sum),  (unrooted, ra)]
    if length != 5 then error("_tree input has length \(length)") else . end
    | .[0] as $b | .[1] as $c | .[2] as $sum | .[3] as $unrooted | .[4] as $ra
    | if $b > BRANCH then [$unrooted, $ra]
      else
        ($sum + n) as $sum
        | if $sum >= MAX_N or
             # prevent unneeded long math
             ( l * 2 >= $sum and $b >= BRANCH) then [$unrooted, $ra]                      # return
          else (if $b == br + 1 then $ra[n] * cnt
                else ($c * ($ra[n] + (($b - br - 1)))) / ($b - br) | floor
                end) as $c
          | (if l * 2 < $sum then ($unrooted | .[$sum] += $c)
             else $unrooted end) as $unrooted
          | if $b >= BRANCH then [$b+1, $c, $sum, $unrooted, $ra] | _tree                 # next
            else  [$unrooted, ($ra | .[$sum] += $c) ]
            | reduce range(1; n) as $m (.;  tree($b; $m; l; $sum; $c))
            | ([$b + 1, $c, $sum] + .) | _tree
            end
          end
      end
  ;

  # start by incrementing b, and prepending values for (b,c,sum)
  ([br+1, cnt, sum] + .)  | _tree
;

# input and output: [unrooted, ra]
def bicenter(s):
  if s % 2 == 1 then .
  else
     .[1][s / 2] as $aux
     | .[0][s] += ($aux * ($aux + 1)) / 2 # 2 divides odd*even
  end
;

def array(n;init): [][n-1] = init | map(init);

def ra: array( MAX_N; 0) | .[0] = 1 | .[1] = 1;

def unrooted: ra;

# See below for a simpler implementation using "foreach"
def paraffins:
  # range(1; MAX_N)
  def _paraffins(n):
    if n >= MAX_N then empty
    else tree(0; n; n; 1; 1) | bicenter(n)
    | [n, .[0][n]],  # output
      _paraffins(n+1)
    end;
  [unrooted, ra] | _paraffins(1)
;

paraffins


const branches = 4
const nmax = 500

const rooted = zeros(BigInt, nmax + 1)
const unrooted = zeros(BigInt, nmax + 1)
rooted[1] = rooted[2] = unrooted[1] = unrooted[2] = 1
const c = zeros(BigInt, branches)

function tree(br, n, l, sum, cnt)
    for b in br+1:branches
        sum += n
        if (sum > nmax) || (l * 2 >= sum && b >= branches)
            return
        elseif b == br + 1
            c[br + 1] = rooted[n + 1] * cnt
        else
            c[br + 1] *= rooted[n + 1] + b - br - 1
            c[br + 1] = div(c[br + 1], b - br)
        end
        if l*2 < sum
            unrooted[sum + 1] += c[br + 1]
        end
        if b < branches
            rooted[sum + 1] += c[br + 1]
        end
        for m in n-1:-1:1
            tree(b, m, l, sum, c[br + 1])
        end
    end
end

bicenter(n) = if iseven(n) unrooted[n + 1] += div(rooted[div(n, 2) + 1] * (rooted[div(n, 2) + 1] + 1), 2) end

function paraffins()
    for n in 1:nmax
        tree(0, n, n, 1, one(BigInt))
        bicenter(n)
        println("$n: $(unrooted[n + 1])")
    end
end

paraffins()


// version 1.1.4-3

import java.math.BigInteger

const val MAX_N = 250
const val BRANCHES = 4

val rooted   = Array(MAX_N + 1) { if (it < 2) BigInteger.ONE else BigInteger.ZERO }
val unrooted = Array(MAX_N + 1) { if (it < 2) BigInteger.ONE else BigInteger.ZERO }
val c = Array(BRANCHES) { BigInteger.ZERO }

fun tree(br: Int, n: Int, l: Int, s: Int, cnt: BigInteger) {
    var sum = s
    for (b in (br + 1)..BRANCHES) {
        sum += n
        if (sum > MAX_N || (l * 2 >= sum && b >= BRANCHES)) return

        var tmp = rooted[n]
        if (b == br + 1) {
            c[br] = tmp * cnt
        }
        else {
            val diff = (b - br).toLong()
            c[br] *= tmp + BigInteger.valueOf(diff - 1L)
            c[br] /= BigInteger.valueOf(diff)
        }

        if (l * 2 < sum) unrooted[sum] += c[br]
        if (b < BRANCHES) rooted[sum] += c[br]
        for (m in n - 1 downTo 1) tree(b, m, l, sum, c[br])
    }
}

fun bicenter(s: Int) {
    if ((s and 1) == 0) {
        var tmp = rooted[s / 2]
        tmp *= tmp + BigInteger.ONE
        unrooted[s] += tmp.shiftRight(1)
    }
}

fun main(args: Array<String>) {
    for (n in 1..MAX_N) {
        tree(0, n, n, 1, BigInteger.ONE)
        bicenter(n)
        println("$n: ${unrooted[n]}")
    }
}


       identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.


s[m_, p_, n_] :=
  CycleIndexPolynomial[SymmetricGroup[m],
   Table[ComposeSeries[p, x^i + O[x]^(n + 1)], {i, m}]];
G000598[n_] := Nest[1 + x s[3, #, n] &, 1 + O[x], n];
G000602[n_] :=
  x s[4, #, n] - s[2, # - 1, n] +
     ComposeSeries[#, x^2 + O[x]^(n + 1)] &[G000598[n]];
A000602[n_] := SeriesCoefficient[G000602[n], n];
A000602List[n_] := CoefficientList[G000602[n], x];
[email protected]@{Range[0, 200], [email protected]}


import bigints

const
  nMax: int32 = 250
  nBranches = 4

var rooted, unrooted: array[nMax + 1, BigInt]
rooted[0..1] = [1.initBigInt, 1.initBigInt]
unrooted[0..1] = [1.initBigInt, 1.initBigInt]
for i in 2 .. nMax:
  rooted[i] = 0.initBigInt
  unrooted[i] = 0.initBigInt

proc choose(m: BigInt; k: int32): BigInt =
  result = m
  if k == 1: return
  for i in 1 ..< k:
    result = result * (m + i) div (i + 1)

proc tree(br, n, l, sum: int32; cnt: BigInt) =
  var s: int32 = 0
  for b in br + 1 .. nBranches:
    s = sum + (b - br) * n
    if s > nMax: return

    let c = choose(rooted[n], b - br) * cnt

    if l * 2 < s: unrooted[s] += c
    if b == nBranches: return
    rooted[s] += c
    for m in countdown(n-1, 1):
      tree b, m, l, s, c

proc bicenter(s: int32) =
  if (s and 1) == 0:
    unrooted[s] += rooted[s div 2] * (rooted[s div 2] + 1) div 2

for n in 1 .. nMax:
  tree 0, n, n, 1, 1.initBigInt
  n.bicenter
  echo n, ": ", unrooted[n]


is_pangram = (s) ->
  # This is optimized for longish strings--as soon as all 26 letters
  # are encountered, we will be done.  Our worst case scenario is a really
  # long non-pangram, or a really long pangram with at least one letter
  # only appearing toward the end of the string.
  a_code = 'a'.charCodeAt(0)
  required_letters = {}
  for i in [a_code...a_code+26]
    required_letters[String.fromCharCode(i)] = true

  cnt = 0
  for c in s
    c = c.toLowerCase()
    if required_letters[c]
      cnt += 1
      return true if cnt == 26
      delete required_letters[c]
  false

do ->
  tests = [
    ["is this a pangram", false]
    ["The quick brown fox jumps over the lazy dog", true]
  ]

  for test in tests
    [s, exp_value] = test
    throw Error("fail") if is_pangram(s) != exp_value
    # try long strings
    long_str = ''
    for i in [1..500000]
      long_str += s
    throw Error("fail") if is_pangram(long_str) != exp_value
    console.log "Passed tests: #{s}"


0010 FUNC pangram#(s$) CLOSED
0020   FOR i#:=ORD("A") TO ORD("Z") DO
0030     IF NOT (CHR$(i#) IN s$ OR CHR$(i#+32) IN s$) THEN RETURN FALSE
0040   ENDFOR i#
0050   RETURN TRUE
0060 ENDFUNC
0070 //
0080 WHILE NOT EOD DO
0090   READ s$
0100   PRINT "'",s$,"' is ",
0110   IF NOT pangram#(s$) THEN PRINT "not ",
0120   PRINT "a pangram"
0130 ENDWHILE
0140 END
0150 DATA "The quick brown fox jumps over the lazy dog."
0160 DATA "The five boxing wizards dump quickly."


(defun pangramp (s)
  (null (set-difference
          (loop for c from (char-code #\A) upto (char-code #\Z) collect (code-char c))
          (coerce (string-upcase s) 'list))))


Program Paraffins;

uses
  gmp;

const
  max_n = 500;
  branch = 4;

var
  rooted, unrooted: array [0 .. max_n-1] of mpz_t;
  c: array [0 .. branch-1] of mpz_t;
  cnt, tmp: mpz_t;
  n: integer;
  fmt: pchar;
  sum: integer;

procedure tree(br, n, l: integer; sum: integer; cnt: mpz_t);
  var
    b, m: integer;
  begin
    for b := br + 1 to branch do
    begin
      sum := sum + n;
      if sum >= max_n then
	exit;

      (* prevent unneeded long math *)
      if (l * 2 >= sum) and (b >= branch) then
	exit;

      if b = (br + 1) then
	mpz_mul(c[br], rooted[n], cnt)
      else
      begin
	mpz_add_ui(tmp, rooted[n], b - br - 1);
	mpz_mul(c[br], c[br], tmp);
	mpz_divexact_ui(c[br], c[br], b - br);
      end;

      if l * 2 < sum then
	mpz_add(unrooted[sum], unrooted[sum], c[br]);

      if b < branch then
      begin
	mpz_add(rooted[sum], rooted[sum], c[br]);
	for m := n-1 downto 1 do
	  tree(b, m, l, sum, c[br]);
      end;
    end;
  end;

procedure bicenter(s: integer);
begin
  if odd(s) then
    exit;
  mpz_add_ui(tmp, rooted[s div 2], 1);
  mpz_mul(tmp, rooted[s div 2], tmp);
  mpz_tdiv_q_2exp(tmp, tmp, 1);

  mpz_add(unrooted[s], unrooted[s], tmp);
end;

begin
  for n := 0 to 1 do
  begin
    mpz_init_set_ui(rooted[n], 1);
    mpz_init_set_ui(unrooted[n], 1);
  end;
  for n := 2 to max_n-1 do
  begin
    mpz_init_set_ui(rooted[n], 0);
    mpz_init_set_ui(unrooted[n], 0);
  end;
  for n := 0 to BRANCH-1 do
    mpz_init(c[n]);

  mpz_init(tmp);

  mpz_init_set_ui(cnt, 1);
  sum := 1;
  for n := 1 to MAX_N do
  begin
    tree(0, n, n, sum, cnt);
    bicenter(n);
    mp_printf('%d: %Zd'+chr(13)+chr(10), n, @unrooted[n]);
  end;
end.


MODULE BbtPangramChecker;
IMPORT StdLog,DevCommanders,TextMappers;

PROCEDURE Check(str: ARRAY OF CHAR): BOOLEAN;
CONST
	letters = 26;
VAR
	i,j: INTEGER;
	status: ARRAY letters OF BOOLEAN;
	resp : BOOLEAN;
BEGIN
	FOR i := 0 TO LEN(status) -1 DO status[i] := FALSE END;

	FOR i := 0 TO LEN(str) -  1 DO
		j := ORD(CAP(str[i])) - ORD('A');
		IF (0 <= j) & (25 >= j) & ~status[j] THEN status[j] := TRUE END
	END;

	resp := TRUE;
	FOR i := 0 TO LEN(status) - 1 DO;
		resp := resp & status[i]
	END;
	RETURN resp;
END Check;

PROCEDURE Do*;
VAR
	params: DevCommanders.Par;
	s: TextMappers.Scanner;
BEGIN
	params := DevCommanders.par;
	s.ConnectTo(params.text);
	s.SetPos(params.beg);
	s.Scan;
	WHILE (~s.rider.eot) DO
		IF (s.type = TextMappers.char) & (s.char = '~') THEN
			RETURN
		ELSIF (s.type # TextMappers.string) THEN
			StdLog.String("Invalid parameter");StdLog.Ln
		ELSE
			StdLog.Char("'");StdLog.String(s.string + "' is pangram?:> ");
			StdLog.Bool(Check(s.string));StdLog.Ln
		END;
		s.Scan
	END
END Do;

END BbtPangramChecker.


use Math::GMPz;

my $nmax = 250;
my $nbranches = 4;

my @rooted   = map { Math::GMPz->new($_) } 1,1,(0) x $nmax;
my @unrooted = map { Math::GMPz->new($_) } 1,1,(0) x $nmax;
my @c        = map { Math::GMPz->new(0) } 0 .. $nbranches-1;

sub tree {
  my($br, $n, $l, $sum, $cnt) = @_;
  for my $b ($br+1 .. $nbranches) {
    $sum += $n;
    return if $sum > $nmax || ($l*2 >= $sum && $b >= $nbranches);
    if ($b == $br+1) {
      $c[$br] = $rooted[$n] * $cnt;
    } else {
      $c[$br] *= $rooted[$n] + $b - $br - 1;
      $c[$br] /= $b - $br;
    }
    $unrooted[$sum] += $c[$br] if $l*2 < $sum;
    return if $b >= $nbranches;
    $rooted[$sum] += $c[$br];
    for my $m (reverse 1 .. $n-1) {
      next if $sum+$m > $nmax;
      tree($b, $m, $l, $sum, $c[$br]);
    }
  }
}

sub bicenter {
  my $s = shift;
  $unrooted[$s] += $rooted[$s/2] * ($rooted[$s/2]+1) / 2  unless $s & 1;
}

for my $n (1 .. $nmax) {
  tree(0, $n, $n, 1, Math::GMPz->new(1));
  bicenter($n);
  print "$n: $unrooted[$n]\n";
}


include "cowgol.coh";

sub pangram(str: [uint8]): (r: uint8) is
    var letters: uint8[26];
    MemZero(&letters[0], 26);

    loop
        var chr := [str];
        if chr == 0 then break; end if;
        str := @next str;
        chr := (chr | 32) - 'a';
        if chr >= 26 then continue; end if;
        letters[chr] := letters[chr] | 1;
    end loop;

    r := 1;
    chr := 0;
    while chr < 26 loop
        r := r & letters[chr];
        if r == 0 then break; end if;
        chr := chr + 1;
    end loop;
end sub;

var yesno: [uint8][] := {": no\n", ": yes\n"};
var test: [uint8][] := {
    "The quick brown fox jumps over the lazy dog.",
    "The five boxing wizards dump quickly."
};

var i: @indexof test := 0;
while i < @sizeof test loop
    print(test[i]);
    print(yesno[pangram(test[i])]);
    i := i + 1;
end loop;


def pangram?(sentence)
  ('a'..'z').all? {|c| sentence.downcase.includes?(c) }
end

p pangram?("not a pangram")
p pangram?("The quick brown fox jumps over the lazy dog.")


bool isPangram(in string text) pure nothrow @safe @nogc {
    uint bitset;

    foreach (immutable c; text) {
        if (c >= 'a' && c <= 'z')
            bitset |= (1u << (c - 'a'));
        else if (c >= 'A' && c <= 'Z')
            bitset |= (1u << (c - 'A'));
    }

    return bitset == 0b11_11111111_11111111_11111111;
}

void main() {
    assert("the quick brown fox jumps over the lazy dog".isPangram);
    assert(!"ABCDEFGHIJKLMNOPQSTUVWXYZ".isPangram);
    assert(!"ABCDEFGHIJKL.NOPQRSTUVWXYZ".isPangram);
    assert("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ".isPangram);
}


with javascript_semantics
constant MAX_N = 32,
         BRANCH = 4

sequence rooted = repeat(0,MAX_N+2),
       unrooted = repeat(0,MAX_N+2)

procedure tree(integer br, n, l=n, tot=1, atom cnt=1)
    atom c
    for b=br+1 to BRANCH do
        tot += n
        if tot>=MAX_N+1
        or (l*2>=tot and b>=BRANCH) then
            return
        end if
        integer n1 = n+1,
                t1 = tot+1
        if b==br+1 then
            c = rooted[n1]*cnt
        else
            c *= (rooted[n1]+(b-br-1))/(b-br)
        end if
        if l*2<tot then
            unrooted[t1] += c
        end if
        if b<BRANCH then
            rooted[t1] += c
            for m=1 to n-1 do
                tree(b,m,l,tot,c)
            end for
        end if
    end for
end procedure

procedure bicenter(integer s)
    if even(s) then
        atom aux = rooted[s/2+1]
        s += 1
        unrooted[s] += aux*(aux+1)/2
    end if
end procedure

rooted[1..2] = 1
unrooted[1..2] = 1
for n=1 to MAX_N do
    tree(0, n)
    bicenter(n)
    if n<10 or n=MAX_N then
        printf(1,"%d: %d\n",{n, unrooted[n+1]})
    end if
end for


program PangramChecker;

{$APPTYPE CONSOLE}

uses StrUtils;

function IsPangram(const aString: string): Boolean;
var
  c: char;
begin
  for c := 'a' to 'z' do
    if not ContainsText(aString, c) then
      Exit(False);

  Result := True;
end;

begin
  Writeln(IsPangram('The quick brown fox jumps over the lazy dog')); // true
  Writeln(IsPangram('Not a panagram')); // false
end.


proc nonrec pangram(*char s) bool:
    ulong letters;
    char c;
    byte b;
    byte A = pretend('a', byte);
    byte Z = pretend('z', byte);

    letters := 0L0;
    while
        c := s*;
        s := s + 1;
        c /= '\e'
    do
        b := pretend(c, byte) | 32;
        if b >= A and b <= Z then
            letters := letters | 0L1 << (b-A)
        fi
    od;
    letters = 0x3FFFFFF
corp

proc nonrec test(*char s) void:
    writeln("\"", s, "\": ",
            if pangram(s) then "yes" else "no" fi)
corp

proc nonrec main() void:
    test("The quick brown fox jumps over the lazy dog.");
    test("The five boxing wizards jump quickly.");
    test("Not a pangram")
corp


def isPangram(sentence :String) {
    return ("abcdefghijklmnopqrstuvwxyz".asSet() &! sentence.toLowerCase().asSet()).size() == 0
}


int MAX_N = 300;
int BRANCH = 4;

array ra = allocate(MAX_N);
array unrooted = allocate(MAX_N);

void tree(int br, int n, int l, int sum, int cnt)
{
    int c;
    for (int b = br + 1; b < BRANCH + 1; b++)
    {
        sum += n;
        if (sum >= MAX_N)
            return;

        // prevent unneeded long math
        if (l * 2 >= sum && b >= BRANCH)
            return;

        if (b == br + 1)
        {
            c = ra[n] * cnt;
        }
        else
        {
            c = c * (ra[n] + (b - br - 1)) / (b - br);
        }

        if (l * 2 < sum)
            unrooted[sum] += c;

        if (b < BRANCH)
        {
            ra[sum] += c;
            for (int m=1; m < n; m++)
            {
                tree(b, m, l, sum, c);
            }
        }
    }
}

void bicenter(int s)
{
    if (!(s & 1))
    {
        int aux = ra[s / 2];
        unrooted[s] += aux * (aux + 1) / 2;
    }
}

void main()
{
    ra[0] = ra[1] = unrooted[0] = unrooted[1] = 1;

    for (int n = 1; n < MAX_N; n++)
    {
        tree(0, n, n, 1, 1);
        bicenter(n);
        write("%d: %d\n", n, unrooted[n]);
    }
}


try:
    import psyco
    psyco.full()
except ImportError:
    pass

MAX_N = 300
BRANCH = 4

ra = [0] * MAX_N
unrooted = [0] * MAX_N

def tree(br, n, l, sum = 1, cnt = 1):
    global ra, unrooted, MAX_N, BRANCH
    for b in xrange(br + 1, BRANCH + 1):
        sum += n
        if sum >= MAX_N:
            return

        # prevent unneeded long math
        if l * 2 >= sum and b >= BRANCH:
            return

        if b == br + 1:
            c = ra[n] * cnt
        else:
            c = c * (ra[n] + (b - br - 1)) / (b - br)

        if l * 2 < sum:
            unrooted[sum] += c

        if b < BRANCH:
            ra[sum] += c;
            for m in range(1, n):
                tree(b, m, l, sum, c)

def bicenter(s):
    global ra, unrooted
    if not (s & 1):
        aux = ra[s / 2]
        unrooted[s] += aux * (aux + 1) / 2

def main():
    global ra, unrooted, MAX_N
    ra[0] = ra[1] = unrooted[0] = unrooted[1] = 1

    for n in xrange(1, MAX_N):
        tree(0, n, n)
        bicenter(n)
        print "%d: %d" % (n, unrooted[n])

main()


 [Pangram checker for Rosetta Code.
  EDSAC program, Initial Orders 2.]

 [Outline: Make a table, one entry per 5-bit character code.
  Initialize entry for each letter to 1.
  When a letter is read, convert its entry to 0.]

 [Subroutine to read string from the input and
    store it with character codes in low 5 bits.
  String is terminated by blank row of tape, which is stored.
  Input: 0F holds address of string in address field (bits 1..11).
  21 locations; workspace: 4F]
            T   56 K
  [email protected]@[email protected]@[email protected]@[email protected]@[email protected]

 [*************** Rosetta Code task ***************
  Subroutine to test whether string is a pangram.
  Input:  0F = address of string, characters in low 5 bits,
               terminated by blank row of tape.
  Output: 1F = (number of missing letters) - 1.
  87 memory locations; workspace 4F.]
            T   88 K
            G      K
            A    3 F  [make and plant link for return]
            T   48 @
       [Fill letter table with 1's.
        The code is a bit neater if we work backwards.]
            A   54 @  [index of last entry]
      [3]   A   51 @  [make T order for table entry]
            T    6 @  [plant in code]
            A   53 @  [acc := 1]
      [6]   T      F  [table entry := 1]
            A    6 @  [dec address in table]
            S    2 F
            S   51 @  [finished table?]
            E    3 @  [loop back if not]
       [Set non-letters to 0, except blank row := -1]
            T    4 F  [clear acc]
            T   66 @  [figures shift]
            T   70 @  [letters shift]
            T   73 @  [carriage return]
            T   75 @  [space]
            T   79 @  [line feed]
            S   53 @  [acc := -1]
            T   71 @  [blank row of tape]
       [Loop to read characters from string.
        Terminated by blank row of tape.
        Assume acc = 0 here.]
            A      F  [load address of string]
            A   49 @  [make order to read first char]
     [21]   T   22 @  [plant in code]
     [22]   A      F  [char to acc]
            L      D  [shift to address field]
            A   50 @  [make A order for this char in table]
            U   28 @  [plant in code]
            A   52 @  [convert to T order]
            T   31 @  [plant in code]
     [28]   A      F  [load table entry]
            G   35 @  [jump out if it's -1, i.e. blank row]
            T    4 F  [clear acc]
     [31]   T      F  [table entry := 0 to flag that letter is present]
            A   22 @  [inc address in input string]
            A    2 F
            G   21 @  [back to read next char]
       [Get total of table entries, again working backwards.
        The number of missing letters is (total + 1).]
     [35]   T    4 F  [clear acc]
            T    1 F  [initialize total := 0]
            A   54 @  [index of last entry]
     [38]   A   50 @  [make A order for table entry]
            T   41 @  [plant in code]
            A    1 F  [load total so far]
     [41]   A      F  [add table entry]
            T    1 F  [update total]
            A   41 @  [load A order]
            S    2 F  [dec address]
            S   50 @  [finished table?]
            E   38 @  [loop back if not]
            T    4 F  [clear acc before exit]
     [48]   E      F
  [Constants]
     [49]   A      F  [to make A order referring to input]
     [50]   A   55 @  [to make A order referring to table]
     [51]   T   55 @  [to make T order referring to table]
     [52]   O      F  [add to A order to convert to T order]
     [53]   P      D  [constant 1]
     [54]   P   31 F  [to change address by 31]
  [Table]
     [55]   PFPFPFPFPFPFPFPFPFPFPF
     [66]   PFPFPFPF               [11 = figures shift]
     [70]   PF                     [15 = letters shift]
     [71]   PFPF                   [16 = blank row of tape]
     [73]   PFPF                   [18 = carriage return]
     [75]   PFPFPFPF               [20 = space]
     [79]   PFPFPFPFPFPFPFPF       [24 = line feed]

 [Main routine to demonstrate pangram-checking subroutine]
            T  200 K
            G      K
  [Constants]
      [0]   P   25 @  [address for input string]
      [1]   N      F  [letter N]
      [2]   Y      F  [letter Y]
      [3]   K 2048 F  [letter shift]
      [4]   @      F  [carriage return]
      [5]   &      F  [line feed]
      [6]   K 4096 F  [null char]
 [Enter with acc = 0]
      [7]   O    3 @  [set letters shift]
      [8]   A      @  [load address of input]
            T      F  [pass to input subroutine in 0F]
     [10]   A   10 @  [call input subroutine, doesn't change 0F]
            G   56 F
     [12]   A   12 @  [call pangram subroutine]
            G   88 F
       [We could print the number of missing letters,
        but we'll just print 'Y' or 'N'.]
            A    1 F  [load (number missing) - 1]
            E   18 @  [jump if not pangram]
            O    2 @  [print 'Y']
            G   19 @  [exit]
     [18]   O    1 @  [print 'N']
     [19]   O    4 @  [print CR, LF]
            O    5 @
            O    6 @  [print null to flush printer buffer]
            Z      F  [stop]
            T      F  [on Reset, clear acc]
            E    8 @  [and test another string]
     [25]             [input string goes here]
            E    7 Z  [define entry point]
            P      F  [acc = 0 on entry]
THE!QUICK!BROWN!FOX!JUMPS!OVER!THE!LAZY!DOG.


defmodule Pangram do
  def checker(str) do
    unused = Enum.to_list(?a..?z) -- to_char_list(String.downcase(str))
    Enum.empty?(unused)
  end
end

text = "The quick brown fox jumps over the lazy dog."
IO.puts "#{Pangram.checker(text)}\t#{text}"
text = (Enum.to_list(?A..?Z) -- 'Test') |> to_string
IO.puts "#{Pangram.checker(text)}\t#{text}"


-module(pangram).
-export([is_pangram/1]).

is_pangram(String) ->
  ordsets:is_subset(lists:seq($a, $z), ordsets:from_list(string:to_lower(String))).


#lang racket

(define MAX_N 33)
(define BRANCH 4)

(define rooted   (make-vector MAX_N 0))
(define unrooted (make-vector MAX_N 0))
(for ([i 2]) (vector-set! rooted i 1) (vector-set! unrooted i 1))

(define (vector-inc! v i d) (vector-set! v i (+ d (vector-ref v i))))

(define (choose m k)
  (if (= k 1) m
      (for/fold ([r m]) ([i (in-range 1 k)]) (/ (* r (+ m i)) (add1 i)))))

(define (tree br n cnt sum l)
  (let/ec return
    (for ([b (in-range (add1 br) (add1 BRANCH))])
      (define s (+ sum (* (- b br) n)))
      (when (>= s MAX_N) (return))
      (define c (* (choose (vector-ref rooted n) (- b br)) cnt))
      (when (< (* l 2) s) (vector-inc! unrooted s c))
      (when (= b BRANCH) (return))
      (vector-inc! rooted s c)
      (for ([m (in-range (sub1 n) 0 -1)]) (tree b m c s l)))))

(define (bicenter s)
  (when (even? s)
    (vector-inc! unrooted s (* (vector-ref rooted (/ s 2))
                               (add1 (vector-ref rooted (/ s 2)))
                               1/2))))

(for ([n (in-range 1 MAX_N)])
  (tree 0 n 1 1 n)
  (bicenter n)
  (printf "~a: ~a\n" n (vector-ref unrooted n)))


sub count-unrooted-trees(Int $max-branches, Int $max-weight) {
    my @rooted   = flat 1,1,0 xx $max-weight - 1;
    my @unrooted = flat 1,1,0 xx $max-weight - 1;

    sub count-trees-with-centroid(Int $radius) {
        sub add-branches(
            Int $branches,        # number of branches to add
            Int $w,               # weight of heaviest branch to add
            Int $weight  is copy, # accumulated weight of tree
            Int $choices is copy, # number of choices so far
        ) {
            $choices *= @rooted[$w];
            for 1 .. $branches -> $b {
                ($weight += $w) <= $max-weight or last;
                @unrooted[$weight] += $choices if $weight > 2*$radius;
                if $b < $branches {
                    @rooted[$weight] += $choices;
                    add-branches($branches - $b, $_, $weight, $choices) for 1 ..^ $w;
                    $choices = $choices * (@rooted[$w] + $b) div ($b + 1);
                }
            }
        }
        add-branches($max-branches, $radius, 1, 1);
    }

    sub count-trees-with-bicentroid(Int $weight) {
        if $weight %% 2 {
            my \halfs = @rooted[$weight div 2];
            @unrooted[$weight] += (halfs * (halfs + 1)) div 2;
        }
    }

    gather {
        take 1;
        for 1 .. $max-weight {
            count-trees-with-centroid($_);
            count-trees-with-bicentroid($_);
            take @unrooted[$_];
        }
    }
}

my constant N = 100;
my @paraffins = count-unrooted-trees(4, N);
say .fmt('%3d'), ': ', @paraffins[$_] for flat 1 .. 30, N;


ISPANGRAM
=LAMBDA(s,
    LET(
        abc, CHARS(LOWER("abcdefghijklmnopqrstuvwxyz")),
        AND(
            LAMBDA(c,
                ISNUMBER(SEARCH(c, s, 1))
            )(
                abc
            )
        )
    )
)


let isPangram (str: string) = (set['a'..'z'] - set(str.ToLower())).IsEmpty


: pangram? ( str -- ? )
    [ "abcdefghijklmnopqrstuvwxyz" ] dip >lower diff length 0 = ;

"How razorback-jumping frogs can level six piqued gymnasts!" pangram? .


: pangram? ( addr len -- ? )
  0 -rot bounds do
    i [email protected] 32 or [char] a -
    dup 0 26 within if
      1 swap lshift or
    else drop then
  loop
  1 26 lshift 1- = ;

s" The five boxing wizards jump quickly." pangram? .   \ -1


/*REXX pgm enumerates (without repetition) the number of paraffins with N carbon atoms. */
parse arg nodes .                                /*obtain optional argument from the CL.*/
if nodes=='' | nodes==","  then nodes= 100       /*Not specified?  Then use the default.*/
  rooted. =  0;     rooted.0= 1;     rooted.1= 1 /*define the  base     rooted  numbers.*/
unrooted. =  0;   unrooted.0= 1;   unrooted.1= 1 /*  "     "     "    unrooted     "    */
numeric digits max(9, nodes % 2)                 /*this program may use gihugeic numbers*/
w= length(nodes)                                 /*W:  used for aligning formatted nodes*/
say  right(0, w)  unrooted.0                     /*show enumerations of  0  carbon atoms*/
                                                 /* [↓]  process all nodes (up to NODES)*/
          do C=1  for nodes;           h= C % 2  /*C:   is the number of carbon atoms.  */
          call  tree  0, C, C, 1, 1              /* [↓]  if # of carbon atoms is even···*/
          if \(C//2)  then unrooted.C= unrooted.C    +    rooted.h * (rooted.h + 1)  %  2
          say right(C, w)  unrooted.C            /*display an aligned formatted number. */
          end   /*C*/
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
tree: procedure expose rooted. unrooted. nodes #.          /*this function is recursive.*/
      parse arg br,n,L,sum,cnt;             nm= n - 1;            LL= L + L
      brp= br + 1
                        do b=brp  to 4;     sum= sum + n
                        if sum>nodes  then leave
                        if b==4       then if LL>=sum  then leave
                        if b==brp     then #.br= rooted.n * cnt
                                      else #.br= #.br  *  (rooted.n + b - brp) % (b - br)
                        if LL<sum     then unrooted.sum= unrooted.sum  +  #.br
                        if b==4       then leave
                        rooted.sum= rooted.sum + #.br
                           do m=nm  by -1  for nm;            call tree b, m, L, sum, #.br
                           end   /*m*/
                        end      /*b*/                     /* ↑↑↑↑↑↑↑↑↑   recursive.    */
      return


MAX_N = 500
BRANCH = 4

def tree(br, n, l=n, sum=1, cnt=1)
  for b in br+1 .. BRANCH
    sum += n
    return if sum >= MAX_N
    # prevent unneeded long math
    return if l * 2 >= sum and b >= BRANCH
    if b == br + 1
      c = $ra[n] * cnt
    else
      c = c * ($ra[n] + (b - br - 1)) / (b - br)
    end
    $unrooted[sum] += c if l * 2 < sum
    next if b >= BRANCH
    $ra[sum] += c
    (1...n).each {|m| tree(b, m, l, sum, c)}
  end
end

def bicenter(s)
  return if s.odd?
  aux = $ra[s / 2]
  $unrooted[s] += aux * (aux + 1) / 2
end

$ra       = [0] * MAX_N
$unrooted = [0] * MAX_N

$ra[0] = $ra[1] = $unrooted[0] = $unrooted[1] = 1
for n in 1...MAX_N
  tree(0, n)
  bicenter(n)
  puts "%d: %d" % [n, $unrooted[n]]
end


module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram


' FB 1.05.0 Win64

Function isPangram(s As Const String) As Boolean
  Dim As Integer length = Len(s)
  If length < 26 Then Return False
  Dim p As String = LCase(s)
  For i As Integer = 97 To 122
    If Instr(p, Chr(i)) = 0 Then Return False
  Next
  Return True
End Function

Dim s(1 To 3) As String = _
{ _
 "The quick brown fox jumps over the lazy dog", _
 "abbdefghijklmnopqrstuVwxYz", _ '' no c!
 "How vexingly quick daft zebras jump!" _
}

For i As Integer = 1 To 3:
  Print "'"; s(i); "' is "; IIf(isPangram(s(i)), "a", "not a"); " pangram"
  Print
Next

Print
Print "Press nay key to quit"
Sleep


object Paraffins extends App {
  val (nMax, nBranches) = (250, 4)
  val rooted, unrooted = Array.tabulate(nMax + 1)(i => if (i < 2) BigInt(1) else BigInt(0))
  val (unrooted, c) = (rooted.clone(), new Array[BigInt](nBranches))

  for (n <- 1 to nMax) {
    def tree(br: Int, n: Int, l: Int, inSum: Int, cnt: BigInt): Unit = {
      var sum = inSum
      for (b <- br + 1 to nBranches) {
        sum += n
        if (sum > nMax || (l * 2 >= sum && b >= nBranches)) return

        if (b == br + 1) c(br) = rooted(n) * cnt
        else {
          c(br) = c(br) * (rooted(n) + BigInt(b - br - 1))
          c(br) = c(br) / BigInt(b - br)
        }
        if (l * 2 < sum) unrooted(sum) = unrooted(sum) + c(br)
        if (b < nBranches) rooted(sum) = rooted(sum) + c(br)

        for (m <- n - 1 to 1 by -1) tree(b, m, l, sum, c(br))
      }
    }

    def bicenter(s: Int): Unit = if ((s & 1) == 0) {
      val halves = rooted(s / 2)
      unrooted(s) = unrooted(s) + ((halves + BigInt(1)) * halves >> 1)
    }

    tree(0, n, n, 1, BigInt(1))
    bicenter(n)
    println(f"$n%3d:  ${unrooted(n)}%s")
  }
}


s = "The quick brown fox jumps over the lazy dog."
println["\"$s\" is" + (isPangram[s] ? "" : " not") + " a pangram."]

isPangram[s] :=
{
   charSet = toSet[charList[lc[s]]]
   for c = char["a"] to char["z"]
      if ! charSet.contains[char[c]]
         return false

   return true
}