... "97% will fail this test"

Begonnen von herrmannj, 28 Januar 2021, 01:18:27

Vorheriges Thema - Nächstes Thema

herrmannj

Coole Lösung, auch von Wahl des Werkzeuges. Nochmals Faktor 10 schneller.

xenos1984

Es geht noch etwas schneller. C++, kompiliert mit

g++ -O3 -o pah1 -std=c++2a pah1.cpp

Aufruf:

./pah1 <Endergebnis> <Zahl1> <Zahl2> ... <ZahlN>

Timing mit den Beispielen:


$ time ./pah1 24 3 3 8 8
(/ 8 1/3) : [ 24 ] <- [ 1/3 8 ]
(- 3 8/3) : [ 1/3 8 ] <- [ 8/3 3 8 ]
(/ 8 3) : [ 8/3 3 8 ] <- [ 3 3 8 8 ]

real    0m0,006s
user    0m0,001s
sys     0m0,006s

$ time ./pah1 36 1 9 6 8
(/ 9 1/4) : [ 36 ] <- [ 1/4 9 ]
(- 1 3/4) : [ 1/4 9 ] <- [ 3/4 1 9 ]
(/ 6 8) : [ 3/4 1 9 ] <- [ 1 6 8 9 ]

real    0m0,007s
user    0m0,003s
sys     0m0,004s

$ time ./pah1 54 1 9 6 8
(/ 6 1/9) : [ 54 ] <- [ 1/9 6 ]
(- 1 8/9) : [ 1/9 6 ] <- [ 8/9 1 6 ]
(/ 8 9) : [ 8/9 1 6 ] <- [ 1 6 8 9 ]

real    0m0,007s
user    0m0,007s
sys     0m0,000s

$ time ./pah1 -24 1 9 6 8
(* -3 8) : [ -24 ] <- [ -3 8 ]
(- 6 9) : [ -3 8 ] <- [ 6 8 9 ]
(* 1 6) : [ 6 8 9 ] <- [ 1 6 8 9 ]

real    0m0,006s
user    0m0,006s
sys     0m0,000s

justme1968

hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

herrmannj