Solutions for Muetzilla's Advent Calendar

Overview

Solutions for Muetzilla's Advent Calendar

Link To the Advents Calendar

Content

Problem 1

Hello World in a new Language: Go

Source Code

package main

func main() {
	println("Hello World!")
}

Problem 2

Calculate the LCM from numbers 1 - 10

Source Code

  • The Function size_t lcm(size_t a, size_t b) takes 2 numbers as parameters.
  • The Bigger number of the two is used as a start.
  • Then the program counts up until the number is divisible by both numbers.
size_t lcm(size_t a, size_t b) {
    int max = (a > b) ? a : b;

    while (1) {
        if (max % a == 0 && max % b == 0) {
            return max;
        }

        ++max;
    }
}

Problem 3

Calculate the GCD of all numbers from 1 - 10

Source Code

  • The Function private int findGCD(int a, int b) takes 2 numbers as parameters.
  • This Function will be called recursively with the args (b, a % b) until b == 0 and a is returned.
private int findGCD(int a, int b) {
    if (b == 0) return a;
    return findGCD(b, a % b);
}

Problem 4

Create a Calculator using Python which can do (+-*/) operations.

Source Code

  • First the calculation is split into it's parts (numbers & operators)
    • 15 + 53 * 10 => ['15', '+', '53', '*', '10']
  • Then the operations * and / are performed
    • def point_calc(calc):
    • => ['15', '+', '530']
  • Finally the operations + and - are performed
    • def dash_calc(calc):
    • => [545]
split = split_calculation(calculation)
try:
    after_point = point_calc(split)
    after_dash = dash_calc(after_point)
    print(f"The result is: {after_dash}")
except:
    print("The calculation you entered is not Valid!")

Problem 5

Make a Program to calculate the circumference and area of a Shape

Source Code

Enum with functions for shapes enum class Shape(val circumerence: () -> Double, val area: () -> Double)

Problem 6

Create a Program in any JVM Language, which takes user input and converts it to the nth Primenumber

Language used: Scala

Source Code

private def isPrime(n: Int): Boolean = {
    for (i <- 2 to (n / 2)) {
        if (n % i == 0) return false
    }

    true
}

How To Run The Code

  • Go
    • Install Golang on your local machine
    • Run the following command in a terminal: go run .\ProblemXX.go
  • C
    • Install a C compiler (Ex. GCC)
    • Run the following command: gcc ProblemXX.c -o ProblemXX
    • Run the created .exe / .o file
  • Java
    • Install JDK & JRE
    • Run the following commands in a terminal: javac .\ProblemXX.java; & java ProblemXX
  • Python
    • Install Python on your system
    • Run the following command: python ProblemXX.py
  • Kotlin
    • Install Kotlin
    • Run the following command: kotlinc ProblemXX.kt -include-runtime -d ProblemXX.jar
    • To Run the Problem, run: java -jar ProblemXX.kt
  • Scala
    • Install Scala
    • Run the following commands:
      • Compile: scalac ProblemXX.scala
      • Run: scala ProblemXX
You might also like...
A Jetpack Compose library for handling calendar component rendering.
A Jetpack Compose library for handling calendar component rendering.

Compose Calendar Compose Calendar is a composable handling all complexity of rendering calendar component and date selection. Due to flexibility provi

Calendar - A component for compose desktop
Calendar - A component for compose desktop

日历 一个用于compose-desktop的日历组件。 截图 feature DayPicker的动画 月份选择器错误提示 点击非本月的时间会跳到上个月 to

Solutions for Muetzilla's Advent Calendar

Solutions for Muetzilla's Advent Calendar Link To the Advents Calendar Content Solutions for Muetzilla's Advent Calendar Content Problem 1 Problem 2 P

Android calendar view inspired by Sunrise calendar and iOS7 stock calendar
Android calendar view inspired by Sunrise calendar and iOS7 stock calendar

SilkCal Android calendar view inspired by Sunrise calendar and iOS7 stock calendar. Usage Add compile 'me.nlmartian.silkcal:library:0.1.1' to your dep

Android calendar view inspired by Sunrise calendar and iOS7 stock calendar
Android calendar view inspired by Sunrise calendar and iOS7 stock calendar

SilkCal Android calendar view inspired by Sunrise calendar and iOS7 stock calendar. Usage Add compile 'me.nlmartian.silkcal:library:0.1.1' to your dep

My Advent of Code solutions written in Kotlin

AOC21 My Advent of Code solutions written in Kotlin Why Kotlin? I think Kotlin is a really suitable language for Advent of Code, because it handles li

My solutions for Advent of Code 2021 puzzles, mainly using Kotlin.

Advent of Code 2021 Featuring Kotlin What's that ? https://adventofcode.com/2021/about Advent of Code is an Advent calendar of small programming puzzl

My solutions for Advent of Code 2021, written in Kotlin!

Advent-of-Code-2021 Welcome to the Advent of Code1 Kotlin project created by thijsboehme using the Advent of Code Kotlin Template delivered by JetBrai

Advent of Code 2021: Solutions in Kotlin

Advent of Code 2021 Solutions in Kotlin This repo is my personal attempt at solving the Advent of Code 2021 set of problems with the Kotlin programmin

🎅 Marry XMas 🎄 Kotlin solutions for my Advent of Code 2021 🤶

Advent of Code 2021 🎄 val aMessageFromMe = """ _____________,--, | | | | | | |/ .-.\ HANG IN THERE |_|_|_|_|_|_/ / `. SAN

My solutions for the Advent of Code 2021. See the link for a playlist with recordings of me solving each puzzle.

Advent of Code 2021 My solutions for the Advent of Code 2021 solved with Kotlin. What is the Advent of Code? Advent of Code is an online event created

My Advent Of Code 2021 solutions 🎄🎅

AdventOfCode2021 In this repository, i am about to provide solutions for the Advent of Code1 puzzles using Kotlin language. Footnotes Advent of Code –

Advent of Code 2021 in Kotlin, solved by myself. Focus on code readability. With GitHub Actions all puzzles are executed and their solutions printed

Advent of Code 2021 in Kotlin Focus on Code Readability. With CI Solution Printing. Welcome to the Advent of Code1 Kotlin project created by michaeltr

My advent of code 2021 solutions.

Advent of code 2021 These are my kotlin solutions for however long I manage to take part without giving up. How to run Add a Config.kt file locally an

🎄 Solutions to Advent of Code 2021 in Kotlin 💜

Advent of Code 2021 in Kotlin These are my solutions to Advent of Code 2021 using the Kotlin language. Each day has its own subpackage. Try the proble

Solutions to advent of code 2021 in the gen-Z programming language known as kotlin

Advent Of Code 2021 - Kotlin Edition How to run? Get the kotlin SDK using the sdkman tool: https://sdkman.io/sdks#kotlin Run the commands: ./gradlew

My solutions for advent of code challenges 2021.

advent-of-code-2021 Welcome to the Advent of Code1 Kotlin project created by hiteshchalise using the Advent of Code Kotlin Template delivered by JetBr

The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Custom-Calendar-View To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this by eith

Kalendar - A calendar to integrate Calendar with Custom design in your jetpack compose project
Kalendar - A calendar to integrate Calendar with Custom design in your jetpack compose project

Kalendar - An Elementary Compose Calendar. This is a calendar to integrate Calen

Owner
Marc Andri Fuchs
Why is the compiler always angry at me :(
Marc Andri Fuchs
📅 Minimal Calendar - This calendar library is built with jetpack compose. Easy, simple, and minimal.

?? Minimal Calendar This calendar library is built with jetpack compose. Easy, simple, and minimal. Latest version The stable version of the library i

Minjae Kim 16 Sep 14, 2022
A better calendar for Android

Caldroid Caldroid is a fragment that display calendar with dates in a month. Caldroid can be used as embedded fragment, or as dialog fragment. User ca

Roomorama 1.4k Nov 29, 2022
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Square 4.4k Dec 20, 2022
An android library which provides a compact calendar view much like the one used in google calenders.

CompactCalendarView CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar clas

SundeepK 1.5k Jan 7, 2023
📅 CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.

CosmoCalendar Made by Applikey Solutions Usage Customization Common Selection Current day Navigation buttons Weekend days Connected days Disabled days

Applikey Solutions 1.6k Dec 22, 2022
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour

CustomizableCalendar This library allows you to create a completely customizable calendar. You can use CustomizableCalendar to create your calendar, c

MOLO17 216 Dec 6, 2022
Demo app for a horizontal schedule(event) calendar

This is a demo project that showcases a horizontally laid out calendar that shows events in a timeline fashion. It is not a library, just a reference implementation for curious developers.

Halil Ozercan 188 Dec 26, 2022
Android open source calendar

Etar Calendar Etar (from Arabic: إِيتَار) is an open source material designed calendar made for everyone! Why? Well, I wanted a simple, material desig

null 1.5k Jan 4, 2023
A simple calendar with events, customizable widgets and no ads.

Simple Calendar A simple calendar with events and a customizable widget. A simple calendar with optional CalDAV synchronization. You can easily create

Simple Mobile Tools 3k Jan 4, 2023
Kmpcalendar - A calendar library and views written for kotlin multiplatform

KMPCalendarView Minimal Kotlin Multiplatform project with SwiftUI, Jetpack Compo

Anmol Verma 2 Oct 7, 2022