October 2025
🔄
Functions
Challenge Instructions
For AS especially, they sometimes might ask you to implement one of the given functions (i.e. as if you were creating the programming language from scratch) from either fundamental constructs (iteration (loops), selection (if/case) etc), or from a subset of the other functions on the course
Below are all the functions for both IGCSE/O-Level and AS - let's try to implement as many as possible as a group
If you are confused about any of these function's operation, you can see the syllabus for IGCSE & O-Level, the official pseudocode guide for AS or the demo programs on this site
For example, you can call you function MY_SUBSTRING for example and create a series of tests like: OUTPUT MY_SUBSTRING("abcde", 2, 3") = SUBSTRING("abcde", 2, 3) to ensure your functions work as expected
IGCSE & O-Level Functions
- DIV
- MOD
- LENGTH (in some languages like C, the null terminator (ASCII code 0) is used to signify the end of a string - for IG, you can't really do this...perhaps just say "!" signifies the end of the string - i.e. LENGTH("hello!") would return 5, since there's 5 valid characters
- LCASE & UCASE - not possible with other IG functions
- SUBSTRING
- ROUND
- RANDOM - could implement your own simple pseudorandom number generator that starts with a seed value, then produces a sequence of numbers
AS Functions
- LEFT
- RIGHT
- MID
- LENGTH - as in the IG example above - but this time, you can use the null terminator (character with ASCII code 0) to signify the end of a string
- TO_UPPER
- TO_LOWER
- NUM_TO_STR
- STR_TO_NUM
- IS_NUM
- ASC - not possible
- CHR - not possible
- INT
- RAND - see "RANDOM" for IG. Remember, RAND also takes a parameter
- DAY - assume given a date string, return characters representing day number - e.g. "29/09/2025" would return 29
- MONTH - as above, but for the month number
- YEAR - as above, but for the year number
- DAYINDEX - possible can set a known day index (e.g. Jan 1st 0001 was a Monday, as was Jan 1st 1900) and calculate any current dayindex based off of that
- SETDATE
- TODAY - not possible
You can also create your own functions or simulate e.g. bitwise operators - AND("0011", "1010") would return "0010" as a string...or 2 if you decide to return an integer
Or create a function to check if two strings are equal, without using the = operator for string comparisons
As a target, let's try and have 10 programs submitted by members of the community for others to enjoy...good luck...and have fun!
Top Submissions
Submission Instructions
Create your program on the editor page, then click the upload button at the bottom of the code editor as shown below
Once you are confident your program is working well without obvious bugs, then give it a relevant name, choose the current monthly challenge from the dropdown box, choose some program categories if you want and submit it :)
Note: your submitted programs will be in blue and you can overwrite them by opening them, clicking the upload button again and selecting "overwrite"