C Puzzles

yet another place for C puzzles

Monday, February 19, 2007

 

curly bracket matching

Not a puzzle exactly.

Q. Are you familiar with curly bracket matching in vi editor?
(FYI: you may use % to find matching curly brackets)

implement this feature in 'your own' editor.

[you may even give a single-WORD-answer :-]

To simplify the question...
imagine a text with curly brackets like the following
"{{}{{}{}}{}}"

Input/output:
2nd curly matches with 3rd
1st curly with last one
4th with 9th

Now start writing the program.

Friday, February 16, 2007

 

a minor memory issue

Q. we have identified a problem in our hardware memory.


|<--------------32-bit---------->|

+--------------------------------+
| A |
+--------------------------------+
| B |
+--------------------------------+
| C |
+--------------------------------+
| D |
+--------------------------------+
| E |
+--------------------------------+
| F |
+--------------------------------+

Whenever we give instruction to write something to A it writes to B. and vice versa.

it occurs in a similar pattern for rest of the memory. like C to D, D to C, E to F, F to E, and so on.

write a workaround(in a single line).

Archives

July 2005   August 2005   October 2005   December 2005   March 2006   June 2006   July 2006   December 2006   February 2007   June 2007   March 2010   May 2010  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]