Skip to content

Instantly share code, notes, and snippets.

View zsoltkebel's full-sized avatar

Zsolt Kébel zsoltkebel

  • ISIS Neutron and Muon Source
  • Oxford, UK
  • X @zkebel
View GitHub Profile
# algorithm to order sequence for optimal binary tree construction
import sys
def arrange(numArray):
if len(numArray) == 0:
return numArray
numArray.sort()
@zsoltkebel
zsoltkebel / tnpo.py
Last active February 22, 2022 09:08
Collatz Conjecture Efficient max step length finding algorithm with memoization
# Collatz conjecture:
# https://en.wikipedia.org/wiki/Collatz_conjecture#Iterating_on_all_integers
import sys
# s,f=sys.stdin.readline().split()
# s=int(s)
# f=int(f)
s = 1
f = 1000000
git init
git remote add <name> <link>
git add .
git log <remote/branch>
git status

Testing Multiple User Input in Python 3

What to do when you need to test a sequence of inputs to console in Python?

The return_value configures the value returned when the mock is called. It will always return the same value when the mock is called.

The side_effect argument can accept a function to be called when the mock is called, an iterable or an Exception. By passing in an iterable we can mock multiple inputs inside the testing function, because it will yield the next value everytime it’s called.

import unittest
@zsoltkebel
zsoltkebel / quickstart-python.md
Last active March 1, 2021 12:39
A Quickstart Guide for writing code in Python.

Quickstart Guide for Python

A Quickstart Guide for writing code in Python.

"Python is an experiment in how much freedom programmers need. Too much freedom and nobody can read another's code; too little and expressiveness is endangered." - Guido van Rossum


Table of Contents

@zsoltkebel
zsoltkebel / arm_run.sh
Last active February 22, 2021 17:47
A script for faster workflow when running assembly source code in Codio.
#!/bin/bash
# Set the execute permission for this file:
# $ chmod +x arm_run.sh
# use:
# $ ./arm_run.sh path/to/file //file name without .s extension
echo "Assembling and running file: $1.s"