Tagged in

code

Codewars - Land Perimeter

The Land-Perimeter challenge from Codewars is slightly different from the others I've mentioned; it effectively needs you to produce results from a list of lists, where the relationship between a given item and its peers is important. I tried this one in Haskell first, since the approach in that language …

Codewars - Odd Integer

"Find the integer that appears an odd number of times in this list," says Codewars. "Sure," I say, "this ought to be fun."

Again, playing with Haskell and how I fare with it compared to Python.

Is it really a spoiler?

Python

def find_it(seq):
  """Given a sequence of integers …

Codewars - Sierpinski's Gasket

The Codewars Sierpinski's Gasket challenge asks us to draw Sierpinski's triangle using the letter "L" and spaces. Per usual I'm trying it in both Python and Haskell; this time I solved it in Python first.

Hea come da spoilers.

Python

def sierpinski(x):
  """Produce a 'triangle' of Ls, recursively x …

Codewars - Tongues

Per previous notes, I'm playing with Haskell. In particular, how does learning Haskell feel as someone who is reasonably comfortable with Python and a few similar languages?

For this round I worked through the "Tongues" challenge. The goal is to replace the characters in a string with other characters, according …

Codewars - Parentheses

The Codewars Valid Parentheses challenge is to evaluate a string containing parentheses, returning true if they are properly balanced and false if they aren't. Nice fit to feel how beginner level Haskell compares to intermediate Python.

Here there be spoilers.

Haskell

My solution was simple: iterate over every characater in …

Counting youth held in Philadelphia adult jails

"As of 2017-03-26, there are 36 youth in Philadelphia adult jails." yasp.pablovirgo.com

A friend of mine is working to keep kids and teenagers out of adult jails. The prison system shares a census periodically, but the data isn't meant to be easy to work with.

A recent webinar …

Minetest Cereal, coming unglued

Annoying that I couldn't make it work with Racket. I took another EDx course on computer programming: MITx 6.00.1x. So that's going to get added to my LinkedIN profile soonish.

Parsing the Minetest World format was trickier than I guessed. Nevertheless, I cracked the section I was previously …

Minetest Cereal, Python Restart

I've been writing my Minetest Cereal project using Racket. That worked great for:

  • Duplicating mathematical algorithms
  • Creating a command line interface
  • Connecting to an sqlite3 database
  • Reading individual bytes from a stream
  • Writing proper unit tests
  • Learning about functional programming

Unfortunately, the Minetest world format compresses some of its data …

Minetest Cereal, Week 5: So close, and yet ...

There was no specific update for week 4.

Working with a singlenode (all air) map, I treated the data blob as an input stream, pulling out data 8, 16, or 32 bits based on the documentation. Here's what I've been able to gather:

  • map-version: 25
  • flags: 1 (appears that per-bit …

Minetest Cereal, Week 3: Inverted World

Blocks aren't nodes

Invented World

The tools to convert back and forth between the Minetest world format and my Minetest Cereal format are past the first hurdle. They can convert to and from a database that uses x,y,z coordinates for block positions and back.

On a lark, I converted my …