Skip to the content.

Seed Review

Seed Review Blog

MCQ Review

Categories for Improvement

Question Review

  • Score: 59/67
  • Q11 Color represented by binary triplet: Did the binary to base 10 conversion of the RGB triplet given wrong (11111111, 11111111, 11110000), I approximated the final number instead of calcuating it which was a mistake.
  • Q15 Compare output of program a and b: While half of my logic was correct (i.e the part that identified both programs have same number of entires), I thought they have different values when they didn’t. Going through a few concrete examples for each algorithm would be a useful tool in future problems.
  • Q18 Algorithm to move robot to goal: Didn’t read the question correctly, I thought that the black section was a walll rather than something that termiantes the robot.
  • Q27 Existence of unsolvable problems: Moore’s Law is the observation that the number of transistors on a computer chip doubles roughly every two years, and this improves performance thus by this observation performance is not a problem. Rather it is the lack of algorithms to solve certain complex problems, although some optimization problems are limited by classical computer’s efficiency and provide a premise and usecase for quantum computing in the future. The algorithm option is the better answer despite the other option choice holding true in some cases.
  • Q40 Role of certificate authorities: Didn’t know that a certificate authority verifies the authenticity of encryption keys used in secured communications.
  • Q50 Reasonable time algorithms: I knew that 1 and 3 were reasonable time but wasn’t sure if n^2 was considered reasnonable time for a large n, thus choose the last one despite it not making complete sense. Will employ process of elimination in the future in the future, and will consider n^2 as reasonable run time.
  • Q66 Error in counting perfect numbers: Logical mistake - didn’t read the purpose of the algorithm correctly and thus got wrong answer.
  • Q67 Error in numOccurrences procedure: Didn’t understand the question and what it was asking for, moreover the purpose of the algorithm and its function was confusing for this question.

Improvement

  • 4 question improvement upon last time, which shows improvement and developement of core skills.
  • Compared to last time got the questions about encryption and got a 100% on the network section of the test, which is an improvement compared to last time. Moreover, I had a five question improvement upon last time.
  • However I still need to focus on maintaing focus on the test and reading all the questions carefully even towards the end of the examination, also it seems I need to focus on safe computing and algorithmic error

Project Feature Writeup (PPR & FRQ Language)

Call to Algorithm:

    async function deleteGame(id, name) {
        let user_name = await getUser();
        if (user_name.toLowerCase() !== name.toLowerCase()) {
            console.log('Logged in user cannot remove another users card')
            return
        }

        try {
            const response = await fetch(`${pythonURI}/api/pgn`, {
                method: 'DELETE',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ id: id })
            });
            if (!response.ok) {
                throw new Error('Failed to delete: ' + response.statusText);
            }

            fetchGames();
        } catch (error) {
            console.error('Error deleting entry:', error);
        }
    }

Explanation:

  • Here we have an async function that first calls a getUser function to get the current logged in user, and if the logged in user matches the username of the card they are trying to delete, then the sequencing is continued. Then a call to algorithm is made, where the DELETE algorithm is ran on the backend when the fetch request was made to the /api/pgn endpoint with the proper method and body data allowing for the backend to be updated after which the frontend is subsequently updated with another fetchGames function call.

Function (sequencing, iteration, selection):

   async function fetchGames(){
        try {
            const response = await fetch(`${pythonURI}/api/pgns`, fetchOptions);
            if (!response.ok) {
                throw new Error('Failed to fetch groups: ' + response.statusText);
            }

            const games = await response.json();
            const container = document.getElementById('cards-container');
            container.innerHTML = '';

            games.forEach(game => {
                const card = document.createElement('div');
                card.className = 'card';
                card.innerHTML = `
                    <h2>${game.name}</h2>
                    <h4>Played By: ${game.user_name}</h4>
                    <br>
                    <p>${game.pgn}</p>
                    <button class="button update">Update</button>
                    <button class="button delete">Delete</button>
                    <button class="button analyze">Analyze</button>
                    <button class="button download">Download PGN File</button>
                `;

                card.querySelector('.delete').addEventListener('click', () => deleteGame(game.id, game.user_name));
                card.querySelector('.update').addEventListener('click', () => updateGame(game.id, game.user_name));
                card.querySelector('.analyze').addEventListener('click', () => redirectToAnalyze());
                card.querySelector('.download').addEventListener('click', () => downloadFile(game.pgn));
                container.appendChild(card);
            });
        } catch (error) {
            console.error('Error fetching entries:', error);
        }
    }

Explanation:

  • The sequencing of the function call is as follows, first a fetch is made to the /api/pgns endpoint which is a BULK CRUD endpoint that returns all the chess game entries from the PGN table of the database as a json object. The forEach loop then performs iteration and goes through the list to then utlize the DOM (document object model) and create a card with numerous elements in it: a H3, H4, buttons with event listeners, and p tags. This code is all wrapped in a try-catch statement for error handling within the application, which shows the selection as try-except loops are are considered selection for they are a form of conditional that checks for errors. Moreover, there is other error handling that checks whether the response is acceptable before continuing, else an error is thrown.

List Creation

    class _BULK_CRUD(Resource):
        def get(self):
            pgns = Pgn.query.all()
            json_ready = []
            for pgn in pgns:
                print(pgn)
                pgn_data = pgn.read()
                json_ready.append(pgn_data)
            return jsonify(json_ready)

Explanation:

  • This python function for my games REST API queries the pgn table of the SQLite3 database, to return all the games which it does then stores in the list pgns, each pgn is then processed as the read method of the pgn object is ran, and the output is saved in the json_ready list which is returned by the function in a json format.

List Processing

            json_ready = []
            for pgn in pgns:
                print(pgn)
                pgn_data = pgn.read()
                json_ready.append(pgn_data)

Explanation:

  • This code block creates a new list called json_ready, the for loop then uses iteration to loop through the pgns list, and then perform the read method of the pgn object, save that in a variable called pgn_data then append it to the json_ready list. This could be done using list comprehension, but I wrote it in a traditional for loop so I could perform debugging when an issue occured.