ITECH1400 Fundamentals of Programming Assignment

Assignment Help Python Programming
Reference no: EM132876510

ITECH1400 Fundamentals of Programming - Federation University

ASSIGNMENT 1 - Thue-Morse Sequences

Overview
In this assignment you will have the opportunity to test your Python skills in generating and manipulating text. Throughout the assignment you are expected to apply the principles of problem solving that we have already discussed in this course.

Knowledge:
K1. Identify and use the correct syntax of a common programming language.
K2. Recall and use typical programming constructs to design and implement simple software solutions.
K4. Explain the importance of programming style concepts (documentation, mnemonic names, indentation).

Skills:
S1. Utilise pseudocode and/or algorithms as a major program design technique.
S2. Write and implement a solution algorithm using basic programming constructs.
S4. Describe program functionality based on analysis of given program code.

Application of knowledge and skills:
A1. Develop self-reliance and judgement in adapting algorithms to diverse contexts.
A2. Design and write program solutions to identified problems using accepted design constructs.

ASSESSMENT DETAILS
0.Introduction. The Thue-Morse sequence is an infinite word in the alphabet of two symbols, ‘0' and ‘1', which can be constructed in the following way:
(0) t0 = ‘0'
(1) t1 = ‘0' + ‘1' = ‘01'
(2) t2 = ‘01' + ‘10' = ‘0110'
(3) t3 = ‘0110' + ‘1001' = ‘01101001'
...

(n) tn = tn-1 + (tn-1)‾, where (tn-1)‾ denotes the ‘inverse' of tn-1, i.e. all ‘0's in tn-1 are replaced by ‘1's and vice versa.

It is easy to see that each ti is the first half of ti+1, and ti+1 can be seen as an extension of ti.

This sequence of extensions can be performed infinitely many times, thus building an infinite word, T, which contains all tis as its prefixes (beginnings):
T = ‘0110100110010110100101100110100110010110011010010...'
T has an important property: it does not contain "cubes", i.e. three consecutive identical blocks (sub-words).
Thue-Morse sequence has multiple applications ranging from Chess to Group Theory and Differential Geometry.

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).

Task 2. Building a square-free word in the alphabet of three symbols.

In this task you are required to write a function in Python that builds an arbitrarily long (potentially infinite) square-free word in the alphabet of three symbols, ‘1', ‘2', ‘3'. I.e. a word that does not contain "squares" - two consecutive identical sub-words.
Although, this can be done by using the Thue-Morse sequence, in this task we will use another construction, suggested by S. Arshon.

Construction of the Square-Free Word: Again, as in Task 1, we will build a sequence of finite words, ai, that can be extended to an infinite word.
We start with a0 = ‘1'.
Each next word, ak+1, is constructed by replacing each occurrence of the symbols ‘1', ‘2', ‘3' in the previous word, ak, with 3- letter words according to the following rules:

(1) if symbol ‘1' is in an odd position in ak, then it is replaced with the word ‘123', if ‘1' is in even position, it is replaced with ‘321'.

(2) if symbol ‘2' is in an odd position in ak, then it is replaced with the word ‘231', if ‘2' is in even position, it is replaced with ‘132'.

(3) if symbol ‘3' is in an odd position in ak, then it is replaced with the word ‘312', if ‘3' is in even position, it is replaced with ‘213'.

Here's the table repeating the replacement rules in a tabular format:

Symbols in odd positions

Replacement string for odd positions

Symbols in even positions

Replacement string for even positions

1

123

1

321

2

231

2

132

3

312

3

213

Please note, that in this description the first symbol is considered to be in position 1. Therefore, you will need to make


the necessary adjustments when using Python strings, which are zero-based.

Below you can see the first few steps of the construction process:
a0 = ‘1'
a1 = ‘123'
a2 = ‘123132312'
a3 = ‘123132312321312132312321231'
...
A = ‘1231323123213121323123212312132313213123212313213121323...'

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).

(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. For example, print3Blocks(a3) will print:

123 132 312 321 312 132 312 321 231

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.

For example, count_squares (‘1231233') should return 2 as there are two "squares" in its argument: ‘1231233' and ‘1231233'.

Attachment:- Thue-Morse Sequences.rar

Reference no: EM132876510

Questions Cloud

Research paper on semiconductor : How would you recommend for MGT Semiconductor Co. to proceed? Should it stay with the same production capacity or increase it as described above?
Various types of airport planning studies : For this sixth short paper, describe the various types of airport planning studies and identify the focus of each type of study.
Describe what critical path is in project : Describe what critical path is in project. Describe a time in your career or your personal life, when critical path item controlled the length of the timeline
Create an mvc web application : Create an MVC web application and Create model classes that are specific in ERD - Design your own entity relationship diagram (ERD) for the classes
ITECH1400 Fundamentals of Programming Assignment : ITECH1400 Fundamentals of Programming Assignment Help and Solution, Federation University - Assessment Writing Service
MA609 Business Analytics and Data Intelligence Assignment : MA609 Business Analytics and Data Intelligence Assignment Help and Solution, Melbourne Institute of Technology - Assessment Writing Service
Deploy the system on cloud instance : Deploy the system on Cloud Instance (EC2 or VM) and you will deploy the database on database instance on the same provider (Like RDS, Azure SQL etc).
NUR251 Medical Surgical Nursing Assignment : NUR251 Medical Surgical Nursing Assignment Help and Solution, Charles Darwin University - Assessment Writing Service
Non -repudiation and anonymity protocols : Non -Repudiation and Anonymity Protocols - Cryptographic Data Objects - Example 2 Rule 3" was changed to "Permit", then the outcome of the request

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd