Git Product home page Git Product logo

-algorithmtest's Introduction

Python Project 3

Project Overview

This project contains solutions for two problems along with their corresponding unit tests. The project structure is as follows:

pythonProject3/
│
├── problem1.py
├── problem2.py
├── run_tests.py
└── test/
    ├── test_problem1.py
    └── test_problem2.py

Problem Descriptions

Problem 1: Shortest Way to Form String

Given two strings source and target, return the minimum number of subsequences of source such that their concatenation equals target. If the task is impossible, return -1.

Examples:

  • source = "abc", target = "abcbc", Output: 2
  • source = "abc", target = "acdbc", Output: -1
  • source = "xyz", target = "xzyxz", Output: 3

Problem 2: Check Parentheses

Given a list of strings containing parentheses, check if the parentheses are balanced. If there are unmatched left parentheses, mark them with x; if there are unmatched right parentheses, mark them with ?.

Example Input:

"bge)))))))))" 
"((IIII))))))" 
"()()()()(uuu" 
"))))UUUU((()" 

Example Output:

" ?????????" 
" ????" 
" x " 
"???? xx " 

Files Description

  • problem1.py - Contains the solution for Problem 1.
  • problem2.py - Contains the solution for Problem 2.
  • run_tests.py - Script to run all tests at once.
  • test/test_problem1.py - Unit tests for Problem 1.
  • test/test_problem2.py - Unit tests for Problem 2.

Usage Instructions

Running Tests

To run all tests, execute the following command in the project's root directory:

python run_tests.py

-algorithmtest's People

Contributors

rjzhb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.