# Euler

(Difference between revisions)
 Revision as of 07:31, 18 November 2010 (view source)Ctd (Talk | contribs) (→By Problem)← Older edit Revision as of 04:47, 8 March 2011 (view source)Althalus (Talk | contribs) m (→By Problem)Newer edit → Line 121: Line 121: * [[Euler Solution 102 | Problem 102]] (1) * [[Euler Solution 102 | Problem 102]] (1) * [[Euler Solution 103 | Problem 103]] (1) * [[Euler Solution 103 | Problem 103]] (1) + * [[Euler Solution 104 | Problem 104]] (1) * [[Euler Solution 105 | Problem 105]] (1) * [[Euler Solution 105 | Problem 105]] (1) * [[Euler Solution 108 | Problem 108]] (1) * [[Euler Solution 108 | Problem 108]] (1)

# What is ProgSoc Euler

ProgSoc Euler is a collaborative approach to solving the Project Euler problems for ProgSoc members. Any ProgSoc member can log into the ProgSoc account and try to (re-)solve any of the problems. Solutions to problems can be posted to the links further down this page (just add a new page for any problem you are the first to solve!).

The goal is for ProgSoc members to share their brilliant solutions with other members, as well as discover new ways to solve problems.

# The rules

Your solution can be written in any language, however it must run on a ProgSoc server (default is Niflheim via ssh.progsoc.org, if you use another machine then note which). If you solve a problem, post the code and runtime on the solutions page for that problem. You are free to modify/improve the code of other members or port them to other languages.

# How do I enter/compete?

The login details can be found at "/home/progsoc-users/sanguinev/euler.txt" from Niflheim. You can find the problems here. Solutions can be posted below.

# Solutions

Below can be found the solutions to the ProgSoc/Project Euler problems. The first section contains solutions by problem number, the second by programming language. Note that problems may be solved in multiple languages and/or by multiple members, with all solutions posted for contrasting approaches.

## By Problem

Links to pages with a brief description of each problem and the solutions created by ProgSoc members. Comments/insights may also be posted.

 Problem 1 (15) Problem 2 (6) Problem 3 (3) Problem 4 (4) Problem 5 (5) Problem 6 (6) Problem 7 (3) Problem 8 (3) Problem 9 (4) Problem 10 (3) Problem 11 (3) Problem 12 (2) Problem 13 (2) Problem 14 (2) Problem 15 (2) Problem 16 (2) Problem 17 (2) Problem 18 (2) Problem 19 (3) Problem 20 (3) Problem 21 (2) Problem 22 (2) Problem 23 (1) Problem 24 (1) Problem 25 (2) Problem 26 (2) Problem 27 (1) Problem 28 (2) Problem 29 (2) Problem 30 (1) Problem 31 (1) Problem 32 (1) Problem 33 (1) Problem 34 (1) Problem 35 (1) Problem 36 (2) Problem 37 (1) Problem 38 (2) Problem 39 (1) Problem 40 (2) Problem 41 (1) Problem 42 (1) Problem 43 (1) Problem 44 (1) Problem 45 (1) Problem 46 (2) Problem 47 (1) Problem 48 (2) Problem 49 (2) Problem 50 (1) Problem 51 (3) Problem 52 (1) Problem 53 (1) Problem 54 (1) Problem 55 (3) Problem 56 (1) Problem 57 (1) Problem 58 (1) Problem 59 (2) Problem 60 (1) Problem 61 (1) Problem 62 (1) Problem 63 (2) Problem 64 (1) Problem 65 (1) Problem 66 (1) Problem 67 (1) Problem 68 (2) Problem 69 (2) Problem 70 (1) Problem 71 (1) Problem 72 (1) Problem 73 (1) Problem 74 (3) Problem 75 (1) Problem 76 (1) Problem 78 (1) Problem 79 (1) Problem 80 (1) Problem 81 (1) Problem 82 (2) Problem 85 (1) Problem 87 (1) Problem 89 (1) Problem 91 (1) Problem 92 (3) Problem 95 (1) Problem 97 (2) Problem 99 (3) Problem 100 (1) Problem 102 (1) Problem 103 (1) Problem 104 (1) Problem 105 (1) Problem 108 (1) Problem 112 (1) Problem 119 (1) Problem 120 (1) Problem 121 (1) Problem 124 (1) Problem 125 (1) Problem 128 (1) Problem 145 (2) Problem 146 (1) Problem 187 (1) Problem 197 (1) Problem 205 (1) Problem 206 (1) Problem 216 (1) Problem 234 (1) Problem 243 (1)

## By Language

Languages used to solve the problems, each including a list of the numbers corresponding to the problems that have been solved by that language.

Each language also includes a (very brief) description of how to compile/run code for that language on Niflheim.

### C (10 solutions)

Compile with: gcc -o <output filename> <input filename>

1 , 6 , 14, 36, 45, 59, 74, 81, 82, 145

### C++ (5 solutions)

Compile with: g++ -o <output filename> <input filename>

1, 2, 5, 7, 10

### C# (1 solution)

We've finally gotten around to installing Mono on niflheim!

Compile with: gmcs <input filename>

Execute with: mono <output filename>

### Caml (8 solutions)

Compile with: ocamlc -o <output filename> <input filename>

Interactive mode with: ocaml

1, 2, 4, 6, 8, 9, 51, 92

Compile with: ghc -o <output filename> <input filename>

Interactive mode with: ghci or hugs

•  :quit

1, 2, 3, 4, 5, 6, 7, 10, 12, 21, 22, 25, 26, 28, 29, 35, 37, 40, 41, 43, 44, 49, 52, 53, 55, 56, 63, 68, 69, 70, 71, 73, 74, 85, 87, 99, 103, 105, 108, 119, 120, 121, 125, 128, 145, 146, 187, 197, 206, 234, 243

### Java (4 solutions)

Come on, script kiddies first-year BScIT students...

Compile with: javac-sablevm <ClassName>.java (do not use javac on niflheim - it'll only give you grief)

Execute with: java <ClassName>

1, 11, 26, 92

### Lisp/Scheme (12 solutions)

Interactive mode with: mzscheme

Script mode with: mzscheme -f <filename>

11, 13, 15, 16, 18, 20, 34, 48, 57, 67, 97, 205

### Pen and Paper (3 solutions)

Using a pen and paper, or alternatively a whiteboard marker and the whiteboard to do it in the ProgSoc room.

38, 68, 79

### Perl (2 solutions)

Script mode with: perl <filename>

1, 5

### Prolog (2 solutions)

Interactive mode with: prolog

• Exit: halt.

Compile with: gplc <filename>

1, 19

### Python (82 solutions)

Interactive mode with: python

Script mode with: python <filename>

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 42, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 66, 69, 70, 73, 74, 75, 76, 78, 80, 81, 82, 85, 89, 91, 92, 95, 97, 99, 112, 124, 145, 205, 206

### Ruby (17 solutions)

Script mode with: ruby <filename>

1, 2, 4, 6, 8, 9, 17, 19, 33, 36, 39, 42, 46, 51, 55, 63, 99

### SQL (3 solutions)

Interactive mode with: mysql -h muspell -u <username> -p

1, 2

### wolframalpha (1 solution)

Get results with:

Note that both of these still require some effort to access the actual solution.

### VBA (4 solutions)

I guess you could install Office in Linux using Wine or Office for Mac in Mac OS on the Mac minis, then find the answer.

Alternatively, you could try it out as an OpenOffice macro (i.e. treat it as OpenOffice Basic). It might work, although YMMV.

5*, 6*, 9*, 20*

(* - runs in OpenOffice)

### XSLT (1 solution)

Transform with: xsltproc <xslt filename> <xml filename>