# include # include # include # include "bicycle_lock.h" int main ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: BICYCLE_LOCK_TEST tests BICYCLE_LOCK. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 August 2017 Author: John Burkardt */ { int c; int m = 3; int n = 10; int seed; int step; timestamp ( ); printf ( "\n" ); printf ( "BICYCLE_LOCK_TEST\n" ); printf ( " C version.\n" ); printf ( " A bicycle combination lock consists of 3 dials,\n" ); printf ( " each having 10 symbols, 0 through 9.\n" ); printf ( " We seek to determine the combination C.\n" ); /* Report on the problem data. */ printf ( "\n" ); printf ( " The number of dials is M = %d\n", m ); printf ( " The number of symbols is N = %d\n", n ); printf ( " The number of possible combinations is M^N = %d\n", i4_power ( n, m ) ); /* Choose a combination. */ seed = get_seed ( ); c = i4_uniform_ab ( 0, 999, &seed ); printf ( " The \"secret\" combination is %d\n", c ); /* Try to determine the combination. */ step = bicycle_lock ( c ); if ( step == -1 ) { printf ( "\n" ); printf ( " The combination was not found!\n" ); } else { printf ( "\n" ); printf ( " The combination was found on step %d\n", step ); } /* Terminate. */ printf ( "\n" ); printf ( "BICYCLE_LOCK_TEST\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; }