Before climbing the leaderboard, learn about the shebang and command-line arguments.
Edit me

Solve These First

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.

Hello World

This has long been the first program any guide on programming uses to demonstrate the language. In Codewarz, 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.)

Interpreted (Scripting) Languages Must Include a Shebang

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:

Bourne-Again Shell (BASH 4.4.19)

hello_world.sh:

#!/bin/bash
echo "Hello, World!"

Common Lisp

hello_world.lsp:

#!/usr/bin/env clisp
(print "Hello World")

Nodejs 10.2.1

hello_world.js:

#!/usr/bin/env nodejs
console.log("Hello, World!");

Perl 5 (5.26.1)

hello_world.pl:

#!/usr/bin/env perl
use strict;
use warnings;
print "Hello, World!\n";

PHP (7.2.5)

hello_world.php:

#!/usr/bin/php
<?php
echo "Hello, World!"
?>

Python (2.7.15)

hello_world.py:

#!/usr/bin/env python
print "Hello, World!"

Python 3 (3.6.5)

hello_world.py:

#!/usr/bin/env python3
print("Hello, World!")

Ruby

hello_world.rb:

#!/usr/bin/env ruby
puts "Hello, World!"

hello_world_object_oriented.rb:

#!/usr/bin/env ruby
class HelloWorld
   def initialize(name)
      @name = name.capitalize
   end
   def sayHi
      puts "Hello, #{@name}!"
   end
end

hello = HelloWorld.new("World")
hello.sayHi

Scala

hello_world.scala:

#!/usr/bin/env scala
object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, World!")
  }
}

Compiled Language Submissions Must be Source Code (No Binaries)

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:

C

hello_world.c:

#include <stdio.h>

int main()
{
    printf("Hello, World!");
}

C++

hello_world.cpp:

#include <iostream>

int main()
{
    std::cout << "Hello, World!";
}

C#

hello_world.cs:

public class Hello_World
{
    public static void Main()
    {
        System.Console.WriteLine("Hello, World!");
    }
}

Golang 1.10.2

hello_world.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Haskell

hello_world.hs:

module Main where

main = putStrLn "Hello, World!"

Argumentative

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 four
one 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.

Bourn-Again Shell (BASH 4.4.19)

argumentative.sh:

#!/bin/bash
echo $@

Common Lisp

argumentative.lsp:

#!/usr/bin/env clisp
(loop for i in *args*
    do (format t " ")
    do (format t "~A" i)
    )

Nodejs 10.2.1

argumentative.js:

#!/usr/bin/env nodejs
process.argv.slice(2).forEach(function (val, index, array) {
    process.stdout.write(val+" ");
});
console.log();

Perl 5 (5.26.1)

argumentative.pl:

#!/usr/bin/env perl
use strict;
use warnings;

print "$_ " foreach @ARGV;
print "\n"

PHP (7.2.5)

argumentative.php:

#!/usr/bin/php
<?php
for($i = 1; $i < sizeof($argv); $i++) {
    echo $argv[$i]." ";
}
echo "\n";
?>

Python (2.7.15)

argumentative.py:

#!/usr/bin/env python
import sys
print ' '.join(sys.argv[1:])

Python 3 (3.6.5)

argumentative3.py:

#!/usr/bin/env python3
import sys
print(' '.join(sys.argv[1:]))

Ruby

argumentative.rb:

#!/usr/bin/env ruby
puts ARGV.join(' ')

Scala

argumentative.scala:

#!/usr/bin/env scala
object Argumentative {
  def main(args: Array[String]): Unit = {
      println(args.mkString(" "))
  }
}

Compiled Language Argumentative Solutions

The following are examples of correct Argumentative submissions for the compiled languages that we support:

C

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("\n");
}

C++

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;
}

C#

argumentative.cs:

using System;

public class Argumentative
{
    public static void Main(string[] args)
    {
        for (int i = 0; i < args.Length; i++)
        {
            System.Console.Write("{0} ",args[i]);
        }
        System.Console.WriteLine();
    }
}

Golang 1.10.2

argumentative.go:

package main

import "os"
import "fmt"
import "strings"

func main() {
    argsWithoutProg := strings.Join(os.Args[1:], " ")
    fmt.Println(argsWithoutProg)
}

Haskell

argumentative.hs:

import System.Environment
import Data.List

main = do
    args <- getArgs
    putStrLn (intercalate " " args)