KnowledgeZen Technology Consulting http://knowledgezen.appspot.com

knowledgezenforyou@gmail.com Assorted posts about Software design, development and debugging, algorithms and data structures, programming languages(C,C++,Python,Matlab,Javascript,...), programming puzzles,brain teasers and other technical stuff we find interesting.

Wednesday, 17 July 2013

My solution to the puzzle posted here few days back is below.

Implement a function h(n) as below:

h(h(n)) = -n

 static int run = 0  
 int f(n)  
 {  
 run++;  
 return (pow(-1,(run-1))*n);  
 }   
Posted by Unknown at 21:51
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2015 (2)
    • ►  June (2)
  • ►  2014 (7)
    • ►  December (1)
    • ►  November (3)
    • ►  September (1)
    • ►  March (1)
    • ►  January (1)
  • ▼  2013 (22)
    • ►  November (1)
    • ►  October (1)
    • ►  September (6)
    • ►  August (8)
    • ▼  July (6)
      • Solution to the puzzle Towering personalities
      • Towering personalities... A Puzzle.
      • My solution to the puzzle posted here few days bac...
      • Python functions - Default values as function argu...
      •                         function(function(n))=......
      •                                       C++ Copy co...

knowledgezenforyou@gmail.com

Unknown
View my complete profile

Popular Posts

  • Commands for various tools to do Static Code analysis of C C++ source
    Static code analysis is a very important step that every software developer, organisation should carry out to check if the code has any subt...
  • Using GDB,top and other tools to debug a process that has hanged and is hogging 99.9%CPU
    A process which crashes leaves a back-trace so on getting that we at least know the symptom of the crash but a process which is hogging CPU...
  • Programming Puzzle to solve
    Here is a good programming puzzle I solved over the weekend just to "sharpen my code axe" --------------------------------------...
  • Memory leaks, errors... plug that
    Memory leak is the phenomenon when a dynamically allocated memory using malloc or new operator(C++) is not freed and returned to the languag...
  • All permutations of numbers in Python
    Just recently, I was looking to fill an excel sheet with all possible permutations of five numbers : 1,2,3,4,5 . One permutation in each cel...
  • Multipath TCP connections
    Just recently , read about an interesting technology in network programming which is implemented for the first time in a commercial setting,...
  • C++ Class destructor throwing an exception ... No No
    In C++ exception handling is feature provided by the C++ run-time environment to handle errors in execution of functions. Exceptions are he...
  • Python Challenge - Caesar cipher with shift
    Here is a programming puzzle picked from Python challenge from  early levels , relatively easy but very good exercise for someone who is a p...
  • (no title)
    Here is an interesting puzzle (graph colouring problem!): In figure below, it shows 5 circular nodes connected by lines. Assuming you have...
  • Solution to the python challenge Caesar crypt puzzle
    Here is my solution to the Python Challenge Caesar crypt with shift. Very simple but teaches a python beginner a lot of its concepts about p...

Search This Blog

Copyright (c) 2013 http://knowledgezen.appspot.com. Awesome Inc. theme. Powered by Blogger.