Instantly share code, notes, and snippets.

# Nikodemus Karlsson nikodemusk

Created August 27, 2022 19:32
Factorization of a number to primes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Factorization of a number to primes from math import sqrt the_number = 2*3*3*5**3*35*51 primes = [] def factorize(number): factor_1 = 1 factor_2 = 2 while factor_2 <= int(sqrt(number)): if number % factor_2 == 0:
Created August 29, 2021 17:01
From Project Euler, https://projecteuler.net/problem=2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Program som beräknar summan av de jämna Fibonacci-talen, # där den största termen är som mest 4 000 000. # Se https://projecteuler.net/problem=2 a = 1 b = 2 # Listan fib_numbers kommer att innehålla de Fibonacci-tal # som ska summeras fib_numbers = []
Last active February 8, 2021 07:53
JavaScript-fil till canvas-1 övning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // Några grundläggande inställningar var canvas = document.querySelector('canvas'); canvas.width = window.innerWidth; canvas.height = 0.8*window.innerHeight; // Genom variabeln c kommer man åt det mesta som // med canvas att göra var c = canvas.getContext('2d'); // Blå kvadrat
Last active April 1, 2022 13:23
HTML-fil till canvas-1 övning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Canvas Intro
Last active October 9, 2020 06:41
Exempel och uppgifter som rör Pythons bibliotek Turtle. Ska bl a tjäna som en översiktlig introduktion till objektorienterade programmering.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Exempelkod som visar några egenskaper hos Pythons bibliotek Turtle # Fullständig referens till biblioteket finns på # https://docs.python.org/3/library/turtle.html import turtle as t import random as r aTurtle = t.Turtle() # Initierar en sköldpadda bTurtle = t.Turtle() # Initierar en till sköldpadda # Funktion som sätter slumpad färg
Last active September 6, 2020 10:41
Kodskelett till en kalkylator i Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Detta är ett kodskelett till en kalkylator för # addition, subtraktion och multiplikation. Användaren # ska ange två tal och operator (räknesätt), varpå # programmet skriver ut resultatet av operationen. # # Val av operator är "inmatningssäkert" i loopskelettet, # dvs programmet kraschar inte om ett odefinierat # alternativ anges. Däremot finns ingenting i kodskelettet # som kontrollerar att det är riktiga tal som matas in. # Om du vill utöka programmet med sådan kontroll finns
Created July 6, 2019 19:56 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

# tmux shortcuts & cheatsheet

start new:

``````tmux
``````

start new with session name:

``````tmux new -s myname
``````
Last active November 1, 2018 14:35
Gyllene snittet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Detta program tar fram ett närrmevärde på det # Gyllene snittet enligt kedjebråksutvecklingen # # 1 # phi = 1 + ----------------------- # 1 # 1 + -------------------- # 1 # 1 + ------------------
Created October 15, 2018 19:42 — forked from md2perpe/pretty_print.py
Pretty print av polynom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # https://www.facebook.com/photo.php?fbid=10155461108530633&set=p.10155461108530633&type=3&theater&ifg=1 def prettyPrint(lista): # Funktionen tar en lista med koefficienter # till ett polynom i avtagande ordning och # skriver ut polynomet # Polynomets gradtal polynomets_gradtal = len(lista) - 1
Last active August 18, 2018 13:46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Validating input in Python def inputNumber(textOutput): while True: try: userInput = float(input(textOutput)) # or int except ValueError: print("This is not a number, try again.") continue else: