Advent of Code, this year I will attempt the 25 different languages challenge

Overview

Advent of Code 2022

As this is my third year doing Advent of Code, this time I will try the 25 Different Languages Challenge, which is solving the problem each day with a different language. I will start with the old and Low-Level ones and work my way up to the ones I'm most comfortable with. The only goal for each language is defining and using a function. This will serve as a programming language history task and to check out interesting languages.

Day Solution Language Year Used b4 Installed Comment
01.sh Bash 1989 ✔️ ✔️ The default Linux Shell, a bit ugly
02.asm Assembly 1947 ✔️ Remembered the pain of jumping
03.f90 Fortran 1957 ✔️ Used WSL on VSCode Remote Shell
04.sql SQL 1974 ✔️ ✔️ Hold my tables
05.vb Visual Basic 1991 So my father used Visual Basic
06.pas Pascal 1970 Actually decent, except putting ;
07.scala Scala 2005 Java without ;
08.lua Lua 1993 Both gangster and slighly painful things
09.m MATLAB 1984 A bit restrictive but works
10.pl Perl 1987 ✔️ Acceptable, but $ and err checking sucks
11.swift Swift 2014 Pretty bad ngl
12.rb Ruby 1995 It's actually good but a lot of ends
13.jl Julia 2012 ✔️ Why are the ends necessary?
14.php PHP 1995 a bit painful $ and ; but does the job
15.r R 1993 ✔️ ✔️ Quite hard the problem, R did not help
16.rs Rust 2010 ✔️ It's interesting, owning is a bit weird
17.go Go 2009 ✔️ It's simple but disappointing
18.c C 1972 ✔️ ✔️ Worse language to debug
19.kt Kotlin 2011 ✔️ It's ok, has some cool things
20.js Javascript 1995 ✔️ ✔️ Never have I seen so many weird errors
21.cs C# 2000 ✔️ It does the job and is consistent
22.java Java 1995 ✔️ ✔️ Ok but cold be better and simpler
23.ts TypeScript 2012 ✔️ Probably better than Javascript?
24.cpp C++ 1985 ✔️ ✔️ C++ is funnier than I remembered
25.py Python 1991 ✔️ ✔️ I love Python

I used OneCompiler to write and run the languages I did not install on my pc.

01. Bash

Bourne Again SHell. Used for making Scripts. Comes with WSL (Windows Subsystem for Linux).

wsl
bash src/01.sh

02. Assembly

Has routines and operations on registers. Needs quite a lot of jumps, but at least has divison with remainder for modular arithmetic

03. Fortran

FORmula TRANslation The first commercially available language and one of the first high level programming languages, still used today for high performance computing. I installed it inside the Ubuntu version in WSL with: sudo apt install gfortran

wsl
gfortran src/03.f90
./a.out < inputs/03.txt

04. SQL

Structured Query Language, 'Ess-cue-ell'. Installed previously along the MySQL Workbench, which is useless so I uninstalled the Workbench. I used Linux's sed to replace - by , in the file to be able to load the file easily in sql.

wsl sed -i 's/-/,/g' inputs/04.txt
mysql --local-infile=1 -u root -p
source src/04.sql

05. Visual Basic

Needed to close a lot of whiles and ifs, but the closing of for was "Next" instead of "End For", WTF Microsoft. A lot uglier than the relevant programming languages from the same time.

06. Pascal

It's actually pretty decent, except for the fact that all the debugging I had to do was put ; almost everywhere (and not everywhere which makes it more painful).

07. Scala

Decent, I like not having to end lines with the ;

08. Lua

Getting the length of a string with # is really gangster, but getting a char from an string is really painful. Overall pretty good experience.

09. MATLAB

The functions are a bit pants because I can't edit a dictionary inside them, but overall it's decent. Used the official MATLAB Online IDE

10. Perl

It came installed with the Ubuntu version of the WSL.

wsl
perl src/10.pl < inputs/10.txt

11. Swift

It's actually really ugly to be used as a General Programming Language.

12. Ruby

Decent.

13. Julia

Installed the Julia Windows version.

Get-Content inputs/13.txt | julia src/13.jl

14. PHP

I thought previously that it was ugly, but it's actually acceptable to read and does the job. Though it's a bit painful to have to put $ before every single variable, why??? Even putting the ; at the end it's not remotely as painful as this.

15. R

Yay finally I can sleep. I installed previously RStudio but it's unncessary, only R and Rscript needed.

Get-Content inputs/15.txt | Rscript src/15.r

16. Rust

That was a ride indeed. Rust is actually quite interesting.

I installed Rust on WSL with: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

wsl
rustc src/16.rs
./16 < inputs/16.txt

Using tqdm for progress bar (needs a Cargo project?):

wsl
cargo new hello_cargo
cd hello_cargo
cp ../src/16.rs src/main.rs
cargo add kdam
cargo build
cargo run < ../inputs/16.txt

17. Go

Using Go official executable on Windows.

Get-Content inputs/17.txt | go run src/17.go

18. C

Using Cygwin on Windows.

gcc src/18.c
Get-Content inputs/18.txt | ./a.exe

19. Kotlin

Slowest language to compile ever (10 seconds from terminal, 3 seconds using IntelliJ IDEA). I installed the Kotlin command line compiler but it's necessary to create a Kotlin project with IntelliJ IDEA if you don't want to die while fixing compile errors.

kotlinc src/19.kt -include-runtime -d 19.jar
Get-Content inputs/19.txt | java -jar 19.jar

20. Javascript

Getting the input from stdin was even more difficult than assemlby... And so many weird things and errors.

Get-Content inputs/20.txt | node src/20.js

21. C#

Installed the .NET SDK.

dotnet new console -o app
cd app
cp ../src/21.cs Program.cs
Get-Content ../inputs/21.txt | dotnet run

22. Java

java src/22.java

23. TypeScript

npm install -g typescript
npm install @types/node --save-dev
tsc src/23.ts
node src/23.js

24. C++

g++ src/24.cpp
Get-Content inputs/24.txt | ./a.exe

25. Python

If it can be done in Python, it should be done in Python.

Get-Content inputs/25.txt | python src/25.py
You might also like...
Cloc - cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.

cloc Count Lines of Code cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. Latest release: v1.9

Run code from many programming languages!

Langbot Creating an image Install podman Build an image: podman build -t langbot . Running a language Run podman run --rm -i langbot ./scripts/run.sh

Demo app duplicated in 5 languages (Go/JavaScript/Python/Ruby/Rust) showing how to go from source code to container image using melange+apko

hello-melange-apko 💫 This repo contains an example app duplicated across 5 languages showing how to: Package source code into APKs using melange Buil

Code implementation of DDIA, primarily using Rust and Go languages.

Let's implement DDIA in rust and golang (with some Java and Cpp). This repository contains code implementations for 'Designing Data-Intensive Applicat

Shellfirm - Intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification
Shellfirm - Intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification

shellfirm Opppppsss you did it again? 😱 😱 😰 Protect yourself from yourself! rm -rf * git reset --hard before saving? kubectl delete ns which going

Rust vs C: Software Graphics Challenge
Rust vs C: Software Graphics Challenge

Rust vs C: Reto de Gráficos por Software Aprende Rust y C programando gráficos por software con efectos de demoscene clásica de los años 80. Episodios

⭐ Advent of Code 2020: Мade with Rust

Advent of Code 2020: Мade with Rust When I was solving puzzles, my goal was to practice writing idiomatic Rust. My solutions do not claim to be the fa

⭐ Advent of Code 2021: Мade with Rust

Advent of Code 2021: Мade with Rust When I was solving puzzles, my goal was to practice writing idiomatic Rust. My solutions do not claim to be the fa

Advent of Code 2021 puzzles & solutions in Rust

Advent of Code 2021 These are puzzles for the Advent of Code 2021 challenge, written and solved in the Rust programming language. The puzzle for each

Owner
Andreu Vall Hernàndez
Computer Science & Maths Student
Andreu Vall Hernàndez
Advent of Code 2021, in rust this year

Advent of Code 2021 ?? Solutions for the 2021 edition of Advent of Code. This year, I try to do this in Rust ?? . I discover the language, so do not t

Florian Gaudin-Delrieu 1 Aug 12, 2022
A simple trait-based framework for the annual Advent of Code programming challenge.

lib_aoc lib_aoc is a simple trait-based framework for the annual Advent of Code programming challenge. Focus less on the boilerplate and more on the p

null 2 Dec 8, 2022
Advent of Code 2021, also an attempt to practice a bit of Rust.

Advent of Code 2021 Advent of Code 2021 (my first one!), also an attempt to practice a bit of Rust. Running (Assuming that the respective inputs are i

Edoardo Debenedetti 1 Dec 3, 2021
🎄 Advent of Code written in various languages. (2015-2022)

?? Advent of Code This repository contains my solutions to the Advent of Code puzzles. Every year, I will try to solve the puzzles in a different lang

Tommy 2 Dec 15, 2022
Advent of Code, different language each day

I forgor ?? Advent Of Code 2022 Using a different language each Day!! (For obvious reason some solutions might be absolute shitcode, since I'm learnin

Ven 8 Dec 11, 2022
Rust-advent - Learning Rust by solving advent of code challenges (Streaming live on Twitch every Monday)

Rust advent ?? ?? Learning Rust by implementing solutions for Advent of Code problems. ?? HEY, we are live-streaming our attempts to solve the exercis

Luciano Mammino 20 Nov 11, 2022
zman is a CLI year (time) progress that small, fast, and just one single binary.

zman zman is a CLI year (time) progress that small, fast, and just one single binary. Features Show year progress Show month, and week progress Show r

azzamsa 17 Dec 21, 2022
Same procedure as every year… right?

Advent of Code 2022 solutions What this repository is This repository contains solutions to Eric Wastls Advent of Code 2022. Thank you, Eric! While th

Patrick 3 Dec 15, 2022
Convert a unix timestamp (seconds) to a struct {year, month, day, hour, minute, second, weekday}.

uts2ts uts2ts is a simple function that does only one thing: It converts a unix timestamp to something slightly more useful. ;-) So why then? Well, it

Helmut K. C. Tessarek 6 Jul 26, 2023
A CLI for analyzing the programming languages and how much code written in a project.

projlyzer A CLI for analyzing the programming languages and how much code written in a project. New features are on the way... Example Screenshot Buil

null 10 Apr 10, 2022