Practice Go. Build Word @ Alex Pliutau's Blog
Seems like previous exercise is a quite difficult to implement :) Here is a new one.
Build Word
You have a word
in lowercase. Your task is to write this word using the fragments
you are given. Each element of fragments can be used more than once, but they cannot overlap. It is guaranteed that it’s always possible to write the word using the given fragments.
What is the minimum number of elements you have to use? Return 0 if it’s not possible to build a word.
Example
// bu + ild + wo + rd
BuildWord("buildword", []string{"buil", "dwor", "bu", "ild", "wo", "rd"}) = 4
Run tests with benchmarks
go test -bench .
相關推薦
Practice Go. Build Word @ Alex Pliutau's Blog
Seems like previous exercise is a quite difficult to implement :) Here is a new one. Build Word You have a word in lowercase. Your task is t
Practice Go: Secret Message @ Alex Pliutau's Blog
I just created a new challenge in Practice Go collection, happy to review all possible solutions and choose the best one. Secret Message Cre
Practice Go: Mosaic Photo @ Alex Pliutau's Blog
Your mission is to write a mosaic-photo generating command line program that: Allows the user to select a target picture. Allows the user
Practice Go: Roman Numerals @ Alex Pliutau's Blog
Create 2 functions: Encode(n int) (string, bool) - takes an integer as its parameter and returns a string containing the Roman numeral rep
Practice Go: Web Scraping @ Alex Pliutau's Blog
Web Scraping Create a function that finds the time from this http://tycho.usno.navy.mil/cgi-bin/timer.pl and then prints it by extracting t
Practice Go: Missing Numbers @ Alex Pliutau's Blog
Given an array containing all the numbers from 1 to n except two, find the two missing numbers. Example missing([]int{4, 2, 3}) = []int{1
Practice Go: Function Frequency @ Alex Pliutau's Blog
Function Frequency Given a valid Go code in gocode.txt file find top-3 used functions. Don’t count function declaration. This is a static a
Practice Go: Print Spiral @ Alex Pliutau's Blog
Write a program that will display a spiral of n × n numbers. Make sure your program uses constant (or linear) space. This means, it is not a
Practice Go: Reverse Parentheses @ Alex Pliutau's Blog
Reverse Parentheses Complete the function that reverses characters in (possibly nested) parentheses in the input string. Input strings will
Practice Go. Short Hash @ Alex Pliutau's Blog
This function can be used to generate short unique hashes, for example in URL shorteners. You’re given a dictionary of unique characters and
Different ways to block Go runtime forever @ Alex Pliutau's Blog
The current design of Go’s runtime assumes that the programmer is responsible for detecting when to terminate a goroutine and when to terminat
Image Recognition in Go using Tensorflow @ Alex Pliutau's Blog
Tensorflow is a computation library that represents computations with graphs. Its core is implemented in C++ and there are also bindings for
How to build Go plugin with data inside @ Alex Pliutau's Blog
Go 1.8 gives us a new tool for creating shared libraries, called plugins! This new plugin buildmode is currently only supported on Linux. But
Practice Go. Find Broken Node @ Alex Pliutau's Blog
We have a chain of nodes, the functionality of each node is to find if next node is working well. Unfortunately, we recently found that some
Practice Go: Warriors @ Alex Pliutau's Blog
BitVille and ByteVille are 2 warring tribes. BitVille has a spy telescope called the Hobble Scope, to count the number of Byte Warriors in B
Practice Go: First Letter, Last Letter game @ Alex Pliutau's Blog
First Letter, Last Letter game There is a game I played a lot in school. The game is called first letter, last letter. The object of this
Practice Go. Coins @ Alex Pliutau's Blog
Coins Let Piles(n int) represent the number of different ways in which n coins can be separated into piles. For example, five coins can be
packagemain: Youtube channel about Programming in Go @ Alex Pliutau's Blog
I’m really enjoying to share some stuff about Golang and related technologies. I am blogging here and also on dev.to. But I want to try the n
Coming soon: Microservices with Go Workshop, Vietnam, HCMC @ Alex Pliutau's Blog
One month ago Wizline organized the Microservices with Go Workshop in Mexico, GDL as part of Wizeline Academy I am happy to announce that we’re
Go tools are awesome @ Alex Pliutau's Blog
Yes, they are. And that’s why I love Go. Almost all important tools come together with Go installation, but there are also some you can inst