AminetAminet
Search:
84481 packages online
About
Recent
Browse
Search
Upload
Setup
Services

misc/math/CEB.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:Solves a 'Countdown' arithmetic problem
Author:gilles (dot) bannay (at) free.fr (Gilles BANNAY)
Uploader:flype44 gmail com (Philippe CARPENTIER)
Type:misc/math
Version:1.67
Architecture:m68k-amigaos >= 2.0
Distribution:Aminet
Date:2023-08-26
Download:http://aminet.net/misc/math/CEB.lha - View contents
Readme:http://aminet.net/misc/math/CEB.readme
Downloads:327

DESCRIPTION:
 
 Solves a 'Countdown' arithmetic problem (in english) or 'Le Compte Est Bon'
 (in french).
 
 The target must be fitted arithmetically with the argument list and the 
 operators +, -, *, / (and optionally exponant). See Help() function below 
 for all options.


PRINCIPLE:

 Solves [target] from [a1, a2, a3, a4, a5, a6].
 
 Solves [67] from [15, 8, 50, 4, 5, 21].
 
 One possible answer could be :
 
 5 * 15 = 75
 75 - 8 = [67]


SYNTAX:

 CEB a1 a2 a3 a4 a5 a6 [target] [options]


AMIGA PORT:
 
 You probably all knows the TV game on which you need solves arithmetically
 a number from six random numbers. This program, CEB, written by Gilles 
 BANNAY, is a resolver for this game. It was last updated in 2012.
 
 It was originally compiled for GCC compiler (intel-linux), using :
 gcc -march=i686 -O2 -fomit-frame-pointer -oceb ceb.c
 
 I compiled it on Amiga with the SAS/C Compiler 6.59 (m68k-amiga), 
 without any modification.
 sc ceb.c TO ceb_ANY LINK CPU=ANY   MATH=STANDARD CHKABORT NOICONS STRIPDEBUG
OPT OPTGO
 sc ceb.c TO ceb_020 LINK CPU=68020 MATH=STANDARD CHKABORT NOICONS STRIPDEBUG
OPT OPTGO
 sc ceb.c TO ceb_040 LINK CPU=68040 MATH=STANDARD CHKABORT NOICONS STRIPDEBUG
OPT OPTGO
 sc ceb.c TO ceb_060 LINK CPU=68060 MATH=STANDARD CHKABORT NOICONS STRIPDEBUG
OPT OPTGO
 
 ENGLISH VERSION:
 Executable    MD5                                 Size
 ceb_en_ANY    9ffe2fa2c27dcce0185886c42aacfc11    27936 bytes
 ceb_en_020    06fe97e8480260865708cc83a024af0d    27672 bytes
 ceb_en_040    df1758e1bd951956ba2bf9ec5ed8b021    27660 bytes
 ceb_en_060    b7547d83a0212cec3f4b1ed42ceff89e    27684 bytes
 
 FRENCH VERSION:
 Executable    MD5                                 Size
 ceb_fr_ANY    05a78fd08cd74888af63fb5fff46e212    27980 bytes
 ceb_fr_020    bac3b367f5611dea794c7e1a3622353a    27716 bytes
 ceb_fr_040    6046a476413aaf6f55b0871b730ea656    27704 bytes
 ceb_fr_060    f82b87ec44f52838b8f39944a8b860a0    27728 bytes


HISTORY:                

 V 1.00  (GBY)   11-Mar-1998 Mod: creation
 V 1.01  (GBY)   02-Mai-1998 Add: Linux portage
 V 1.10  (GBY)   03-Mai-1998 Fix: display issue when lines<5
 V 1.20  (GBY)   05-Mai-1998 Opt: rewrite EssaiOp() for speed
                             Add: BorlandC 4.5 portage
                             Add: verbose in multi-line format (-v option)
 V 1.30  (GBY)   01-Sep-2000 Opt: add some tests in EssaiOp()
                             Opt: don't explore 2*2 after 2+2
 V 1.31  (GBY)   01-Sep-2000 Add: excluding mode ('-x[P]' option)
 V 1.40  (GBY)   02-Sep-2000 Mod: rewrite code
 V 1.41  (GBY)   02-Sep-2000 Opt: using SWAP
 V 1.42  (GBY)   06-Sep-2000 Add: variable arguments number ('-a[N]' option)
 V 1.43  (GBY)   07-Sep-2000 Add: diagnostic mode ('-d' option)
 V 1.44  (GBY)   08-Sep-2000 Add: using mode ('-u[N]' option)
                             Fix: special case for -u0 et -u1
                             Add: optimize mode ('-o' option)
 V 1.45  (GBY)   15-Sep-2000 Add: mapping mode for statistics
 V 1.50  (GBY)   23-Jan-2001 Mod: 16 bits compiler portage
                             Mod: max arguments number = 64.
 V 1.51  (GBY)   23-May-2006 Add: operators selection (-s[+*-/] option)
 V 1.52  (GBY)   01-Mar-2007 Add: exponant operator selection (-s[+*-/e] option)
 V 1.53  (GBY)   16-Mar-2007 Add: verbose in one-line format (-v1 option)
                             Add: test overflow.
 V 1.54  (GBY)   18-Mar-2007 Add: associativity
 V 1.60  (GBY)   19-Mar-2007 Fix: -s option (- without + or / without *)
 V 1.61  (GBY)   09-Avr-2011 Add: -g option global
 V 1.62  (GBY)   11-Avr-2011 Fix: bugfix end variable init
 V 1.63  (GBY)   30-Avr-2011 Add: -w option (with)
 V 1.64  (GBY)   01-May-2011 Mod: merge 1.62 & 1.63 version for performance
                             Fix: Operation with 0^0=1 is allowed.
 V 1.65  (GBY)   14-Sep-2012 Add: -f option (fractionnal)
 V 1.66  (GBY)   29-Sep-2012 Opt: power_frac() uses nthroot() in place of exp &
log
 V 1.67  (GBY)   22-Oct-2012 Opt: Elag tree with 'first' parameter 


HELP ENGLISH:

CEB a1 a2 a3 a4 a5 a6 [target] [options]

Solves  a  'Countdown'  or  a  'Compte Est Bon'  problem.
The  target  must be fitted  arithmetically  with the six
arguments 'a1'..'a6' and the operators +, -, *, /, ^.

a1..a6    six numerical positive arguments.
[target]  target number to fit.
          When 'target' is not present CEB returns a
          statistics for the targets from 0 to 999.
[options] Permits to define some default parameters:       
-aN       set the number of arguments to N (default is 6)
-bP       set the begin limit for statistics (default is 0)
-d        prints debug information
-eP       set the end limit for statistics (default is 999)
-f        fractionnal numbers allowed
-g        global mode
-o        optimizes the number of arguments used           
-s[+*-/e] set the allowed operators list (default is +*-/)
-uP       using P arguments or less (default is N)
-v        displays the solution (multi-lines format)
-v1       displays the solution (one-line format)
-wP       with P arguments or more (default is 1)
-xP       search up to Pth unfit target (no default)


HELP FRENCH:

CEB a1 a2 a3 a4 a5 a6 [cible] [options]

Permet de resoudre un probleme du type 'Le Compte Est Bon'.
La cible doit etre atteinte arithmetiquement avec les six 
nombres 'a1'..'a6' et les operateurs +, *, -, /, ^

a1..a6    Six arguments numeriques positifs.
[cible]   Nombre positif a atteindre.
          Si 'cible' n'est pas precisee, retourne pour les
          cibles de 0 a 999 une statistique des solutions.
[options] Permet de modifier certaines valeurs par defaut:
-aN       fixe a N le nombre d'arguments (6 par defaut)
-bP       fixe a P la borne min pour stat (0 par defaut)
-d        mode debug                                       
-eP       fixe a P la borne max pour stat (999 par defaut)
-f        nombres fractionnaires autorises                 
-g        mode global                                      
-o        recherche avec nombre d'arguments minimum        
-s[+*-/e] liste des operateurs autorises (+*-/ par defaut)
-uP       avec au plus P arguments utilises (N par defaut)
-v        affiche la solution (en multi-lignes)
-v1       affiche la solution (en une ligne)
-wP       avec au moins P arguments utilises (1 par defaut)
-xP       recherche jusqu'au Pieme recalcitrant.


EXAMPLES:

Below are some examples, among others. There are lots of options, so 
better try by yourself, that's part of the fun :)

Beware with some combinations that would be unlogical, i noticed  
some cases that produce very very long calcs, or abnormally long.

1.
What you certainly want to see for a very first try is the following example.
It ask how to solves the target [342] by using the [+, -, /, *] arithmetic 
operators and by using the numbers [15, 49, 8, 50, 4, 5].

> ceb 15 49 8 50 4 5 342 -v
4 + 50 = 54
5 * 54 = 270
49 + 15 = 64
8 + 64 = 72
270 + 72 = 342


2.
Given 6 initial numbers, but no target number, CEB returns statistics 
for the targets from 0 to 999. Here, for example, 838, 953, and 955 
are invalid targets. All other targets from 0 to 999 have a solution.

> ceb 15 49 4 50 8 4
unfit = 838 953 955
Success = 99.70%, 3 unfit in 0-999.


3.
Some other set of numbers, which have a solution for any 
number from 0 to 999.

> ceb 15 49 8 50 4 5
unfit =
Success = 100.00%, 0 unfit in 0-999.


4.
Same as previous, and let's see if it have at least one solution for 
the target number 342.

> ceb 15 49 4 50 8 4 342
Solved !


5.
Same as previous, with the solution, in one-line format.

> ceb 15 49 8 50 4 5 342 -v1
((5 * (4 + 50)) + (8 + (49 + 15))) = 342


6.
The solution found is not necessarily the best one.
It's only the 'first' one the algorithm finds.
But you can ask explicitely for the shortest solution with -o.

> ceb 15 49 8 50 4 5 342 -v1 -o
((8 * 49) - 50) = 342


7.
Or the opposite, to ask the longest solution, using -wP.

> ceb_en_060 15 49 8 50 4 5 342 -v -w6
4 + 50 = 54
5 * 54 = 270
49 + 15 = 64
8 + 64 = 72
270 + 72 = 342


8.
To use less or more than 6 initial numbers, use the -aN parameter.

> ceb 15 49 8 50 342 -a4 -v1 -o
((8 * 49) - 50) = 342


9.
To force use only some arithmetic operators, use the -s parameter.
This of course will changes the possible solutions.

> ceb 15 49 8 50 4 5 131 -v1 -o -s+-
(5 + (4 + (50 + (8 + (49 + 15))))) = 131

> ceb 15 49 8 50 4 5 131 -v1 -o -s-*
((4 * (49 - 15)) - 5) = 131

> ceb 50 60 70 80 2 3 9 -v1 -o -s+-*/
(2 + (70 / (60 - 50))) = 9

> ceb 50 60 70 80 2 3 9 -v1 -o -s+-*/e
(3 ^ 2) = 9

> ceb 50 60 70 80 3 3 27 -v1 -o -s+-*/e
(3 ^ 3) = 27


Contents of misc/math/CEB.lha
PERMISSION  UID  GID    PACKED    SIZE  RATIO METHOD CRC     STAMP     NAME
---------- ----------- ------- ------- ------ ---------- ------------ ----------
[unknown]                10262   49350  20.8% -lh5- 67b1 Aug 26 03:05 ceb.c
[unknown]                 3611    8991  40.2% -lh5- bd52 Aug 26 09:51 ceb.readme
[unknown]                15559   27672  56.2% -lh5- ca33 Aug 26 02:58 ceb_en_020
[unknown]                15549   27660  56.2% -lh5- c153 Aug 26 02:58 ceb_en_040
[unknown]                15552   27684  56.2% -lh5- c852 Aug 26 02:59 ceb_en_060
[unknown]                15712   27936  56.2% -lh5- ad62 Aug 26 02:59 ceb_en_ANY
[unknown]                15581   27716  56.2% -lh5- c2d0 Aug 26 03:06 ceb_fr_020
[unknown]                15573   27704  56.2% -lh5- 90a7 Aug 26 03:06 ceb_fr_040
[unknown]                15569   27728  56.1% -lh5- 33f9 Aug 26 03:06 ceb_fr_060
[unknown]                15737   27980  56.2% -lh5- ff88 Aug 26 03:05 ceb_fr_ANY
---------- ----------- ------- ------- ------ ---------- ------------ ----------
 Total        10 files  138705  280421  49.5%            Aug 27 00:03

Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>