Skip to main content

All Questions

Tagged with
3 votes
2 answers
401 views

Count character 'a' in first n characters of indefinitely repeating string s

Problem statement: Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n ...
Sandio's user avatar
  • 109
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 ...
Sandio's user avatar
  • 109
2 votes
1 answer
438 views

Functional API wrapper written in Scala

I've been working on an small API wrapper for the GitHub API using Scala (full source on GitHub). I'm still very new to the language, so I was hoping to get some feedback about a couple of design ...
MattDs17's user avatar
  • 225
2 votes
2 answers
614 views

A Scala Maze Generator in Functional Style

I'm wondering if there is more I can do to incorporate more idiomatic scala and functional programming principles. I know the maze itself is mutable but i didn't see an easy solution to making it ...
j will's user avatar
  • 155
2 votes
1 answer
100 views

Building and querying an immutable phone book

I wanted to get your opinion on this immutable implementation of a Phone Book using recursion to process a stream. I am especially interested in ways to speed up the code execution. Here is an ...
Guillaume's user avatar
  • 123
5 votes
3 answers
128 views

Generating a game board with squares in a rectangle

I am trying to generate a game board (similar to a Monopoly board). I am new to Scala and am thinking that there may be a better way to do this. But improvements to the code are also welcome. ...
Can't Tell's user avatar
3 votes
1 answer
191 views

Functional SaveObject in Scala

I came across Java like Scala code that I am trying to refactor to make it functional and immutable. The first obvious flaw is that it's violating thread safety by using mutable public class level ...
user2066049's user avatar