Skip to content

Commit

Permalink
added string mask go
Browse files Browse the repository at this point in the history
  • Loading branch information
fmt-Println-MKO committed Aug 3, 2015
1 parent e6ad0e2 commit 11ed8c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/de/sunbits/codeeval/stringmask/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import "fmt"
import "log"
import "bufio"
import "os"
import "strings"

func main() {
file, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer file.Close()

var one int32 = 49

scanner := bufio.NewScanner(file)
for scanner.Scan() {
var line string = scanner.Text()
var lineArray []string = strings.Fields(line)
var word string = lineArray[0]
var code string = lineArray[1]

for i, r := range code {
if r == one {
fmt.Print(strings.ToUpper(string(word[i])))
} else {
fmt.Print(string(word[i]))
}
}
fmt.Println()
}
}
1 change: 1 addition & 0 deletions src/de/sunbits/codeeval/stringmask/results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 Go Aug 03, 2015 Solved 100 1 4096 yes 34.995 Share on LinkedIn DELETE
3 changes: 3 additions & 0 deletions src/stringmask.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello 11001
world 10000
cba 111

0 comments on commit 11ed8c7

Please sign in to comment.