stringsAndLoops

A Python script that separates even and odd indexed characters from input strings.

https://github.com/davidbmar/stringsAndLoops  ·  public  ·  shipped

What it is

A command-line utility designed for coding challenges that processes a series of strings, splitting each into two parts: characters at even indices and characters at odd indices, then prints them space-separated.

Features

Quickstart

python stringsAndLoops.py

Architecture

flowchart TD
    A[Start] --> B[Read Test Case Count]
    B --> C{More Cases?}
    C -->|Yes| D[Read Input String]
    D --> E[Initialize Even/Odd Lists]
    E --> F[Iterate Characters]
    F --> G{Index Even?}
    G -->|Yes| H[Append to Even List]
    G -->|No| I[Append to Odd List]
    H --> J{Next Char?}
    I --> J
    J -->|Yes| F
    J -->|No| K[Join Even List]
    K --> L[Join Odd List]
    L --> M[Print Result]
    M --> C
    C -->|No| N[End]

How it's built

Built with pure Python using standard I/O. It reads the number of test cases from stdin, iterates through each string, classifies characters by index parity into separate lists, and writes the concatenated results to stdout.

How it runs

sequenceDiagram
    participant User
    participant Script
    participant SysStdout
    User->>Script: Provide Test Case Count (N)
    loop For each test case
        User->>Script: Provide Input String (S)
        Script->>Script: Initialize evenString, oddString
        loop For each char in S
            Script->>Script: Check index parity
            alt Even Index
                Script->>Script: Append to evenString
            else Odd Index
                Script->>Script: Append to oddString
            end
        end
        Script->>SysStdout: Write evenString chars
        Script->>SysStdout: Write space
        Script->>SysStdout: Write oddString chars
        Script->>SysStdout: Write newline
    end

How to apply & reuse

Use this as a reference for basic string manipulation, list accumulation patterns, and handling standard input/output in Python 2 environments. It demonstrates O(N) character processing per string.

At a glance

CapabilitiesString indexingStandard input parsingConditional logic applicationList accumulation
ComponentsMain execution blockInput readerCharacter classifierOutput writer
TechPython 2sys moduleraw_inputstdout.write
Depends onPython 2 runtime
Integrates withStandard Input (stdin)Standard Output (stdout)
PatternsAccumulator patternIteration over sequenceParity check
Reuse tagsstring-manipulationcoding-challengebasic-algorithmstdin-processing

Repo hygiene

✓ all on main — nothing unmerged.