isundil 9 سال پیش
والد
کامیت
355a045ffa
1فایلهای تغییر یافته به همراه52 افزوده شده و 0 حذف شده
  1. 52 0
      d09/d09.go

+ 52 - 0
d09/d09.go

@@ -0,0 +1,52 @@
+package main
+
+import "strconv"
+import "bufio"
+import "fmt"
+import "os"
+
+type Compressed struct {
+	BSize int
+	Count int
+}
+
+func ReadCompressed(line string) *Compressed {
+	if (line[0] != '(' || line[len(line) -1] != ')') {
+		return nil
+	}
+	line = line[1:len(line)-1]
+	fmt.Println(">>>" +line +"<<<")
+	this := new(Compressed)
+	this.BSize = 0
+	return this
+}
+
+func main() {
+	reader := bufio.NewReader(os.Stdin)
+	length := 0
+
+	for true {
+		line, err := reader.ReadString('(')
+		if line[len(line) -1] == '(' {
+			line = line[0: len(line) -1]
+			reader.UnreadByte()
+		}
+		length += len(line)
+		fmt.Println(line)
+		if err != nil {
+			break
+		}
+
+		line, err = reader.ReadString(')')
+		compressed := ReadCompressed(line)
+		if (compressed == nil) {
+			length += len(line)
+			continue
+		}
+		if err != nil {
+			break
+		}
+	}
+	fmt.Println("len: " +strconv.Itoa(length))
+}
+