All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Single Line Expression (Posted on 2008-01-27) Difficulty: 1 of 5
Give a single line "C type" expression to evaluate (-1)k using only +,-,* and % operators.

See The Solution Submitted by Praneeth    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Hints/Tips re: Whole numbers is reasonable assumption | Comment 4 of 6 |
(In reply to Whole numbers? by Erik O.)

I think Dej Mar's complaint would be valid, but it's clear that no such expression would exist for most values of k (the ones where the answer is imaginary).

Furthermore, even fractions such as 5/2 would get out of the range of a D1 question, so I think it's unlikely that a more complex answer was desired than what was previously given.

  Posted by Gamer on 2008-01-28 13:46:14

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information