Title | ITECH 1400 - Assignment 1-Thue Morse Sequences - Kishani Agulugahagamage 30397085 |
---|---|
Author | Kishani Agulugahagamage |
Course | Foundations of Programming |
Institution | Federation University Australia |
Pages | 4 |
File Size | 373.3 KB |
File Type | |
Total Downloads | 345 |
Total Views | 385 |
Assignment 1ITECH – 1400Kishani AgulugahagamageStudent ID: 303970851 | P a g eTask -1 Building Thue-Morse SequenceIn this task you are required to write a Python function named thue_morse(n), that takes a positive integer parameter, n, and returns the string tn (defined above). In your program you m...
Assignment 1 ITECH – 1400
Kishani Agulugahagamage Student ID: 30397085
Task -1 Building Thue-Morse Sequence
In this task you are required to write a Python function named thue_morse(n), that takes a positive integer parameter, n, and returns the string tn (defined above). In your program you may define other (auxiliary) functions with arbitrary names, however, the solution function of this task should be named thue_morse(n).
In this task we defined python function called thue_morse(n) and then we initialized two string values ‘0’ and ‘1’ to X and Y. As the next step we created a for loop start from 0 and it will iterate until n (whatever number we called in function). Inside the for loop, we have a function X and Y and inverse of X and Y as Y and X. Finally, it will return the value of X.
1|P age
Task – 2 Building a square-free word in the alphabet of three symbols
2.1. Construction of the Square-Free Word
2.2. The Programming Tasks a) You are required to write a Python function named square_free(n), that takes a positive integer parameter n and returns the string an (defined above). Again, as in Task 1, you may define other (auxiliary) functions with arbitrary names, however, the solution function of this task should be named square_free(n).
2|P age
b) Write a Python function named print3Blocks(s) that takes a string, s, as a parameter and prints it in blocks of 3 symbols separated by white spaces.
Task 3. Counting the number of squares in a string. In this task you are required to write a Python function named count_squares(s) that takes a string, s, as a parameter and returns the number of “squares” in s, i.e., the number of occurrences of two consecutive identical sub-words in s.
3|P age...