Event Start:
This coding challenge was made by humans for humans, for the fun of puzzling. Please look somewhere else if you just want to practice your prompting strategies. You'll find other websites with more suitable challenges elsewhere.
How can you join in?
Pick your favorite programming language and get started! These puzzles are designed so they can be solved in any language. Just log in with your GitLab, GitHub or Google account and grab your personalized puzzle input as a .txt file from the calendar's puzzle page.
Rules
At 5 p.m. on the given day, a Christmas bauble is unlocked (click on the Christmas tree). Behind it you'll find the puzzle description and a link to download your puzzle input as text. Solve the puzzle by calculating a single number or a single word from the input, as the description asks. Submit your answer with the "Submit" button and the site will tell you whether it was correct. You can try as often as you like, but you have to wait a short while between attempts. Each puzzle always has two parts. Once you've found the first answer, you unlock the second half of the puzzle. The input stays the same, but the puzzle has to be solved a little differently for the second part. As soon as you've found both answers, you're done!
Everyone gets a different puzzle input! So copying other people's answers won't get you far :^)
The Leaderboard
You get points for every correct answer. The first person to find the correct answer to a puzzle gets 50 points. The second gets 49 points, and so on. Everyone after the first 50 people gets 0 points. So you can earn a maximum of 100 points per day.
Getting Started (Code Snippets)
If you're not quite sure how to start programming, here are a few example snippets in different languages. They show how to read your puzzle input from a saved .txt file:
def parse_input(path: str) -> list[str]:
with open(path, 'r', encoding='utf-8') as f:
lines = f.read().splitlines()
return lines
def main():
lines = parse_input("day1-input.txt")
for line in lines:
print(line)
# your puzzle solution here
if __name__ == "__main__":
main()import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class Day1 {
public static List<String> parseInput(String path) {
try {
return Files.lines(Paths.get(path), StandardCharsets.UTF_8).toList();
} catch (IOException e) {
System.out.println("File not found: " + path);
System.exit(1);
return null;
}
}
public static void main(String[] args) {
List<String> lines = parseInput("day1-input.txt");
for (String line : lines) {
System.out.println(line);
// your puzzle solution here
}
}
}#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <locale>
#include <codecvt>
std::vector<std::string> parseInput(const std::string& path) {
std::ifstream file(path, std::ios::binary);
std::vector<std::string> lines;
if (!file.is_open()) {
std::cerr << "File not found: " << path << std::endl;
return lines;
}
file.imbue(std::locale(file.getloc(), new std::codecvt_utf8<char>));
std::string line;
while (std::getline(file, line)) {
lines.push_back(line);
}
return lines;
}
int main() {
std::vector<std::string> lines = parseInput("day1-input.txt");
for (const auto& line : lines) {
std::cout << line << std::endl;
// your puzzle solution here
}
}
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func parseInput(filename string) ([]string, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
if err := scanner.Err(); err != nil {
return nil, err
}
return lines, nil
}
func main() {
lines, err := parseInput("day1-input.txt")
if err != nil {
log.Fatalf("Error reading file: %v", err)
}
for _, line := range lines {
fmt.Println(line)
// your puzzle solution here
}
}
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn parse_input(path: &str) -> io::Result<Vec<String>> {
let file = File::open(path)?;
let lines = io::BufReader::new(file)
.lines()
.collect::<Result<_, _>>()?;
Ok(lines)
}
fn main() -> io::Result<()> {
let lines = parse_input("day1-input.txt")?;
for line in lines {
println!("{}", line);
// your puzzle solution here
}
Ok(())
}