solved preoblem 23 with randoms