Skip to content
Permalink
Browse files

Чтобы brackets-bot не ругался на грустные смайлы

  • Loading branch information...
akosourov
akosourov committed Apr 22, 2017
1 parent 5629c33 commit 45c667fb6609630d58bf9ff8114af6d8dc4ff4ca
Showing with 10 additions and 0 deletions.
  1. +7 −0 brackets-bot/brackets.go
  2. +3 −0 brackets-bot/brackets_test.go
@@ -2,6 +2,7 @@ package main

import (
"errors"
"strings"
)

var openingBrackets = [...]rune{'(', '[', '{', '<', '«'}
@@ -10,6 +11,8 @@ var closingBrackets = [...]rune{')', ']', '}', '>', '»'}
var inconsistentError = errors.New("Stack is inconsistent")
var emptyError = errors.New("Stack is empty")

var ignoredStrings = [...]string{":(", ":-("}

type bracketsStack []rune

func (a *bracketsStack) pop() (rune, error) {
@@ -65,6 +68,10 @@ func (a bracketsStack) getResult() []rune {
}

func processString(str string) (string, error) {
for _, x := range ignoredStrings {
str = strings.Replace(str, x, "", -1)
}

runes := []rune(str)
brackets_stack := bracketsStack{}
for _, s := range runes {
@@ -11,6 +11,9 @@ func TestBracketsGood(t *testing.T) {
{"((()", "))"},
{"(([", "]))"},
{"()()()([{", "}])"},
{":(", ""},
{":-(", ""},
{"(:(()", ")"},
}
for _, c := range cases {
result, err := processString(c.in)

0 comments on commit 45c667f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.