Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Locate missing number in a series

by Old_Gray_Bear (Bishop)
on Apr 21, 2016 at 23:32 UTC ( #1161160=note: print w/replies, xml ) Need Help??

in reply to Locate missing number in a series

You are looking for the disjunction between the set of all lockers and the set of rented lockers. So, in pseudo code is one way:

  • I have an array of lockers, 1 .. 24, initialized to zeroes
  • I have a database containing information
  • Loop: Read a Record from the DB
  • If the locker-id is present, set the value in my locker-array to 1.
  • Go to Loop: until you exhaust the DB.
  • scan the locker-array, if the value of the i-th element is 0, print the index (i).
  • Turn the result into your Teacher, you have completed the assignment in a FORTRANly fashion.

I Go Back to Sleep, Now.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1161160]
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: Oooh - finally, I can say no lazy; :)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2018-07-17 08:10 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (358 votes). Check out past polls.