Posts Tagged ‘source code’
Monday, August 23rd, 2010
Challenge:
Write the shortest source code by character count to determine if a number is part of the Fibonacci Sequence
Input:
The input should be a integer that comes from a command line argument or stdin. Don’t worry about handling big numbers, but do so if you can/want.
Output:
Output should print “Yes” if the number is in the Fibbonacci Sequence. If it is not in the Fibonacci Sequence then it should print “No”.
Example:
$ fib 2
Yes
$ fib 4
No
Definition
Fibonacci Number From Wikipedia,
By definition, the first two Fibonacci
numbers are 0 and 1, and each
subsequent number is the sum of the
previous two. Some sources omit the
initial 0, instead beginning the
sequence with two 1s.
For example
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...
Tags: 0 1 1 2 3 5 8 13, 1s, big numbers, character count, command line argument, fibbonacci sequence, fibonacci numbers, fibonacci sequence, sequence input, source code, wikipedia, worry
Posted in dotnet, vb, vb.net | No Comments »
Monday, August 23rd, 2010
It’s Sunday, time for a round of code golf!
Challenge
Write the shortest source code by character count to determine if an input number is a “happy prime”, “sad prime”, “happy non-prime”, or “sad non-prime.”
Input
The input should be a integer that comes from a command line argument or stdin. Don’t worry about handling big numbers, but do so if you can/want.
Output
Output should print the type of number: “happy prime”, “sad prime”, “happy non-prime”, or “sad non-prime.”
Examples
$ happyprime 139
happy prime
$ happyprime 2
sad prime
$ happyprime 440
happy non-prime
$ happyprime 78
sad non-prime
Definitions
Just in case your brain needs a refresher.
Happy Number
From Wikipedia,
A happy number is defined by the
following process. Starting with any
positive integer, replace the number
by the sum of the squares of its
digits, and repeat the process until
the number equals 1 (where it will
stay), or it loops endlessly in a
cycle which does not include 1. Those
numbers for which this process ends in
1 are happy numbers, while those that
do not end in 1 are unhappy numbers
(or sad numbers).
For example,
- 139
- 1^2 + 3^2 + 9^2 = 91
- 9^2 + 1^2 = 82
- 8^2 + 2^2 = 68
- 6^2 + 8^2 = 100
- 1^2 + 0^2 + 0^2 = 1
Prime Number
A prime number is has precisely two divisors: 1 and itself.
Happy Prime
A happy prime, is therefore a number that is both happy and prime.
Tags: big numbers, brain, character count, command line argument, definitions, digits, divisors, golf challenge, input number, positive integer, prime examples, prime number, primes, source code, squares, sunday time, wikipedia, worry
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
Hi
Quite simply, I have a SWF embedded in an HTML web page and want to move to a specific frame when a trigger is clicked.
But nothing happens when I click the trigger, as though the js just doesnt communicate at all with the swf.
SWF is written in flash cs4 (a3)
The link to the website is http://simplywebdzine.com/test.html.
I have read the text books over and over and researched high and wide on the internet and as far as I see I have done everything correctly but I cannot get this to work.
The swf is very basic, just a green box moving accross a small stage.
The desired gotoframe would make it cross at a lower height (just a dry run for a more complicated swf)
Would really appreciate someones help if you could possibly find out from the source code what is going wrong.
Many thanks
Steve
Tags: a3, html web, js, many thanks, source code, swf, test html, text books, web page
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
I am thinking about using CRC32 or SHA1, possibly both in C program I develop on Linux (Ubuntu).
Are there any easy to use libraries for either? Cutting and pasting a CRC32 algorithm into the source code of my program seems simple enough, but doing the same for SHA1 feels slightly shaky. Are there any easy to use libraries, preferably in Ubuntu but not necessarily?
I am using C, but C++ would be OK if I had to.
Tags: c program, crc32 algorithm, example images, hash data, libraries, Linux, sha1, source code, ubuntu
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
While browsing the source code of the scala API I met this package definition here :
package scala.util.parsing
package combinator
package syntactical
What does that mean ? That the class will be available in more than one package ?
Tags: api, parsing, scala, source code
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
Is there any one who knows how to install gcc3.x on Ubuntu 10.04? The original version is 4.4.3. I downloaded the gcc3.4.1 source code and compiled, but failed. Got the error ” error: call to ?__open_missing_mode? declared with attribute error: open with O_CREAT in second argument needs 3 arguments “. Is there some arguments I need to set specifically or is there any package to install on 10.04? Thank you!
Tags: attribute, error error, original version, source code
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
From the command line, the maven-gae-plugin can be run by calling:
mvn gae:run
I am working in a Maven project with a POM file that declares the use of the maven-gae-plugin.
I can run this maven command from the command-line in Windows. But, after setting up the source code as a project inside Eclipse, I don’t know how to run this command from inside the Eclipse IDE. Is this possible?
Tags: eclipse ide, maven, mvn, source code
Posted in dotnet, vb, vb.net | No Comments »
Saturday, August 21st, 2010
hi guys,
I wanted to ask you something which is bugging me for a while. I work an IT dept at a local bank and I got instructions to make an application which should retrieve some financial info from a financial banking stats page.
The webpage can be accessed through https://www.banksite.com/fininfo and the info can be seen in the web browser but I cannot extract them because the info is not available in the source code of the page.
It seems it's displaying the info using a jsquery.js file.
I was wondering if it's possible to make an app which uses some cache or something (I guess the the page is saved temporary somewhere on the disk for the current session) to retrieve that data in vb.net?
I would like to thank you in advance and I'll wait for your suggestions
Tags: financial info, fininfo, local bank, source code, web browser
Posted in dotnet, vb, vb.net | No Comments »
Saturday, August 21st, 2010
I’m trying to understand the ControlStyle property in Delphi 2007, but I’m having trouble grasping the csClickEvents and csCaptureMouse attributes.
According to specifications, csCaptureMouse makes the control capture mouse events when it is clicked, whereas csClickEvents enables the control to receive and answer to mouse clicks. It also mentions explicitly that TButton does not inherit this attribute (I’ve checked the source code: this is indeed the case).
What exactly do csCaptureMouse and csClickEvents do, and what is the difference? Thanks for any answer.
Tags: attribute, attributes, delphi, mouse events, source code
Posted in dotnet, vb, vb.net | No Comments »
Saturday, August 21st, 2010
I was wondering if someone can provide me with a tutorial or source code of a way to make it so if people are leeching my sites images and embedding them in their forums or sites it will show a watermark, but if they view it on my site their wont be a watermark?
Tags: leech, sites images, source code, watermark
Posted in dotnet, vb, vb.net | No Comments »