Euler

From ProgSoc Wiki

Jump to: navigation, search


Contents

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 (number of solutions)

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>

1

Caml (8 solutions)

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

Interactive mode with: ocaml

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

Haskell (51 solutions)

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

Interactive mode with: ghci or hugs

  •  :load <filename>
  •  :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

  • Load file: ['<filename>'].
  • Exit: halt.

Compile with: gplc <filename>

1, 19

Python (87 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, 87, 89, 91, 92, 95, 97, 99, 104, 112, 119, 124, 125, 145, 187, 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.

100

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>

1

Personal tools