Validate and Generate Swiss IBAN Check Digits for Client Accounts
Last updated: November 29, 2026
Quick Overview
Write a function that validates a Swiss IBAN (country code CH, 21 characters) using the ISO 13616 mod 97 check, and a second function that builds a valid IBAN from a 5 digit bank clearing number and a 12 character account number.
UBS
November 29, 20260
0
0 solved
Write a function that validates a Swiss IBAN (country code CH, 21 characters) using the ISO 13616 mod 97 check, and a second function that builds a valid IBAN from a 5 digit bank clearing number and a 12 character account number.
A warm-up in the style of a UBS graduate or early-career coding assessment, set in the Personal and Corporate Banking payments domain where every incoming payment instruction carries an IBAN. The grader checks that you read a precise spec, handle the big-number arithmetic without overflow, and reject malformed input instead of crashing.
What the Interviewer Expects
- Normalize input by removing spaces and upper-casing
- Check length, country prefix and character classes before doing arithmetic
- Implement the rearrange, letter-to-number and mod 97 steps correctly
- Compute the mod incrementally so it ports to languages with 64-bit integers
- Derive check digits as 98 minus the remainder of the IBAN with 00 placeholders
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you generalize this to all SEPA countries with different lengths and BBAN formats?
- Why does a mod 97 check catch every single-digit error and nearly all transpositions?
- Where should this validation live in a payment pipeline: client, API gateway, or payment engine?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
A Swiss IBAN is CH + 2 check digits + 5 digit clearing number (IID) + 12 alphanumeric account characters, 21 characters total. Printed IBANs contain spaces every 4 characters, so the function should...
High-Level Design
The ISO algorithm: move the first four characters to the end, replace each letter with two digits (A = 10 ... Z = 35), interpret the result as a big integer and require value mod 97 == 1. Python has...