Skip to content

Instantly share code, notes, and snippets.

@thomaschandler
Last active October 27, 2016 20:28
Show Gist options
  • Select an option

  • Save thomaschandler/b7daccbd8d64982cb8a25c7c3feaf6ac to your computer and use it in GitHub Desktop.

Select an option

Save thomaschandler/b7daccbd8d64982cb8a25c7c3feaf6ac to your computer and use it in GitHub Desktop.

Revisions

  1. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 24 additions and 24 deletions.
    48 changes: 24 additions & 24 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -13,42 +13,42 @@ For the bar, you develop a "ticket validation system" that can be used with the

    1. Ticket_counter = 10. No other tickets have been received.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|0|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|0|1|

    2. Ticket 9 presented. It is accepted, and the field is marked.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|

    3. Ticket 9 presented again, but it is rejected.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|

    4. Ticket 3 presented, it is accepted.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|0|0|1|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|0|0|1|1|

    5. Ticket 7 presented, it is accepted.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|1|0|1|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|1|0|1|1|

    6. Ticket 11 is accepted. The bit field is shifted, and ticket 11 is marked as received.

    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|4|5|6|7|8|9|10|11|
    |Used?|0|0|0|1|0|1|1|1|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|4|5|6|7|8|9|10|11|
    |Used?|0|0|0|1|0|1|1|1|
  2. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,10 @@ For the bar, you develop a "ticket validation system" that can be used with the
    1. A ticket with the same number cannot be used twice

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)

    ------


    1. Ticket_counter = 10. No other tickets have been received.

    |Bit|7|6|5|4|3|2|1|0|
  3. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ For the bar, you develop a "ticket validation system" that can be used with the
    1. A ticket with the same number cannot be used twice

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)
    ======
    ------
    1. Ticket_counter = 10. No other tickets have been received.

    |Bit|7|6|5|4|3|2|1|0|
  4. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,7 @@ For the bar, you develop a "ticket validation system" that can be used with the
    1. A ticket with the same number cannot be used twice

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)


    ======
    1. Ticket_counter = 10. No other tickets have been received.

    |Bit|7|6|5|4|3|2|1|0|
  5. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ For the bar, you develop a "ticket validation system" that can be used with the

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)


    1. Ticket_counter = 10. No other tickets have been received.

    |Bit|7|6|5|4|3|2|1|0|
  6. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 13 additions and 7 deletions.
    20 changes: 13 additions & 7 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,44 +2,50 @@ You are a developer and you are getting calls from a bar looking for help. Each

    The bar staff have been complaining about the difficulty of keeping track of all the tickets during a night, so you have been asked to come up with a solution.

    For the bar, you develop a "ticket validation window" that can be used with the terminals located at the bar in order to prevent guests from re-using tickets. This ticket validation window ensures the following:
    For the bar, you develop a "ticket validation system" that can be used with the terminals located at the bar in order to prevent guests from re-using tickets. This ticket validation window ensures the following:

    1. A ticket with the same number cannot be used twice

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)

    1. Ticket_counter = 10. No other tickets have been received.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|0|1|

    2. Ticket 9 presented. It is accepted, and the field is marked.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|

    3. Ticket 9 presented again, but it is rejected.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|0|0|0|0|0|0|1|1|

    4. Ticket 3 presented, it is accepted.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|0|0|1|1|

    5. Ticket 7 presented, it is accepted.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|3|4|5|6|7|8|9|10|
    |Used?|1|0|0|0|1|0|1|1|

    6. Ticket 11 is accepted. The bit field is shifted, and ticket 11 is marked as received.

    |Ticket Number|4|5|6|7|8|9|10|11|
    |Bit|7|6|5|4|3|2|1|0|
    |---|---|---|---|---|---|---|---|---|
    |Ticket Number|4|5|6|7|8|9|10|11|
    |Used?|0|0|0|1|0|1|1|1|
  7. thomaschandler revised this gist Oct 27, 2016. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,13 @@
    You are a developer and you are getting calls from a bar looking for help. Each night, the bar charges a cover, and in exchange guests are given a series of numbered drink tickets that can be used to exchange for drinks.

    The bar staff have been complaining about the difficulty of keeping track of all the tickets during a night, so you have been asked to come up with a solution.

    For the bar, you develop a "ticket validation window" that can be used with the terminals located at the bar in order to prevent guests from re-using tickets. This ticket validation window ensures the following:

    1. A ticket with the same number cannot be used twice

    2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)

    1. Ticket_counter = 10. No other tickets have been received.

    |Ticket Number|3|4|5|6|7|8|9|10|
  8. thomaschandler renamed this gist Oct 27, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. thomaschandler created this gist Oct 27, 2016.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    1. Ticket_counter = 10. No other tickets have been received.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |---|---|---|---|---|---|---|---|---|
    |Used?|0|0|0|0|0|0|0|1|

    2. Ticket 9 presented. It is accepted, and the field is marked.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |---|---|---|---|---|---|---|---|---|
    |Used?|0|0|0|0|0|0|1|1|

    3. Ticket 9 presented again, but it is rejected.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |---|---|---|---|---|---|---|---|---|
    |Used?|0|0|0|0|0|0|1|1|

    4. Ticket 3 presented, it is accepted.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |---|---|---|---|---|---|---|---|---|
    |Used?|1|0|0|0|0|0|1|1|

    5. Ticket 7 presented, it is accepted.

    |Ticket Number|3|4|5|6|7|8|9|10|
    |---|---|---|---|---|---|---|---|---|
    |Used?|1|0|0|0|1|0|1|1|

    6. Ticket 11 is accepted. The bit field is shifted, and ticket 11 is marked as received.

    |Ticket Number|4|5|6|7|8|9|10|11|
    |---|---|---|---|---|---|---|---|---|
    |Used?|0|0|0|1|0|1|1|1|