The tutorial challenges are there to show new players how their submissions need to be formatted prior to posting them to the site. Prior to trying the other challenges on the site, we recommend you solve the Tutorial challenges first to set you up for success as you progress further.
This has long been the first program any guide on programming uses to demonstrate the language. In RunCode, we have you submit this first to verify you understand the format that your submissions need to be in (and that you have a basic functional proficiency in your language.)
The shebang is an interpreter directive to a program loader that directs what interpreter program should be used to parse the rest of the script that follows.
For example, #!/bin/sh
at the top of a shell script would indicate that /bin/sh
should be used to interpret what follows.
The following examples demonstrate the correct way to submit a script for the languages we support:
hello_world.sh:
#!/bin/bashecho "Hello, World!"
hello_world.lsp:
#!/usr/bin/env clisp(print "Hello World")
hello_world.js:
#!/usr/bin/env nodejsconsole.log("Hello, World!");
hello_world.pl:
#!/usr/bin/env perluse strict;use warnings;print "Hello, World!\n";
hello_world.php:
#!/usr/bin/php<?phpecho "Hello, World!"?>
hello_world.py:
#!/usr/bin/env pythonprint "Hello, World!"
hello_world.py:
#!/usr/bin/env python3print("Hello, World!")
hello_world.rb:
#!/usr/bin/env rubyputs "Hello, World!"
hello_world_object_oriented.rb:
#!/usr/bin/env rubyclass HelloWorlddef initialize(name)@name = name.capitalizeenddef sayHiputs "Hello, #{@name}!"endend​hello = HelloWorld.new("World")hello.sayHi
hello_world.scala:
#!/usr/bin/env scalaobject HelloWorld {def main(args: Array[String]): Unit = {println("Hello, World!")}}
Since compiled languages can’t be executed before being compiled (and because there is no interpreter involved), the shebang line is unnecessary. Instead, you can simply submit the source code for your solutions. They will be compiled and validated once they are received.
The following are examples of correct Hello World submissions for the compiled languages that we support:
hello_world.c:
#include <stdio.h>​int main(){printf("%s", "Hello, World!");}
hello_world.cpp:
#include <iostream>​int main(){std::cout << "Hello, World!";}
hello_world.go:
package main​import "fmt"​func main() {fmt.Println("Hello, World!")}
hello_world.hs:
module Main where​main = putStrLn "Hello, World!"
Argumentative asks you to print all of the arguments to your app from the command-line. This challenge does not provide you with the number of arguments you should expect. Instead, your solution should be able to print one-to-many arguments to the screen.
For example, in the shell script below, there are four arguments provided at the command-line.
$ ./your_app.sh one two three four
The solution, should provide all four arguments not including argument 0 (the app name itself).
$ ./your_app.sh one two three fourone two three four
Below are the solutions you should be able to provide to this tutorial challenge in any of the 14 languages you are using.
argumentative.sh:
#!/bin/bashecho $@
argumentative.lsp:
#!/usr/bin/env clisp(loop for i in *args*do (format t " ")do (format t "~A" i))
argumentative.js:
#!/usr/bin/env nodejsprocess.argv.slice(2).forEach(function (val, index, array) {process.stdout.write(val+" ");});console.log();
argumentative.pl:
#!/usr/bin/env perluse strict;use warnings;​print "$_ " foreach @ARGV;print "\n"
argumentative.php:
#!/usr/bin/php<?phpfor($i = 1; $i < sizeof($argv); $i++) {echo $argv[$i]." ";}echo "\n";?>
argumentative.py:
#!/usr/bin/env pythonimport sysprint ' '.join(sys.argv[1:])
argumentative3.py:
#!/usr/bin/env python3import sysprint(' '.join(sys.argv[1:]))
argumentative.rb:
#!/usr/bin/env rubyputs ARGV.join(' ')
argumentative.scala:
#!/usr/bin/env scalaobject Argumentative {def main(args: Array[String]): Unit = {println(args.mkString(" "))}}
The following are examples of correct Argumentative submissions for the compiled languages that we support:
argumentative.c:
#include <stdio.h>​int main(int argc, char *argv[]){int i = 0;for(i = 1; i < argc; i++) {printf("%s ", argv[i]);}printf("%s", "\n");}
argumentative.cpp:
#include <iostream>​int main(int argc, char *argv[]){int i = 0;for(i = 1; i < argc; i++) {std::cout << argv[i] << " ";}std::cout << std::endl;}
argumentative.go:
package main​import "os"import "fmt"import "strings"​func main() {argsWithoutProg := strings.Join(os.Args[1:], " ")fmt.Println(argsWithoutProg)}
argumentative.hs:
import System.Environmentimport Data.List​main = doargs <- getArgsputStrLn (intercalate " " args)