for index, runeValue := range nihongo {
fmt.Printf("%#U starts at byte position %d\n", runeValue, index)
}
Last active
May 19, 2017 01:15
-
-
Save vovanmix/eb962fa8e1bd4f4586737f7627f3b31f to your computer and use it in GitHub Desktop.
Languages cheatcheet
Standard Hackerrank pattern:
The first line contains an integer, N, denoting the size of the array.
The second line contains N space-separated integers representing the array's elements.
Using scan:
func read() (int, int, []int) {
var a, b, c int
fmt.Scanf("%d %d %d", &a, &b, &c)
arr := make([]int, a)
for i := 0; i < a; i++ {
fmt.Scanf("%d", &arr[i])
}
return b, c, arr
}
Simple:
import "fmt"
func readNum() int {
var input int
fmt.Scanln(&input)
return input
}
import (
"fmt"
"strings"
"bufio"
"os"
"strconv"
"regexp"
)
var reader = bufio.NewReader(os.Stdin)
func readArray() []int {
numbers, _ := reader.ReadString('\n')
numbers = regexp.MustCompile(`\r?\n`).ReplaceAllString(numbers, "")
ar := strings.Split(numbers, " ")
var int_ar = make([]int, len(ar))
for i, el := range ar {
int_ar[i], _ = strconv.Atoi(el)
}
return int_ar
}
func readNum() int {
str, _ := reader.ReadString('\n')
str = regexp.MustCompile(`\r?\n`).ReplaceAllString(str, "")
num, _ := strconv.Atoi(str)
return num
}
object Solution {
def main(args: Array[String]) {
val _ = scala.io.StdIn.readInt()
val input = scala.io.StdIn.readLine()
val arr: Array[Int] = input.split(" ").map(_.toInt)
}
}
io.Source.stdin.getLines().take(2).map(_.toInt)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment