Programming Search⌘K

Taskintro

Create a set

Also called make a set, HashSet, add to a set, remove from a set, test set membership.

Create an empty set, add and remove items and test membership, by adding each word that is not in the set and removing each word that is in it.

Task

Create a set of words. The function toggle(words) starts with an empty set. For each word in words, it removes the word if the set has it, else it adds the word. It returns the words of the set in ascending order by their bytes. Thus the result has each word that is in words an odd number of times. For example, toggle(["red", "blue", "red", "green"]) is ["blue", "green"].

Each word has 1 or more ASCII letters. The list can be empty.

Solutions

Language Empty set Test Add Remove
Python set() w in s s.add(w) s.remove(w)
JavaScript, TypeScript new Set() s.has(w) s.add(w) s.delete(w)
Java new HashSet<>() s.contains(w) s.add(w) s.remove(w)
C# new HashSet<string>() s.Contains(w) s.Add(w) s.Remove(w)
Go make(map[string]struct{}) _, ok := s[w] s[w] = struct{}{} delete(s, w)
Rust HashSet::new() s.contains(w) s.insert(w) s.remove(w)
C a sorted array binary search memmove, then store memmove
C++ std::unordered_set<std::string> s.contains(w) s.insert(w) s.erase(w)
Bash declare -A s=() [[ -v s[$w] ]] s[$w]=1 unset 's[$w]'
  • Remove tells if the item was there. In most of these languages, the remove operation returns whether the set had the item, so one call tests and removes. Java and Rust remove and C# Remove return a bool, JavaScript delete returns a bool, and C++ erase returns the number of items that it removed. In the same way, Rust insert returns "whether the value was newly inserted"1. Python remove raises KeyError for a missing item, and discard does not.
  • Order. A hash set has no useful order, so each solution sorts the items at the end. A sorted set, such as Java TreeSet, Rust BTreeSet and C++ std::set, keeps its items in order. See Ordered map.
  • Go. Go has no set type. A map whose values have the type struct{} is a set, and the values take no memory.
  • C. C has no set type. A sorted array is a set: a binary search tests membership, and memmove opens a gap for a new item or closes the gap of a removed item. Each change moves up to n pointers, so the array is good for small sets.
  • Bash. The keys of an associative array are the set. The quotes in unset 's[$w]' keep the shell from reading s[...] as a glob pattern.

Edge cases

The cases are in cases/basic.jsonl and cases/edge.jsonl.

  • empty: no words give an empty set.
  • two-times: the second a removes the first, so the set is empty.
  • three-times: the third a adds it again.
  • case: a and A are two items. A comes first, because its byte is smaller.
  • prefix: a comes before ab.

Pitfalls

  • Python {} is an empty dict, and a set made from a string is a set of letters. "to create an empty set you have to use set(), not {}; the latter creates an empty dictionary"2. Also, set takes an iterable, and a string is an iterable of its characters. Put the string in a list or in braces:
print(type({}).__name__, type(set()).__name__)
print(sorted(set("red")), sorted({"red"}))
Output
dict set
['d', 'e', 'r'] ['red']
  • JavaScript a Set made from a string is a set of letters. For the constructor, if an "iterable object (such as an array) is passed, all of its elements will be added to the new Set"3. A string is iterable, and its elements are its characters:
console.log(new Set("red").size, new Set(["red"]).size);
console.log([...new Set("red")]);
Output
3 1
[ 'r', 'e', 'd' ]
  • Java Set.of throws for a duplicate. The sets of Set.of "reject duplicate elements at creation time. Duplicate elements passed to a static factory method result in IllegalArgumentException."4 To make a set from data that can have duplicates, copy the data into a HashSet or a TreeSet:
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class Main {
  public static void main(String[] args) {
    try {
      Set.of("red", "blue", "red");
    } catch (IllegalArgumentException e) {
      System.out.println(e.getClass().getSimpleName());
    }
    System.out.println(new TreeSet<>(List.of("red", "blue", "red")));
  }
}
Output
IllegalArgumentException
[blue, red]
  • C# a string set is case-sensitive by default. new HashSet<string>() "uses the default equality comparer for the set type"5, and for strings that comparer is ordinal and case-sensitive. To make red and Red one item, give the constructor a comparer:
using System;
using System.Collections.Generic;

var a = new HashSet<string> { "red", "Red" };
var b = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "red", "Red" };
Console.WriteLine(a.Count + " " + b.Count + " " + b.Contains("RED"));
Output
2 1 True
  • Go a map[string]bool with a false value still has the key. A set of type map[string]bool reads false for a missing key, so s[w] = false looks like a removal. But the key stays, and "The number of map elements is called its length."6 Use delete:
package main

import "fmt"

func main() {
	seen := map[string]bool{"red": true}
	seen["red"] = false
	fmt.Println(seen["red"], len(seen))
	delete(seen, "red")
	fmt.Println(len(seen))
}
Output
false 1
0
  • Rust dedup removes only duplicates that are next to each other. dedup "Removes consecutive repeated elements in the vector according to the PartialEq trait implementation."7 Also: "If the vector is sorted, this removes all duplicates."7 Sort first, or collect the items into a set:
fn main() {
    let mut words = vec!["red", "blue", "red"];
    words.dedup();
    println!("{:?}", words);
    words.sort();
    words.dedup();
    println!("{:?}", words);
}
Output
["red", "blue", "red"]
["blue", "red"]
  • C++ a set of const char * compares addresses. "std::set is an associative container that contains a sorted set of unique objects of type Key. Sorting is done using the key comparison function Compare."8 The default Compare is std::less<Key>, and for a pointer type it compares the addresses. Two arrays with the text red are two items. Use std::string:
#include <iostream>
#include <set>
#include <string>

int main() {
    char a[] = "red";
    char b[] = "red";
    std::set<const char *> ptrs{a, b};
    std::set<std::string> strs{a, b};
    std::cout << ptrs.size() << ' ' << strs.size() << '\n';
}
Output
2 1
  • C strcmp gives 0 for equal strings. strcmp returns "Zero if lhs and rhs compare equal."9 Thus if (strcmp(a, b)) is true when the strings are different, which is the opposite of a membership test. Compare the result with 0:
#include <stdio.h>
#include <string.h>

int main(void) {
    const char *word = "red";
    if (strcmp(word, "red")) {
        puts("strcmp is true");
    } else {
        puts("strcmp is 0");
    }
    printf("%d\n", strcmp(word, "red") == 0);
    return 0;
}
Output
strcmp is 0
1
  • Bash ${#s} is not the size of the set. "Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0."10 Thus ${#s} is the length of the item with the key 0. But "If subscript is ‘@’ or ‘*’, the expansion is the number of elements in the array."10 Use ${#s[@]}:
declare -A colors=([red]=1 [blue]=1)
echo "${#colors} ${#colors[@]}"
Output
0 2

Code

The build runs the native tests of each language in a pinned toolchain.

toggle.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-a-set/.


def toggle(words: list[str]) -> list[str]:
    """Add each word that is not in the set, remove each word that is in it."""
    # set() makes an empty set. {} would make an empty dict.
    seen = set()
    for word in words:
        if word in seen:
            seen.remove(word)
        else:
            seen.add(word)
    return sorted(seen)
test_toggle.py 22 lines
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-a-set/.

import pytest

from toggle import toggle

CASES = {
    "colors": (["red", "blue", "red", "green"], ["blue", "green"]),
    "fresh": (["b", "a"], ["a", "b"]),
    "empty": ([], []),
    "two-times": (["a", "a"], []),
    "three-times": (["a", "a", "a"], ["a"]),
    "case": (["a", "A"], ["A", "a"]),
    "prefix": (["ab", "a"], ["a", "ab"]),
}


@pytest.mark.parametrize("name", CASES)
def test_toggle(name):
    words, want = CASES[name]
    assert toggle(words) == want
toggle.cppI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#include "toggle.hpp"

#include <algorithm>
#include <unordered_set>

std::vector<std::string> toggle(const std::vector<std::string> &words) {
    std::unordered_set<std::string> seen;
    for (const auto &word : words) {
        // erase returns the number of items that it removed, 0 or 1.
        if (seen.erase(word) == 0) {
            seen.insert(word);
        }
    }
    std::vector<std::string> out(seen.begin(), seen.end());
    std::ranges::sort(out);
    return out;
}
toggle.hpp 11 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#pragma once

#include <string>
#include <vector>

// toggle adds each word that is not in the set, and removes each word that is
// in it. It returns the words of the set in ascending order.
std::vector<std::string> toggle(const std::vector<std::string> &words);
test_toggle.cpp 35 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#include "toggle.hpp"

#include <iostream>
#include <string>
#include <string_view>
#include <vector>

static int failures = 0;

using Words = std::vector<std::string>;

static void check(std::string_view name, const Words &words, const Words &want) {
    if (toggle(words) != want) {
        std::cerr << "case " << name << " failed\n";
        failures++;
    }
}

int main() {
    check("colors", Words{"red", "blue", "red", "green"}, Words{"blue", "green"});
    check("fresh", Words{"b", "a"}, Words{"a", "b"});
    check("empty", Words{}, Words{});
    check("two-times", Words{"a", "a"}, Words{});
    check("three-times", Words{"a", "a", "a"}, Words{"a"});
    check("case", Words{"a", "A"}, Words{"A", "a"});
    check("prefix", Words{"ab", "a"}, Words{"a", "ab"});
    if (failures > 0) {
        return 1;
    }
    std::cout << "all cases pass\n";
    return 0;
}
Toggle.javaI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

import java.util.HashSet;
import java.util.List;
import java.util.Set;

final class Toggle {
  private Toggle() {}

  /** Adds each word that is not in the set, and removes each word that is in it. */
  static List<String> toggle(List<String> words) {
    Set<String> seen = new HashSet<>();
    for (String word : words) {
      // remove returns true if the set had the word.
      if (!seen.remove(word)) {
        seen.add(word);
      }
    }
    // String.compareTo compares UTF-16 code units, which is the byte order for ASCII.
    return seen.stream().sorted().toList();
  }
}
ToggleTest.java 29 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class ToggleTest {
  static Stream<Arguments> cases() {
    return Stream.of(
        Arguments.of("colors", List.of("red", "blue", "red", "green"), List.of("blue", "green")),
        Arguments.of("fresh", List.of("b", "a"), List.of("a", "b")),
        Arguments.of("empty", List.of(), List.of()),
        Arguments.of("two-times", List.of("a", "a"), List.of()),
        Arguments.of("three-times", List.of("a", "a", "a"), List.of("a")),
        Arguments.of("case", List.of("a", "A"), List.of("A", "a")),
        Arguments.of("prefix", List.of("ab", "a"), List.of("a", "ab")));
  }

  @ParameterizedTest(name = "{0}")
  @MethodSource("cases")
  void toggle(String name, List<String> words, List<String> want) {
    assertEquals(want, Toggle.toggle(words));
  }
}
toggle.cI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#include "toggle.h"

#include <string.h>

// find returns the index of word in set (k items), or the index where word
// must go if set does not have it. *found tells which.
static size_t find(const char *const *set, size_t k, const char *word, int *found) {
    size_t lo = 0;
    size_t hi = k;
    while (lo < hi) {
        size_t mid = lo + (hi - lo) / 2;
        int c = strcmp(set[mid], word);
        if (c == 0) {
            *found = 1;
            return mid;
        }
        if (c < 0) {
            lo = mid + 1;
        } else {
            hi = mid;
        }
    }
    *found = 0;
    return lo;
}

size_t toggle(const char *const *words, size_t n, const char **out) {
    // C has no set type. A sorted array is a set: a binary search tests
    // membership, and memmove opens or closes a gap.
    size_t k = 0;
    for (size_t i = 0; i < n; i++) {
        int found;
        size_t at = find(out, k, words[i], &found);
        if (found) {
            memmove(&out[at], &out[at + 1], (k - at - 1) * sizeof out[0]);
            k--;
        } else {
            memmove(&out[at + 1], &out[at], (k - at) * sizeof out[0]);
            out[at] = words[i];
            k++;
        }
    }
    return k;
}
toggle.h 15 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#ifndef TOGGLE_H
#define TOGGLE_H

#include <stddef.h>

// toggle adds each of the n words that is not in the set, and removes each
// word that is in it. The set is the array out, in ascending order by
// strcmp. out must have room for n pointers. It returns the size of the set.
// The pointers in out point to the strings of words.
size_t toggle(const char *const *words, size_t n, const char **out);

#endif
test_toggle.c 45 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

#include "toggle.h"

#include <stdio.h>
#include <string.h>

static int failures = 0;

#define L(...) {__VA_ARGS__}

// An empty array has a dummy item in it, because C has no empty array. The
// counts give the real lengths.
#define CHECK(name, cnt, ws, kk, ...)                                          \
    do {                                                                       \
        const char *const words[] = ws;                                        \
        const char *const want[] = {__VA_ARGS__};                              \
        const char *out[sizeof words / sizeof words[0]];                       \
        const size_t want_k = kk;                                              \
        size_t got = toggle(words, cnt, out);                                  \
        int ok = got == want_k;                                                \
        for (size_t i = 0; ok && i < want_k; i++) {                            \
            ok = strcmp(out[i], want[i]) == 0;                                 \
        }                                                                      \
        if (!ok) {                                                             \
            fprintf(stderr, "case %s failed\n", name);                         \
            failures++;                                                        \
        }                                                                      \
    } while (0)

int main(void) {
    CHECK("colors", 4, L("red", "blue", "red", "green"), 2, "blue", "green");
    CHECK("fresh", 2, L("b", "a"), 2, "a", "b");
    CHECK("empty", 0, L(""), 0, "");
    CHECK("two-times", 2, L("a", "a"), 0, "");
    CHECK("three-times", 3, L("a", "a", "a"), 1, "a");
    CHECK("case", 2, L("a", "A"), 2, "A", "a");
    CHECK("prefix", 2, L("ab", "a"), 2, "a", "ab");
    if (failures > 0) {
        return 1;
    }
    printf("all cases pass\n");
    return 0;
}
Toggle.csI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

using System;
using System.Collections.Generic;
using System.Linq;

public static class Toggle
{
    // Run adds each word that is not in the set, and removes each word that is in it.
    public static string[] Run(IEnumerable<string> words)
    {
        var seen = new HashSet<string>(StringComparer.Ordinal);
        foreach (var word in words)
        {
            // Remove returns true if the set had the word.
            if (!seen.Remove(word))
            {
                seen.Add(word);
            }
        }
        return seen.Order(StringComparer.Ordinal).ToArray();
    }
}
ToggleTests.cs 26 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

using Xunit;

public sealed class ToggleTests
{
    public static TheoryData<string, string[], string[]> Cases => new()
    {
        { "colors", new string[] { "red", "blue", "red", "green" }, new string[] { "blue", "green" } },
        { "fresh", new string[] { "b", "a" }, new string[] { "a", "b" } },
        { "empty", new string[0], new string[0] },
        { "two-times", new string[] { "a", "a" }, new string[0] },
        { "three-times", new string[] { "a", "a", "a" }, new string[] { "a" } },
        { "case", new string[] { "a", "A" }, new string[] { "A", "a" } },
        { "prefix", new string[] { "ab", "a" }, new string[] { "a", "ab" } },
    };

    [Theory]
    [MemberData(nameof(Cases))]
    public void Check(string name, string[] words, string[] want)
    {
        Assert.NotNull(name);
        Assert.Equal(want, Toggle.Run(words));
    }
}
toggle.jsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

/**
 * @param {string[]} words
 * @returns {string[]}
 */
export function toggle(words) {
  const seen = new Set();
  for (const word of words) {
    // delete returns true if the set had the word.
    if (!seen.delete(word)) {
      seen.add(word);
    }
  }
  // The default sort compares UTF-16 code units, which is the byte order for ASCII.
  return [...seen].sort();
}
toggle.test.js 23 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

import assert from "node:assert/strict";
import { test } from "node:test";

import { toggle } from "./toggle.js";

const cases = [
  ["colors", ["red", "blue", "red", "green"], ["blue", "green"]],
  ["fresh", ["b", "a"], ["a", "b"]],
  ["empty", [], []],
  ["two-times", ["a", "a"], []],
  ["three-times", ["a", "a", "a"], ["a"]],
  ["case", ["a", "A"], ["A", "a"]],
  ["prefix", ["ab", "a"], ["a", "ab"]],
];

for (const [name, words, want] of cases) {
  test(name, () => {
    assert.deepEqual(toggle(words), want);
  });
}
toggle.tsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

export function toggle(words: readonly string[]): string[] {
  const seen = new Set<string>();
  for (const word of words) {
    // delete returns true if the set had the word.
    if (!seen.delete(word)) {
      seen.add(word);
    }
  }
  // The default sort compares UTF-16 code units, which is the byte order for ASCII.
  return [...seen].sort();
}
toggle.test.ts 23 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

import assert from "node:assert/strict";
import { test } from "node:test";

import { toggle } from "./toggle.ts";

const cases: [string, string[], string[]][] = [
  ["colors", ["red", "blue", "red", "green"], ["blue", "green"]],
  ["fresh", ["b", "a"], ["a", "b"]],
  ["empty", [], []],
  ["two-times", ["a", "a"], []],
  ["three-times", ["a", "a", "a"], ["a"]],
  ["case", ["a", "A"], ["A", "a"]],
  ["prefix", ["ab", "a"], ["a", "ab"]],
];

for (const [name, words, want] of cases) {
  test(name, () => {
    assert.deepEqual(toggle(words), want);
  });
}
toggle.goI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

// Package toggle builds a set of words.
package toggle

import (
	"maps"
	"slices"
)

// Toggle adds each word that is not in the set, and removes each word that is
// in it. It returns the words of the set in ascending order.
func Toggle(words []string) []string {
	// Go has no set type. A map with values of the empty struct type is a set,
	// and the values take no memory.
	seen := make(map[string]struct{})
	for _, word := range words {
		if _, ok := seen[word]; ok {
			delete(seen, word)
		} else {
			seen[word] = struct{}{}
		}
	}
	return slices.Sorted(maps.Keys(seen))
}
toggle_test.go 31 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

package toggle

import (
	"slices"
	"testing"
)

var cases = []struct {
	name  string
	words []string
	want  []string
}{
	{"colors", []string{"red", "blue", "red", "green"}, []string{"blue", "green"}},
	{"fresh", []string{"b", "a"}, []string{"a", "b"}},
	{"empty", []string{}, []string{}},
	{"two-times", []string{"a", "a"}, []string{}},
	{"three-times", []string{"a", "a", "a"}, []string{"a"}},
	{"case", []string{"a", "A"}, []string{"A", "a"}},
	{"prefix", []string{"ab", "a"}, []string{"a", "ab"}},
}

func TestToggle(t *testing.T) {
	for _, c := range cases {
		if got := Toggle(c.words); !slices.Equal(got, c.want) {
			t.Errorf("%s: got %q, want %q", c.name, got, c.want)
		}
	}
}
toggle.rsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

use std::collections::HashSet;

/// Adds each word that is not in the set, and removes each word that is in it.
/// Returns the words of the set in ascending order.
pub fn toggle<'a>(words: &[&'a str]) -> Vec<&'a str> {
    let mut seen: HashSet<&'a str> = HashSet::new();
    for &word in words {
        // remove returns true if the set had the word.
        if !seen.remove(word) {
            seen.insert(word);
        }
    }
    let mut out: Vec<&'a str> = seen.into_iter().collect();
    out.sort_unstable();
    out
}
tests/toggle_test.rs 20 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-a-set/.

use algo_create_a_set::toggle;

#[test]
fn cases() {
    let cases: Vec<(&str, Vec<&str>, Vec<&str>)> = vec![
        ("colors", vec!["red", "blue", "red", "green"], vec!["blue", "green"]),
        ("fresh", vec!["b", "a"], vec!["a", "b"]),
        ("empty", vec![], vec![]),
        ("two-times", vec!["a", "a"], vec![]),
        ("three-times", vec!["a", "a", "a"], vec!["a"]),
        ("case", vec!["a", "A"], vec!["A", "a"]),
        ("prefix", vec!["ab", "a"], vec!["a", "ab"]),
    ];
    for (name, words, want) in cases {
        assert_eq!(toggle(&words), want, "{name}");
    }
}
toggle.shI0RawGitHub
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-a-set/.

# toggle WORD...
# Adds each word that is not in the set, and removes each word that is in it.
# Prints the words of the set, one on each line, in ascending order by bytes.
toggle() {
  # Bash has no set type. The keys of an associative array are the set.
  local -A seen=()
  local word
  for word in "$@"; do
    if [[ -v seen[$word] ]]; then
      # The quotes stop the shell from reading seen[...] as a glob pattern.
      unset 'seen[$word]'
    else
      seen[$word]=1
    fi
  done
  if ((${#seen[@]} > 0)); then
    printf '%s\n' "${!seen[@]}" | LC_ALL=C sort
  fi
}
test_toggle.bats 27 lines
#!/usr/bin/env bats
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-a-set/.

bats_require_minimum_version 1.5.0

setup() {
  source "$BATS_TEST_DIRNAME/toggle.sh"
}

check() { # check WANT ARG...
  local want got
  # %b turns each \n in WANT into a newline. The x keeps the trailing
  # newlines, which $(...) removes.
  want=$(printf '%b' "$1"; printf x)
  shift
  got=$(toggle "$@"; printf x)
  [ "$got" = "$want" ] || { printf 'got:  %q\nwant: %q\n' "$got" "$want"; return 1; }
}

@test "colors" { check "blue\ngreen\n" red blue red green; }
@test "fresh" { check "a\nb\n" b a; }
@test "empty" { check ""; }
@test "two-times" { check "" a a; }
@test "three-times" { check "a\n" a a a; }
@test "case" { check "A\na\n" a A; }
@test "prefix" { check "a\nab\n" ab a; }

References

  1. Rust standard library, struct HashSet, insert; remove
  2. The Python Tutorial, Data Structures, 5.4 Sets
  3. MDN Web Docs, Set() constructor, Parameters
  4. Java SE 25 API, Interface Set, Unmodifiable Sets
  5. .NET API reference, HashSet<T> class, Constructors
  6. The Go Programming Language Specification, Map types
  7. Rust standard library, struct Vec, dedup
  8. cppreference.com, std::set, Description
  9. cppreference.com, strcmp (C), Return value
  10. Bash Reference Manual, 6.7 Arrays

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (bash)I0 not checked yet
  • the tests did not run in this build
Code (c)I0 not checked yet
  • the tests did not run in this build
Code (cpp)I0 not checked yet
  • the tests did not run in this build
Code (csharp)I0 not checked yet
  • the tests did not run in this build
Code (go)I0 not checked yet
  • the tests did not run in this build
Code (java)I0 not checked yet
  • the tests did not run in this build
Code (javascript)I0 not checked yet
  • the tests did not run in this build
Code (python)I0 not checked yet
  • the tests did not run in this build
Code (rust)I0 not checked yet
  • the tests did not run in this build
Code (typescript)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • a history with a source