This article provides the following information about the CodeSignal coding environment:
- CodeSignal IDE video walk-through
- CodeSignal tasks & testing frameworks
- Verdicts
- Supported languages
CodeSignal IDE video walk-through
CodeSignal tasks & testing frameworks
For solving filesystem-enabled CodeSignal tasks, you should edit some or all of the non-locked files (or create new ones) to implement the requirements and pass the Unit Tests specified in the locked files.
Supported testing frameworks:
- JUnit with Maven or Gradle
- Mocha
- unittest (python2, python3)
- RSpec
For solving single-file CodeSignal tasks, you should implement a function in your preferred language. When submitted, your function is wrapped in a class/closure, so some declarations may result in a Syntax (Compilation) Error. Keep the following details in mind:
- Your code should declare a function/method with exactly the same name that is specified in the challenge. Changing its name will result in a syntax error.
- You can log any data in the console for debugging purposes (e.g. console.log in JS, std::cout in C++).
- If the value of some input/output argument is a string that contains double quote characters (") it will be shown in the output with an additional \ symbol. E.g. inputString = hello"world"hello will be displayed in the console as "hello\"world\"hello".
Verdicts
After you submit your code for testing, the following verdicts are possible:
- Compilation/syntax error - This means you probably have some syntax errors in your source code. More detailed information will be given along with the verdict to help you identify the issue.
- Execution error - This means your code has crashed. Most likely, it crashes only for some input parameters. More detailed information will be given along with the verdict to help you identify the issue.
- Compilation time exceeded - This verdict happens rarely, mostly for C++ or Java. This means that your code is either too long or you overused templates, which results in very slow compilation of your code.
- Execution limit exceeded - This means that your code didn't finish executing within the given time limit. It either got hung up on one of the test cases, or it just works very slowly. It's likely that your solution is either not optimally efficient, or you have a bug in the code.
- Output limit exceeded - This verdict happens rarely. It means that either your function return value size is too big (e.g. you returned a very big array or matrix), or that you overused console outputs and essentially spammed it with a lot of data. One possible cause of such an issue is that you have a console output inside an infinite loop.
- Wrong answer - This verdict means that your code was compiled and ran successfully, but it returned an incorrect output for one or more test cases. More detailed information will be provided to help you diagnose the issue.
- All tests passed - This means that your code works correctly and passed all the tests within the given time limit.
Supported languages
We support a variety of compilers and languages. You can solve each challenge in your preferred language by clicking on the language switcher icon in the upper right corner of the IDE.
In the following sections, you'll find detailed information about each available language and compiler. Languages are organized alphabetically.
Bash
For DevOps
challenges, you are required to write bash scripts, which should print required data to stdout.
C
The compiler used on the site is GCC v11.1.0 enabled. You can use printf(...)
to print any data for debugging purposes.
The following libraries are automatically included:
#include <stdatomic.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <openssl/ssl.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <pthread.h>
#include <unistd.h>
C++
We support G++ v8.4.0 c++17 enabled. Feel free to use unordered_map, regex, range for, auto ...
features from C++11, 14 and 17 standards.
You can use cout << ... << endl
to print any data for debugging purposes.
The following libraries are automatically included:
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <jsoncpp/json/json.h>
#include <atomic>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <future>
Some best practices for C++:
- When declaring global variables in C++, initializing them during declaration will result in a syntax error. Instead, perform an initialization in the function/method.
- Static variables are disabled in C++, so using them will lead to unexpected results.
- Add using namespace std; at the beginning of the function in order to use std features without std:: prefix.
- Please use
std::cout
to print any data for debugging purposes. - Use C++11, 14 and 17 features, e.g.
for (auto x: vec) {...}
,lambda functions [](int a, int b) -> bool {...}
.
C#
The compiler used on the site is Mono C# compiler version 6.12.0.122. Please use Console.Write(...)
to print any data for debugging purposes.
The following libraries are automatically included:
using System; using System.IO; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.Net; using System.Net.Http; using System.Reflection; using System.Runtime.Serialization; using System.Text; using System.Web; using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Numerics; using MySql.Data.MySqlClient; using Newtonsoft.Json;
Clojure
The Clojure version used on the site is Clojure 1.10.2.
- Please use (print ...) or (println ...) to print any data for debugging purposes.
The following libraries are automatically imported:
(:require [clojure.string :as string])
(:require [clojure.core :as core])
(:require [clojure.core.reducers :as r])
(:require [clojure.set :as set])
(:require [clojure.java.io :as io])
You can use your own requires. For example:
(require '[<some library>])
(require '[<some other library> :as <library alias>])
CoffeeScript
The CoffeeScript version used on the site is CoffeeScript 2.7.0
- Please use console.log ... to print any data for debugging purposes.
The following libraries are automatically imported:
async = require('async');
axios = require('axios');
chai = require('chai');
chai-http = require('chai-http');
co = require('co');
connect = require('connect');
crypto-js = require('crypto-js');
debug = require('debug');
express = require('express');
forever = require('forever');
futil = require('futil');
http = require('http');
ip-router = require('ip-router');
ip-to-int = require('ip-to-int');
ipaddr.js = require('ipaddr.js');
jquery = require('jquery');
lodash = require('lodash');
mocha = require('mocha');
mongodb = require('mongodb');
mongoose = require('mongoose');
mssql = require('mssql');
mysql = require('mysql');
mysql2 = require('mysql2');
node-fetch = require('node-fetch');
pg = require('pg');
rambda = require('rambda');
request = require('request');
rxjs = require('rxjs');
sequelize = require('sequelize');
shelljs = require('shelljs');
sys = require('sys');
underscore = require('underscore');
validator = require('validator');
when = require('when');
ws = require('ws');
Common Lisp
The Common Lisp version used on the site is CLisp 2.49.
- Please use (write ...) or (write ...) (terpri) to print any data for debugging purposes.
D
The compiler used on the site is DMD64 D Compiler v2.079.1. Please use write(...)
or writeln(...)
to print any data for debugging purposes.
The following libraries are automatically included:
import std.algorithm, std.array, std.format, std.range, std.regex,
std.conv, std.stdio, std.math, std.string, std.container;
Dart
The compiler used on the site is Dart v2.13.4. You can use print(...)
, stdout.write(...)
or stdout.writeln(...)
to print any data for debugging purposes.
The following libraries are automatically imported:
import 'dart:core';
import 'dart:io';
import 'dart:convert';
import 'dart:math';
import 'dart:async';
Elixir
The compiler used on the site is Elixir v1.9.1. You can use IO.write(...)
or IO.puts(...)
to print any data for debugging purposes.
Strings are given as standard UTF-8 binaries and Chars are given as a codepoints, but both the binaries and char lists are accepted in the output.
Erlang
The compiler used on the site is Erlang v22.0. You can use io:fwrite(...)
to print any data for debugging purposes.
Fortran
The compiler used on the site is Fortran GCC v11.1.0 with -ffree-form -std=f2008
. You can use print *, ...
to print any data for debugging purposes.
Free Pascal
The Free Pascal version used on the site is Free Pascal 3.0.4. Please use write(...)
or writeln(...)
to print any data for debugging purposes.
The following libraries are automatically included:
uses sysutils,
math,
strutils,
dateutils,
fpjson,
fgl;
F#
The compiler used on the site is Mono v6.0.400
- Please use printf to print any data for debugging purposes.
- Arrays are used as input parameters instead of lists.
- Return type is mentioned explicitly, so you should return an object of the exact type.
The following libraries are automatically included:
open System
open System.IO
open System.IO.Text
open System.Globalization
Go
The compiler used on the site is Go v1.19.5. Please use fmt.Printf(...)
to print any data for debugging purposes.
The following libraries are automatically included:
import "fmt"
import "bufio"
import "io"
import "log"
import "os"
import "strconv"
import "bytes"
Groovy
The Groovy version used on the site is Groovy 4.0.2.
- Please use print ... or println ... to print any data for debugging purposes.
The following libraries are automatically included:
import java.math.*;
import java.util.regex.*;
import java.util.stream.*;
import java.text.*;
import java.security.SecureRandom;
import java.util.function.*;
import java.util.concurrent.*;
import groovy.json.*;
Haskell
The compiler used on the site is GHC v8.10.4. Please use unsafePerformIO
and print ...
to print any
data for debugging purposes. Here's an example of the add
function with debug output:
add a b = unsafePerformIO $ do
print "test"
print a
return $ a + b
The following libraries are automatically included:
import Debug.Trace (trace) import System.IO (hFlush, stdout, stderr, hPutStrLn, hPutStr) import System.IO.Unsafe (unsafePerformIO) import Data.Array import Data.Bits import GHC.Exts import qualified Data.Aeson as A import qualified Data.Aeson.Encoding as AE import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Lazy as B import qualified Data.Vector as V
Java
The compiler used on the site is Java v17.0.3.
- Please use System.out.println(...) to print any data for debugging purposes.
- When declaring global variables in Java, initializing them during declaration will result in a syntax error. Instead, perform an initialization in the function/method.
The following libraries are automatically included:
import java.math.*;
import java.net.*;
import java.net.http.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import java.text.*;
import java.security.SecureRandom;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.type.*;
import com.fasterxml.jackson.databind.*;
Julia
The compiler used on the site is Julia v1.6.2. You can use println(...)
or print(...)
to print any data for debugging purposes.
Kotlin
The Kotlin version used on the site is Kotlin 1.6.21.
- Please use print(...) or println(...) to print any data for debugging purposes.
The following libraries are automatically included:
import kotlin.comparisons.*; import kotlin.collections.*; import kotlin.io.*; import kotlin.jvm.*; import kotlin.jvm.functions.*; import kotlin.jvm.internal.*; import kotlin.ranges.*; import kotlin.sequences.*; import kotlin.text.*; import java.io.*; import java.math.*; import java.net.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import java.text.*; import java.security.SecureRandom; import kotlinx.coroutines.*; import kotlinx.coroutines.channels.*; import kotlinx.coroutines.selects.*; import kotlinx.coroutines.scheduling.*; import kotlinx.coroutines.sync.*; import kotlinx.coroutines.flow.*;
Lua
The Lua version used on the site is Luajit 2.0.5.
- Please use print(...) to print any data for debugging purposes.
MySQL
The compiler used on the site is MySQL 8.0.28.
Nim
The compiler used on the site is Nim Compiler Version 1.6.10. You can use echo(...)
, stdout.write(...)
or stdout.writeLine(...)
to print any data for debugging purposes.
The following libraries are automatically imported:
import system
import strutils
import sequtilsfrom unicode import runes
JavaScript/NodeJS
We support Node.js v18.12.1 compiler with almost all ES2015 features.
Some best practices for Nodejs:
- Please use console.log() to print any data to the console for debugging purposes.
- Use arrow functions () => {} and other ES2015 features to write concise and clear code.
Included NPM packages:
- sequelize
- underscore
- crypto-js
- lodash
- request
- shelljs
- http
- sys
- jquery
- async
- connect
- mysql
- mysql2
- validator
- ws
- co
- when
- forever
- debug
React
Uses development standalone versions of the following packages:
Objective-C
The compiler used on the site is Clang v10.0.0. You can use printf(...)
or NSPrint(...)
to print any data for debugging purposes.
Note that NSLog(...)
won't work, but NSPrint(...)
is an alternative with the same interface.
The following libraries are automatically included:
#import <objc/objc.h>
#import <objc/Object.h>
#import <Foundation/Foundation.h>
#include <stdio.h>
#include <math.h>
Octave
The compiler used on the site is GNU Octave v5.2.0. You can use disp(...)
to print any data for debugging purposes.
OCaml
The compiler used on the site is OCaml version 4.08.1. Please use print_string(...)
or print_endline(...)
to print any data for debugging purposes.OCaml Batteries included 2.4
is installed and can be used by adding open Batteries
to the beggining of your program.
Perl
The compiler version used on the site is Perl 5.30.0. Please use print ...
to print any data for debugging purposes.
The following libraries are automatically included:
use warnings; use IO::Handle; use JSON;
PHP
The compiler version used on the site is PHP 8.0.27. Please use echo ...
to print any data for debugging purposes.
PostgreSQL
The compiler used on the site is PostgreSQL v14.1.
Python2
The Python2 version used on the site is 2.7.18.
- For information about the differences between python2 and python3, consult The Python Language Wiki.
- Please use print ... to print any data for debugging purposes.
The following libraries are automatically imported:
import json import math import string import re import random import sys import traceback import functools from collections import OrderedDict import numpy import sortedcontainers
Python3
The Python3 version used on the site is 3.10.6.
- For information about the differences between python3 and python2, consult The Python Language Wiki.
- Please use print ... to print any data for debugging purposes.
The following libraries are automatically imported:
import json import math import string import re import random import sys import traceback import functools from collections import OrderedDict import numpy import sortedcontainers
R
The compiler used on the site is R 4.2.2. Please use cat(...)
or print(...)
to print any data for debugging purposes.
Return list
for the challenges where return value is array
.
Use I(x)
if you want a single element list/vector x
to be treated as a list and not as a scalar in the output.
The following libraries are automatically included:
library(stringr)
library(jsonlite)
library(httr)
library(dplyr)
library(magrittr)
library(data.table)
library(futile.logger)
library(tryCatchLog)
suppressPackageStartupMessages(library(tidyverse))
Ruby
The compiler used on the site is ruby 3.0.1. Please use puts ...
to print any data for debugging purposes.
The following libraries are automatically included:
require 'json'
require 'stringio'
Rust
The compiler used on the site is rust v1.66.1. You can use print!(...)
or println!(...)
to print any data for debugging purposes.
The following libraries are automatically included:
use std::io::prelude::*;
use std::io::{BufReader, Lines};
use std::fs::File;
Scala
The compiler used on the site is Scala v3.1.3. Please use println(...)
to print any data for debugging purposes.
Smalltalk
The compiler used on the site is GNU Smalltalk 3.2.5. You can use ... display
or Transcript show: ...
to print any data for debugging purposes.
Swift
The compiler used on the site is Swift v5.4. Please use print(...)
to print any data for debugging purposes.
The following libraries are automatically included:
import Foundation
import Glibc
Tcl
The Tcl version used on the site is v8.6.10 with Tcllib installed. You can use puts
to print any data for debugging purposes.
TypeScript
The TypeScript version used on the site is TypeScript 4.9.5. Please use console.log(...)
to print any data for debugging purposes.
The following priority queue libraries are automatically included:
const async = require('async');
const axios = require('axios');
const chai_ = require('chai');
const chai_http = require('chai-http');
const co = require('co');
const connect = require('connect');
const crypto_js = require('crypto-js');
const _datastructures_js_priority_queue = require('@datastructures-js/priority-queue');
const _datastructures_js_binary_search_tree = require('@datastructures-js/binary-search-tree');
const debug = require('debug');
const express = require('express');
const forever = require('forever');
const futil = require('futil');
const http = require('http');
const ip_router = require('ip-router');
const ip_to_int = require('ip-to-int');
const ipaddr_js = require('ipaddr.js');
const jquery = require('jquery');
const lodash = require('lodash');
const mocha_ = require('mocha');
const mongodb = require('mongodb');
const mongoose = require('mongoose');
const mssql = require('mssql');
const mysql = require('mysql');
const mysql2 = require('mysql2');
const node_fetch = require('node-fetch');
const pg = require('pg');
const rambda = require('rambda');
const request = require('request');
const rxjs = require('rxjs');
const sequelize = require('sequelize');
const shelljs = require('shelljs');
const sys = require('sys');
const underscore = require('underscore');
const validator = require('validator');
const when = require('when');
const ws = require('ws');
Visual Basic
The compiler used on the site is Mono v6.0.400. Please use Console.WriteLine(...)
to print any data for debugging purposes.
The following libraries are automatically included:
Imports System
Imports System.IO
Imports System.CodeDom.Compiler
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Diagnostics.CodeAnalysis
Imports System.Globalization
Imports System.Reflection
Imports System.Runtime.Serialization
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Linq
Questions? Contact support@codesignal.com