polarised political climate by Cathy

package main

import (
\x09"bufio"
\x09"fmt"
\x09"os"
)

func main() {
\x09var sc = bufio.NewScanner(os.Stdin)
\x09for sc.Scan() {
\x09\x09solve(sc.Text())
\x09}
}

func solve(input string) {
\x09runes := []rune(input)
\x09i, j := 0, 0
\x09for i < len(runes) {
\x09\x09if runes[i] == 62 {
\x09\x09\x09for j < len(runes) {
\x09\x09\x09\x09if runes[j] == 60 {
\x09\x09\x09\x09\x09runes[i], runes[j] = runes[j], runes[i]
\x09\x09\x09\x09\x09break
\x09\x09\x09\x09}
\x09\x09\x09\x09j++
\x09\x09\x09}
\x09\x09}
\x09\x09i++
\x09\x09if i > j {
\x09\x09\x09j++
\x09\x09}
\x09}
\x09fmt.Println(string(runes))
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page