Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
319 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 ...
Sandio's user avatar
  • 119
0 votes
1 answer
274 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 ...
Sandio's user avatar
  • 119
6 votes
2 answers
323 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 ...
Sandio's user avatar
  • 119
2 votes
3 answers
421 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 ...
vikrant's user avatar
  • 405
1 vote
1 answer
309 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 ...
Stud's user avatar
  • 786
4 votes
1 answer
212 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 ...
Stud's user avatar
  • 786
2 votes
1 answer
168 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 ...
Stud's user avatar
  • 786
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 ...
Joshua Dawson's user avatar
1 vote
4 answers
204 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 ...
Chase G.'s user avatar
2 votes
1 answer
100 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 ...
Chase G.'s user avatar
10 votes
1 answer
611 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 ...
Brian McCutchon's user avatar
3 votes
1 answer
114 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 ...
bsa's user avatar
  • 793
1 vote
1 answer
277 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 ...
Dmitry Zinkevich's user avatar
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 ...
CodeYogi's user avatar
  • 5,205
2 votes
1 answer
1k views

Anagram in Scala

Code ...
CodeYogi's user avatar
  • 5,205

15 30 50 per page