Sum two inputs:
println(io.Source.stdin.getLines().take(2).map(_.toInt).sum)
Repeat each element of list num times:
def f(num:Int,arr:List[Int]):List[Int] = arr.map(x => List.fill(num)(x)).flatten
#!/usr/bin/python3 | |
# | |
# Usage: spiral.py [MATRIX_HEIGHT] | |
# | |
# Draws spiral of the prime numbers. Numbers are arranged in a spiral like this: | |
# 17 16 15 14 29 | |
# 18 5 4 3 28 | |
# 19 6 1 2 27 | |
# 20 7 8 9 26 | |
# 21 22 23 24 25 |
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
import java.io.File | |
import java.awt.image.BufferedImage | |
import javax.imageio.ImageIO | |
import javax.imageio.ImageTypeSpecifier | |
import java.awt.image.DataBufferByte | |
import java.awt.image.DataBufferInt |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Player Movement using onkeydown/onkeyup (Enhanced version)</title> | |
<style type="text/css" media="screen"> | |
canvas { border: 1px solid; } | |
</style> | |
<script type="text/javascript" charset="utf-8"> | |
///////////// |
#!/usr/bin/env bash | |
# | |
# Creates pdf file from source code. | |
tex_file=$(mktemp) ## Random temp file name | |
cat<<EOF >$tex_file ## Print the tex file header | |
\documentclass{article} | |
\usepackage{listings} | |
\usepackage[usenames,dvipsnames]{color} %% Allow color names |
#!/bin/bash | |
# | |
# Installs Scala. | |
# Install Scala: | |
SCALA_VERSION="2.11.1"; | |
wget http://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | |
tar xvzf scala-$SCALA_VERSION.tgz | |
sudo sh -c 'echo "export SCALA_HOME=\"$PWD/scala-'$SCALA_VERSION'\"" >> /etc/profile; echo "export PATH=\"\$PATH:\$SCALA_HOME/bin\"" >> /etc/profile;' | |
sh /etc/profile |