Programming-cum-logic challenge

Need help troubleshooting your PC? We have a couple of geeks in the forum who can help you
Forum rules
Please read the forum rules carefully before you post.

If you like AnimorphsFanForum.com, please consider making a donation. Any donation will go towards the cost of the hosting, the domain and any other running costs.
User avatar
AneeshTheGreat
Donator
Donator
Posts: 1947
Joined: Sat Apr 11, 2009 9:01 am
Gender: [Male][/Male]
Favourite Animorph: Marco
Location: not Mumbai, India :(

Re: Programming-cum-logic challenge

Post by AneeshTheGreat » Fri Sep 24, 2010 6:47 am

Pretty much like mine except it's counting up. It's written in C!
There are 10 types of people in this world. Those who understand Binary, and those who don't. Now 1/4th a Computer Scientist (or Computer Science Engineer, depending on my mood), i can safely say i fall into the first category.

User avatar
Ellimist
Administrator
Administrator
Posts: 4949
Joined: Thu Nov 22, 2007 4:48 am
Gender: [Male][/Male]
Favourite Animorph: Jake

Re: Programming-cum-logic challenge

Post by Ellimist » Fri Sep 24, 2010 6:52 am

AneeshTheGreat wrote:Pretty much like mine except it's counting up.
Yup.
AneeshTheGreat wrote:It's written in C!
Yeah. I wanted to see if you'd recognise. You don't have it till 2nd semester.
Powered by chocolate and Dvorak

User avatar
AneeshTheGreat
Donator
Donator
Posts: 1947
Joined: Sat Apr 11, 2009 9:01 am
Gender: [Male][/Male]
Favourite Animorph: Marco
Location: not Mumbai, India :(

Re: Programming-cum-logic challenge

Post by AneeshTheGreat » Fri Sep 24, 2010 7:01 am

Ellimist wrote: Yeah. I wanted to see if you'd recognise. You don't have it till 2nd semester.
No, YOU probably didn't have it till the second semester. At my university ( and many others, actually) C is taught right in the first sem, while C++ is taught in the 2nd. Java in the 3rd for CSE and IT students.

And i actually would have been unable to recognize it a few months ago. printf i hear is a function in java as well. The only thing that really stood out was the "%d".

When i first heard about the format specifiers, i was furious! Now, they're turning out to be pretty useful for a "middle level" language.
There are 10 types of people in this world. Those who understand Binary, and those who don't. Now 1/4th a Computer Scientist (or Computer Science Engineer, depending on my mood), i can safely say i fall into the first category.

User avatar
capnnerefir
Administrator
Administrator
Posts: 6981
Joined: Fri May 30, 2008 8:40 am
Gender: [Male][/Male]
Favourite Animorph: Tobias
Location: The rabbit hole. That thing goes deep, man.

Re: Programming-cum-logic challenge

Post by capnnerefir » Fri Sep 24, 2010 2:21 pm

AneeshTheGreat wrote:printf i hear is a function in java as well. The only thing that really stood out was the "%d".

When i first heard about the format specifiers, i was furious! Now, they're turning out to be pretty useful for a "middle level" language.
Man, I should stay away from this forum. That made literally NO sense to me. ;)

User avatar
Current
Eldritch Abomination
Eldritch Abomination
Posts: 1780
Joined: Sat Jul 25, 2009 10:20 pm
Favourite Animorph: Rachel
Location: Southwestern quartersphere

Re: Programming-cum-logic challenge

Post by Current » Fri Sep 24, 2010 7:17 pm

AneeshTheGreat wrote:Actually, same problem, square roots require library functions.
Huh. Then I guess the idea of using factorials isn't going to work...
(In case you're curious, it's
Spoiler:
if a! modulo b! = 0 then a is greater than b, otherwise b is greater. High probability of huge numbers. Terribly impractical, but the idea that some method involving factorials had to exist has been bugging me for a while so I just had to materialise it.
)


@Ellimist: I have no idea how to read that. Though if it's counting up, I gather it's somewhere along the lines of "increase each number by one until one number reaches the other"?

Edit: And just after posting, I realise I was once again overcomplicating.
Spoiler:
Why bother with factorials when you can just use a modulo b, the result should be a if and only if b is greater than a, unless I'm making a mistake somewhere. Of course, this relies on modulo being available. I could reformulate it as [a/b - (a/b rounded down)] times b, which results in a roundabout equivalent of the second method in the original post.
OK, enough mathematics for today, I need food.
What is not the answer to this question?

User avatar
AneeshTheGreat
Donator
Donator
Posts: 1947
Joined: Sat Apr 11, 2009 9:01 am
Gender: [Male][/Male]
Favourite Animorph: Marco
Location: not Mumbai, India :(

Re: Programming-cum-logic challenge

Post by AneeshTheGreat » Fri Sep 24, 2010 10:23 pm

Current wrote: Edit: And just after posting, I realise I was once again overcomplicating. Why bother with factorials when you can just use a modulo b, the result should be a if and only if b is greater than a, unless I'm making a mistake somewhere.
That works. Again, only for positives.
Current wrote:@Ellimist: I have no idea how to read that. Though if it's counting up, I gather it's somewhere along the lines of "increase each number by one until one number reaches the other"?
Nope. Actually we're counting up from 0 till one of the numbers is reached, that's the smaller one. If you go to increase each number by 1, neither would EVER reach the other.
capnnerefir wrote:Man, I should stay away from this forum. That made literally NO sense to me. ;)
:D
There are 10 types of people in this world. Those who understand Binary, and those who don't. Now 1/4th a Computer Scientist (or Computer Science Engineer, depending on my mood), i can safely say i fall into the first category.

User avatar
Ellimist
Administrator
Administrator
Posts: 4949
Joined: Thu Nov 22, 2007 4:48 am
Gender: [Male][/Male]
Favourite Animorph: Jake

Re: Programming-cum-logic challenge

Post by Ellimist » Fri Sep 24, 2010 11:15 pm

AneeshTheGreat wrote: No, YOU probably didn't have it till the second semester. At my university ( and many others, actually) C is taught right in the first sem, while C++ is taught in the 2nd. Java in the 3rd for CSE and IT students.
You are lucky. We are still learning data structures using C, and the syllabus is so outdated, it seems like it's from the stone age.
AneeshTheGreat wrote:And i actually would have been unable to recognize it a few months ago. printf i hear is a function in java as well. The only thing that really stood out was the "%d".
Printf or formatted printing is also available in PHP.
AneeshTheGreat wrote:When i first heard about the format specifiers, i was furious! Now, they're turning out to be pretty useful for a "middle level" language.
I still like concatenated printing techniques, like those used in Java's System.out.print() or PHP's echo. It's much less complicated and you don't have to remember which format specifier stands for which data type.
Current wrote:@Ellimist: I have no idea how to read that. Though if it's counting up, I gather it's somewhere along the lines of "increase each number by one until one number reaches the other"?
I'm counting up from zero till I reach one of the numbers, which is the smaller of the two.
Don't worry, Current. Programming is just formatting the solution using the syntax of the programming language. You can learn the syntax in what, 3 hours? Or even less. What you actually need is the ideas, and the solutions which, needless to say, you have in plenty.
AneeshTheGreat wrote:
capnnerefir wrote:Man, I should stay away from this forum. That made literally NO sense to me. ;)
:D
We are lucky he doesn't try to understand code. If he did, we'd have been out of our jobs. ;)
Powered by chocolate and Dvorak

User avatar
Current
Eldritch Abomination
Eldritch Abomination
Posts: 1780
Joined: Sat Jul 25, 2009 10:20 pm
Favourite Animorph: Rachel
Location: Southwestern quartersphere

Re: Programming-cum-logic challenge

Post by Current » Sun Sep 26, 2010 12:08 am

AneeshTheGreat wrote:Nope. Actually we're counting up from 0 till one of the numbers is reached, that's the smaller one. If you go to increase each number by 1, neither would EVER reach the other.
The original value, silly, not the value after increasing.
What is not the answer to this question?