~athorp96/kattis-solutions

c8f20420e6b1b820d98ce50be61a74f1cd0f5313 — Andrew Thorp 4 years ago
Initial Commit
A  => README.md +6 -0
@@ 1,6 @@
# Kattis Solutions

My personal solutions to [Kattis](kattis) problems in various languages.

[kattis](https://open.kattis.com)


A  => odd_man_out/odd_man_out.py +37 -0
@@ 1,37 @@
"""
Input
    The first line of input gives the number of cases, N.
    N test cases follow. For each test case there will be:
        - One line containing the value G, the number of guests.
        - One line containing a space-separated list of G integers.
          Each integer C indicates the invitation code of a guest.
    You may assume that 1≤N≤50,0<C<231,3≤G<1000

Output
    For each test case, output one line containing
    “Case #x: ” followed by the number C of the guest who is alone.
"""
n = int(input())
found=set()
for i in range(n):
    # There may be optimization around knowing G,
    # but since Sets do not allow an initial size
    # I could not think of any. If they did, we
    # eliminate set resize time (should the set
    # initial list size be exceeded).
    input()
    # Iterating through the list of codes,
    # we are operating under the assumption that
    # only two occurrences of any number can appear
    for c in input().split(' '))
        # Add new elements to a set
        if c in found:
            found.discard(c)
        # Delete duplicate elements from the set
        else:
            found.add(c)
    # Since the only item without a duplicate is the
    # solution, and we deleted all duplicates, popping
    # the found set should return the solution AND empty
    # the set for the next loop
    print(f"Case #{i+1}: {int(found.pop())}")

A  => stuck_in_a_time_loop/main.go +19 -0
@@ 1,19 @@
package main

import (
	"fmt"
	"strconv"
)

func main() {
	fmt.Print("Enter number: ")
	var in string
	fmt.Scanln(&in)
	n, err := strconv.Atoi(in)
	if err != nil {
		fmt.Printf("Thats not a number: %v\n", err)
	}
	for i := 1; i <= n {
		fmt.Printf("%d Abracadabra\n", i++)
	}
}

A  => stuck_in_a_time_loop/stuck_in_a_time_loop +0 -0