FunctionRacerProblemsRace

Value of a Logic Formula

HardStacks and queuesPython, JavaScript, TypeScript, Java, C++

formula is built by these rules, with no spaces:

The brackets of & and | hold one or more formulas, separated by commas. Return the value of formula as True or False.

Example 1

formula "&(t,|(f,t))"
returns true

The inner | is true because one of its parts is true. Then both parts of the & are true.

Example 2

formula "!(|(f,t))"
returns false

The | is true, so its negation is false.

Example 3

formula "&(t,t,f,t)"
returns false

An & with a false part is false, whatever the other parts are.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Stacks and queues problems