Решение на Разлика в сумите от Мария Османлиева

Обратно към всички решения

Към профила на Мария Османлиева

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 2 успешни тест(а)
  • 13 неуспешни тест(а)

Код

package main
import "strings"
func ExtractColumn(logContents string, column uint8) string{
lines := strings.Split(logContents, "\n")
var outputs [3]string
for i:=range lines{
var line string
line = lines[i]
words := strings.Split(line, " ")
outputs[0] += words[0] + " " + words[1] + "\n"
outputs[1] += words[2] + "\n"
for i:=3 ; i<len(words) ; i++ {
outputs[2] += words[i] + " "
}
outputs[2] += "\n"
}
return outputs[column]
}

Лог от изпълнението

--- FAIL: TestWithTheExampleTest (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestDifferentColumns (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestWithEmptyLog (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestWithOneLiner (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.007s
--- FAIL: TestSpacesAtTheStartOrEndOfALine (0.00s)
	solution_test.go:260: Expected
		---
		As far as we can tell this is a DNS
		Yet another DNS, how quaint!
		There is definitely some trend here
		 Some spaces at the beginning of this line
		Nothing particularly interesting happened 
		
		---
		but found
		---
		As far as we can tell this is a DNS 
		Yet another DNS, how quaint! 
		There is definitely some trend here 
		 Some spaces at the beginning of this line 
		Nothing particularly interesting happened  
		
		---
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestNoNewLineAtEndOfInput (0.00s)
	solution_test.go:260: Expected
		---
		As far as we can tell this is a DNS
		There is definitely some trend here
		
		---
		but found
		---
		As far as we can tell this is a DNS 
		There is definitely some trend here 
		
		---
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestIPOrDateAtTheEndOfALine (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.004s
--- FAIL: TestWithOnlyOneNewLine (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestExtractingIPs (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestExtractingTimes (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestExtractingTexts (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
PASS
ok  	_/tmp/d20151103-24541-1wj56la	0.003s
PASS
ok  	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestWithSpaces (0.00s)
	solution_test.go:260: Expected
		---
		spaces   tabs		end
		
		---
		but found
		---
		spaces   tabs		end 
		
		---
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s
--- FAIL: TestMoreLinesThanExample (0.00s)
	solution_test.go:253: There was a panic while testing: runtime error: index out of range
FAIL
exit status 1
FAIL	_/tmp/d20151103-24541-1wj56la	0.003s

История (2 версии и 1 коментар)

Мария обнови решението на 02.11.2015 17:49 (преди над 2 години)

+package main
+
+import "strings"
+
+func ExtractColumn(logContents string, column uint8) string{
+ lines := strings.Split(logContents, "\n")
+ var outputs [3]string
+ for i:=range lines{
+ var line string
+ line = lines[i]
+ words := strings.Split(line, " ")
+ outputs[0] += words[0] + " " + words[1] + "\n"
+ outputs[1] += words[2] + "\n"
+ for i:=3 ; i<len(words) ; i++ {
+ outputs[2] += words[i] + " "
+ }
+ outputs[2] += "\n"
+ }
+
+ return outputs[column]
+}

Мария обнови решението на 03.11.2015 12:21 (преди над 2 години)

package main
import "strings"
func ExtractColumn(logContents string, column uint8) string{
lines := strings.Split(logContents, "\n")
var outputs [3]string
for i:=range lines{
var line string
line = lines[i]
words := strings.Split(line, " ")
outputs[0] += words[0] + " " + words[1] + "\n"
outputs[1] += words[2] + "\n"
for i:=3 ; i<len(words) ; i++ {
- outputs[2] += words[i] + " "
+ outputs[2] += words[i] + " "
}
outputs[2] += "\n"
}
-
return outputs[column]
}