From ad803749480ca2213b6003500898354b7681bad1 Mon Sep 17 00:00:00 2001 From: Jens Glathe Date: Sun, 7 Apr 2019 14:32:03 +0200 Subject: [PATCH] fix: make bubblesort.py compatible with python3 chore: amend the comments in threadtesttool for clarity --- bubblesort.py | 20 +++++++++++++------- threadtesttool.c | 7 +++++-- 2 files changed, 18 insertions(+), 9 deletions(-) mode change 100644 => 100755 bubblesort.py diff --git a/bubblesort.py b/bubblesort.py old mode 100644 new mode 100755 index 2d998a0..046a859 --- a/bubblesort.py +++ b/bubblesort.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # # Understanding Bubble Sort with Examples and Code! # https://youtu.be/WOjc48sVo6E @@ -5,22 +7,26 @@ def bubblesort(list): swapped = True while swapped: - print - print "New iteration..." + print(); + print("New iteration..."); swapped = False for i in range(len(list)-1): if(list[i] > list[i+1]): - print "Index: " + str(i) + " - Swap " + str(list[i]) + " with " + str(list[i+1]) + print("Index: " + str(i) + " - Swap " + str(list[i]) + " with " + str(list[i+1])) tmp = list [i] list[i] = list[i+1] list[i+1] = tmp swapped = True - print list - print "Nothing left to swap. Done" + print(list) + print ("Nothing left to swap. Done") return list +print(); +print("Understanding Bubble Sort with Examples and Code! https://youtu.be/WOjc48sVo6E") +print(); + l = [5,8,1,4,2] -print l +print(l) l = bubblesort(l) -print l +print(l) diff --git a/threadtesttool.c b/threadtesttool.c index 2950364..d7cd37f 100644 --- a/threadtesttool.c +++ b/threadtesttool.c @@ -25,15 +25,18 @@ // // Comile with: // gcc -lpthread -o threadtesttool threadtesttool.c +// On Linux, you can compile (optimizations again optional) it with: +// gcc -O3 -o threadtesttool threadtesttool.c -pthread // // // Usage: -// threadtesttool [[num_threads] num_primes_to_find] +// Usually you use this together with time to get a measurement. +// time ./threadtesttool [[num_threads] num_primes_to_find] // // OR // -// nothreadtesttool [[num_threads] num_primes_to_find] +// time ./nothreadtesttool [[num_threads] num_primes_to_find] // // Note to create "nothreadtesttool" use: // ln -s threadtesttool nothreadtesttool