All Questions
Tagged with scala programming-challenge
25 questions
1
vote
1
answer
310
views
Provide functional-programming style solution for 2D Array - DS challenge
Problem Statement:
Given a 6×6 2D Array, arr:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
We define an hourglass in A to be a subset of ...
0
votes
1
answer
270
views
Imperative and functional-programming solutions for Jumping on the Cloud challenge
Problem Statement
Emma is playing a new mobile game that starts with consecutively
numbered clouds. Some of the clouds are thunderheads and others are
cumulus. She can jump on any cumulus cloud ...
5
votes
2
answers
308
views
Counting valleys traversed below sea level, given elevation changes
Problem Statement:
Gary is an avid hiker. He tracks his hikes meticulously, paying close
attention to small details like topography. During his last hike he
took exactly steps. For every step he ...
2
votes
3
answers
408
views
List of Happy Numbers in scala
Definition of Happy numbers taken 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 ...
1
vote
1
answer
301
views
Binary search in Scala
Another exercise in Scala in which the goal is to find the target position as fast as possible. The initial input provides the grid size and the initial position. Each turn, this code provide a new ...
4
votes
1
answer
204
views
Find an ideal speed to cross all traffic lights when they are green
As a second exercise with Scala I tried to solve another puzzle.
In this puzzle, we have to find the highest speed that allows a driver to cross all the traffic lights when they are green, without ...
2
votes
1
answer
162
views
Finding the nearest defibrillator exercise from CodingGames
For my first attempt at Scala I decided to solve a simple exercise on codingame.com.
Based on a string input containing the user location, the defibrillators count and a list of defibrillators ...
2
votes
1
answer
1k
views
Solution to a simple Hackerrank problem: Compare the Triplets
Given two equally sized arrays of integers A and B, compute the number of times ...
1
vote
4
answers
187
views
Project Euler problem 92 in Scala, square digit chains
Here is a summary of the problem:
"A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before... How many starting ...
2
votes
1
answer
95
views
Project Euler 23 in Scala (non-abundant sums)
I recently overhauled my solution to Project Euler Problem 23 (which asks for the sum of all positive integers which cannot be written as the sum of two abundant numbers) to move it from an imperative ...
9
votes
1
answer
604
views
Kattis problem Amanda Lounges
I wrote this solution to Kattis problem Amanda Lounges in Scala.
The code is written to solve a graph theory problem where it will read in a list of edges from stdin and try to compute the minimum ...
3
votes
1
answer
105
views
Project Euler #12 in Scala — Highly divisible triangular numbers
I generally work in Python for programming competitions, but I'm teaching myself Scala. As an exercise, I've attempted Project Euler problem #12 in Scala. I hope that somebody familiar with Scala can ...
1
vote
1
answer
276
views
Triangle numbers finder in Scala
I'm new to Scala and learn it by solving some Project Euler problems. Here is the solution to problem 42 from Project Euler.
The task is to read words from file, then sum ordinal numbers of each ...
2
votes
1
answer
1k
views
Hamming distance in Scala
Problem
Write a program that can calculate the Hamming difference between two DNA strands.
GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT
^ ^ ^ ^ ^ ^^
Code
...
2
votes
1
answer
990
views
Anagram in Scala
Code
...