Watch ChatGPT compete in 4 coding problems against Software Engineer
AD
Table of Contents
- Introduction
- Challenge 1: Writing "Hello World" in Different Programming Languages
- 2.1 Python Implementation
- 2.2 JavaScript Implementation
- 2.3 Evaluation
- Challenge 2: Implementing Quick Sort Algorithm
- 3.1 Quick Sort Implementation in Python
- 3.2 Space and Time Complexity Explanation
- 3.3 Evaluation
- Challenge 3: Recreating a Python Script for Google Search with Filters
- 4.1 Requirements
- 4.2 Implementation using Selenium
- 4.3 Alternative Implementation using Web Browser Package
- 4.4 Evaluation
- Challenge 4: Recreating a Full-Stack Web Application
- 5.1 Project Overview
- 5.2 Next.js and Tailwind CSS Boilerplate
- 5.3 Handling User Registration and Food Items Page
- 5.4 Evaluation
- The Impact of Chat GPT on Software Engineering
- 6.1 Job Transformation
- 6.2 Pros and Cons
- Conclusion
Challenge 1: Writing "Hello World" in Different Programming Languages
In this first challenge, we test Chat GPT's ability to write a simple "Hello World" program in multiple programming languages. We start with Python and then move on to JavaScript, with an additional requirement of allowing a template STRING with a variable.
2.1 Python Implementation
print("Hello, World!")
2.2 JavaScript Implementation
console.log(`Hello, ${name}!`);
2.3 Evaluation
Chat GPT was able to provide correct implementations for both Python and JavaScript versions of the "Hello World" program. While the response time was slower than expected, the program executed successfully. However, there is room for improvement in terms of speed.
Challenge 2: Implementing Quick Sort Algorithm
In this challenge, we explore Chat GPT's ability to implement the quick sort algorithm and explain its space and time complexity.
3.1 Quick Sort Implementation in Python
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr)//2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
3.2 Space and Time Complexity Explanation
The quick sort algorithm sorts an array by using the divide and conquer approach. It selects a pivot as the middle element and divides the array into three parts: the elements less than the pivot, the elements equal to the pivot, and the elements greater than the pivot. This process is applied recursively until the base case is reached, where the array has a length of zero or one.
The time complexity of quick sort is O(n log n) on average, where n is the number of elements in the array. This is because each recursive call splits the array in half, resulting in logarithmic calls with respect to the size of the array. In the worst case Scenario, where the pivot is always the smallest or largest element, the time complexity becomes O(n^2). The space complexity is O(log n) on average and O(n) in the worst case, due to the memory used by the recursive calls.
3.3 Evaluation
Chat GPT provided a correct implementation of the quick sort algorithm in Python. It also explained the space and time complexity accurately, including the average and worst-case scenarios. The code was well-written and elegant, showcasing a good programming style.
Challenge 3: Recreating a Python Script for Google Search with Filters
In this challenge, we task Chat GPT with recreating a Python script that allows users to perform Google searches with specific Website filters. The aim is to improve the functionality of Google search by filtering results from more organic websites.
4.1 Requirements
- Create a Python script that takes a Google search query with site filters.
- Open Google and perform the search query with the applied filters.
- Make the script executable from the command line with the command
s followed by the query.
- Include site filters for websites like reddit.com, stackoverflow.com, and stackexchange.com.
4.2 Implementation using Selenium
from selenium import webdriver
def search_with_filters(query, site_filters):
driver = webdriver.Firefox()
driver.get(f"https://www.google.com/search?q={query}+site:{site_filters}")
4.3 Alternative Implementation using Web Browser Package
import webbrowser
def search_with_filters(query, site_filters):
search_url = f"https://www.google.com/search?q={query}+site:{site_filters}"
webbrowser.open_new_tab(search_url)
4.4 Evaluation
While Chat GPT initially provided an implementation using Selenium, it was not ideal as it required specific browser installations. However, upon revising the prompt, Chat GPT successfully provided an alternative implementation using the web browser package, which is more suitable for the task. The code worked correctly, allowing users to perform Google searches with specific site filters.
Challenge 4: Recreating a Full-Stack Web Application
In this final challenge, we test Chat GPT's ability to recreate a full-stack web application. The application in question is called "Pool," and it simplifies group decision-making by providing an easy way to plan activities or choose Where To eat.
5.1 Project Overview
The "Pool" app is built using Next.js and Tailwind CSS for the front end and Super Base for the back end. It allows users to create a list of options and vote on their preferred choice.
5.2 Next.js and Tailwind CSS Boilerplate
// Next.js and Tailwind CSS boilerplate code
5.3 Handling User Registration and Food Items Page
// Code to handle user registration and creation of food items page
5.4 Evaluation
While Chat GPT provided a solid initial implementation for the "Pool" app using Next.js and Tailwind CSS, there were some missing details. The handle get started function required modifications, and the Super Base library was not utilized correctly. With additional Prompts and refining, it is possible to obtain the complete and accurate code for creating the user registration and food items page.
The Impact of Chat GPT on Software Engineering
6.1 Job Transformation
The introduction of Chat GPT and similar AI Tools is likely to transform the role of software engineers rather than rendering their jobs obsolete. Software engineers may no longer need to spend time on basic implementation tasks that AI can handle. Instead, they can focus on higher-level design, architecture, optimization, and solving more complex problems.
6.2 Pros and Cons
Pros:
- Increased productivity: AI can quickly generate code snippets, solve simple problems, and perform routine tasks, allowing software engineers to work on more challenging projects.
- Efficient prototyping: AI tools like Chat GPT can help rapidly prototype and validate ideas, enabling faster development cycles.
Cons:
- Limited understanding: AI tools may lack deep understanding of Context, business requirements, and edge cases, leading to potential errors or suboptimal solutions.
- Ethical concerns: The use of AI in software engineering raises ethical considerations such as accountability, bias, and data privacy.
Conclusion
Chat GPT shows promise in its ability to generate code and assist software engineers in various coding challenges. While it may still require refinement and verification from human developers, it can significantly impact software engineering practices and lead to a transformation in job responsibilities. As the technology advances, AI tools like Chat GPT have the potential to enhance software development processes and drive innovation in the field.
Highlights
- Chat GPT showcases proficiency in writing code and solving coding challenges.
- It successfully implements "Hello World" in different programming languages.
- Chat GPT accurately implements the quick sort algorithm and explains its space and time complexity.
- The tool can recreate a Python script for Google search with filters using Selenium or an alternative web browser package.
- Chat GPT can partially recreate a full-stack web application, requiring some modifications for complete functionality.
- The impact of Chat GPT on software engineering includes job transformation and increased productivity, but also raises concerns regarding understanding and ethics.
FAQ
Q: Can Chat GPT replace software engineers?
A: While Chat GPT showcases impressive code-writing capabilities, it is unlikely to replace software engineers entirely. Instead, it will serve as a valuable tool to enhance productivity and streamline certain aspects of the development process.
Q: What are the advantages of using Chat GPT for software engineering?
A: Chat GPT can boost productivity by generating code snippets, solving simple problems, and aiding in prototyping. It enables software engineers to focus on more complex tasks, design, and optimization.
Q: Are there any downsides to using AI tools like Chat GPT in software engineering?
A: One potential downside is the limited understanding of context and edge cases that AI tools may exhibit. This can result in errors or suboptimal solutions. Additionally, ethical concerns related to accountability, bias, and data privacy should be considered when implementing AI in software engineering workflows.