PSeInt Repetir Hasta Que (repeat-until) exercises
7 examples
How it works
Repetir runs a block and only checks the condition at the end. So it always makes at least one pass, even if the condition already holds from the start.
With Hasta Que (until), the loop ends when the condition becomes true. It's the natural way to validate: "ask for the grade until it's between 0 and 100". Mientras Que (while) is the other way round: it keeps going while the condition is true.
The difference from Mientras is when the condition is checked. If the block has to run once before there's anything to ask about (like reading a value), Repetir is usually shorter.
Short example
The least you need to see it work. Copy it or open it in the editor.
Algoritmo ValidateGrade Definir nota Como Real Repetir Escribir "Grade (0 to 100):" Leer nota Hasta Que nota >= 0 Y nota <= 100 Escribir "Grade saved: ", notaFinAlgoritmoWhat it prints:
Grade (0 to 100):User answer: 120Grade (0 to 100):User answer: -1Grade (0 to 100):User answer: 85Grade saved: 85
Opens in the browser editor, nothing to install.
Solved exercises
Each exercise comes with the full code, its flowchart and a sample run.
Password Check
Keeps asking for a password until it has at least 8 characters.
BeginnerReusable Validation
Validates the email and age on a sign-up form.
IntermediateModular Menu
A unit converter with a menu that keeps coming back.
IntermediateQuicksort
Picks a pivot, splits smaller from larger values and sorts each side recursively.
AdvancedTic-Tac-Toe
The classic three-in-a-row game for two players.
AdvancedATM
Checks your PIN and lets you check, deposit and withdraw money.
AdvancedContact Book
Add, list and search contacts in a book that grows.
Advanced
In the language reference
The instructions involved, explained one by one.
Other concepts
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.