WeixiangYan/CodeTransOcean huggingface dataset:
Task: Remove vowels from a string



C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}


Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}
Task: Remove vowels from a string



C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}



Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}
Task: Remove vowels from a string



C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}





Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string



C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}






VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Remove vowels from a string




Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}


Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}
Task: Remove vowels from a string





Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}



Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string




Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}




Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string




Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}





VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Remove vowels from a string







Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()


VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Remove vowels from a string

C: #include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}





Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}
Task: Remove vowels from a string





Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}




VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Faulhaber's formula




Go: package main

import (
	"fmt"
	"math/big"
)

func bernoulli(z *big.Rat, n int64) *big.Rat {
	if z == nil {
		z = new(big.Rat)
	}
	a := make([]big.Rat, n+1)
	for m := range a {
		a[m].SetFrac64(1, int64(m+1))
		for j := m; j >= 1; j-- {
			d := &a[j-1]
			d.Mul(z.SetInt64(int64(j)), d.Sub(d, &a[j]))
		}
	}
	return z.Set(&a[0])
}

func main() {
	
	q := new(big.Rat)
	c := new(big.Rat)      
	be := new(big.Rat)     
	bi := big.NewRat(1, 1) 

	for p := int64(0); p < 10; p++ {
		fmt.Print(p, " : ")
		q.SetFrac64(1, p+1)
		neg := true
		for j := int64(0); j <= p; j++ {
			neg = !neg
			if neg {
				c.Neg(q)
			} else {
				c.Set(q)
			}
			bi.Num().Binomial(p+1, j)
			bernoulli(be, j)
			c.Mul(c, bi)
			c.Mul(c, be)
			if c.Num().BitLen() == 0 {
				continue
			}
			if j == 0 {
				fmt.Printf(" %4s", c.RatString())
			} else {
				fmt.Printf(" %+2d/%-2d", c.Num(), c.Denom())
			}
			fmt.Print("×n")
			if exp := p + 1 - j; exp > 1 {
				fmt.Printf("^%-2d", exp)
			}
		}
		fmt.Println()
	}
}




Python: from fractions import Fraction

def nextu(a):
    n = len(a)
    a.append(1)
    for i in range(n - 1, 0, -1):
        a[i] = i * a[i] + a[i - 1]
    return a

def nextv(a):
    n = len(a) - 1
    b = [(1 - n) * x for x in a]
    b.append(1)
    for i in range(n):
        b[i + 1] += a[i]
    return b

def sumpol(n):
    u = [0, 1]
    v = [[1], [1, 1]]
    yield [Fraction(0), Fraction(1)]
    for i in range(1, n):
        v.append(nextv(v[-1]))
        t = [0] * (i + 2)
        p = 1
        for j, r in enumerate(u):
            r = Fraction(r, j + 1)
            for k, s in enumerate(v[j + 1]):
                t[k] += r * s
        yield t
        u = nextu(u)

def polstr(a):
    s = ""
    q = False
    n = len(a) - 1
    for i, x in enumerate(reversed(a)):
        i = n - i
        if i < 2:
            m = "n" if i == 1 else ""
        else:
            m = "n^%d" % i
        c = str(abs(x))
        if i > 0:
            if c == "1":
                c = ""
            else:
                m = " " + m
        if x != 0:
            if q:
                t = " + " if x > 0 else " - "
                s += "%s%s%s" % (t, c, m)
            else:
                t = "" if x > 0 else "-"
                s = "%s%s%s" % (t, c, m)
                q = True
    if q:
        return s
    else:
        return "0"

for i, p in enumerate(sumpol(10)):
    print(i, ":", polstr(p))
Task: ABC problem


C++: #include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cctype>

typedef std::pair<char,char> item_t;
typedef std::vector<item_t> list_t;

bool can_make_word(const std::string& w, const list_t& vals) {
    std::set<uint32_t> used;
    while (used.size() < w.size()) {
        const char c = toupper(w[used.size()]);
        uint32_t x = used.size();
        for (uint32_t i = 0, ii = vals.size(); i < ii; ++i) {
            if (used.find(i) == used.end()) {
                if (toupper(vals[i].first) == c || toupper(vals[i].second) == c) {
                    used.insert(i);
                    break;
                }
            }
        }
        if (x == used.size()) break;
    }
    return used.size() == w.size();
}

int main() {
    list_t vals{ {'B','O'}, {'X','K'}, {'D','Q'}, {'C','P'}, {'N','A'}, {'G','T'}, {'R','E'}, {'T','G'}, {'Q','D'}, {'F','S'}, {'J','W'}, {'H','U'}, {'V','I'}, {'A','N'}, {'O','B'}, {'E','R'}, {'F','S'}, {'L','Y'}, {'P','C'}, {'Z','M'} };
    std::vector<std::string> words{"A","BARK","BOOK","TREAT","COMMON","SQUAD","CONFUSE"};
    for (const std::string& w : words) {
        std::cout << w << ": " << std::boolalpha << can_make_word(w,vals) << ".\n";
    }
}


C#: using System;
using System.IO;

using System.Text.RegularExpressions;
using System.Collections.Generic;

void Main()
{
   string blocks = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM";
   List<string> words = new List<string>() {
      "A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"
   };

   foreach(var word in words)
   {
      Console.WriteLine("{0}: {1}", word, CheckWord(blocks, word));
   }
}

bool CheckWord(string blocks, string word)
{
   for(int i = 0; i < word.Length; ++i)
   {
      int length = blocks.Length;
      Regex rgx = new Regex("([a-z]"+word[i]+"|"+word[i]+"[a-z])", RegexOptions.IgnoreCase);
      blocks = rgx.Replace(blocks, "", 1);
      if(blocks.Length == length) return false;
   }
   return true;
}
Task: ABC problem


C++: #include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cctype>

typedef std::pair<char,char> item_t;
typedef std::vector<item_t> list_t;

bool can_make_word(const std::string& w, const list_t& vals) {
    std::set<uint32_t> used;
    while (used.size() < w.size()) {
        const char c = toupper(w[used.size()]);
        uint32_t x = used.size();
        for (uint32_t i = 0, ii = vals.size(); i < ii; ++i) {
            if (used.find(i) == used.end()) {
                if (toupper(vals[i].first) == c || toupper(vals[i].second) == c) {
                    used.insert(i);
                    break;
                }
            }
        }
        if (x == used.size()) break;
    }
    return used.size() == w.size();
}

int main() {
    list_t vals{ {'B','O'}, {'X','K'}, {'D','Q'}, {'C','P'}, {'N','A'}, {'G','T'}, {'R','E'}, {'T','G'}, {'Q','D'}, {'F','S'}, {'J','W'}, {'H','U'}, {'V','I'}, {'A','N'}, {'O','B'}, {'E','R'}, {'F','S'}, {'L','Y'}, {'P','C'}, {'Z','M'} };
    std::vector<std::string> words{"A","BARK","BOOK","TREAT","COMMON","SQUAD","CONFUSE"};
    for (const std::string& w : words) {
        std::cout << w << ": " << std::boolalpha << can_make_word(w,vals) << ".\n";
    }
}






Python:     >>> can_make_word("A")
    True
    >>> can_make_word("BARK")
    True
    >>> can_make_word("BOOK")
    False
    >>> can_make_word("TREAT")
    True
    >>> can_make_word("COMMON")
    False
    >>> can_make_word("SQUAD")
    True
    >>> can_make_word("CONFUSE")
    True
Task: ABC problem


C++: #include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cctype>

typedef std::pair<char,char> item_t;
typedef std::vector<item_t> list_t;

bool can_make_word(const std::string& w, const list_t& vals) {
    std::set<uint32_t> used;
    while (used.size() < w.size()) {
        const char c = toupper(w[used.size()]);
        uint32_t x = used.size();
        for (uint32_t i = 0, ii = vals.size(); i < ii; ++i) {
            if (used.find(i) == used.end()) {
                if (toupper(vals[i].first) == c || toupper(vals[i].second) == c) {
                    used.insert(i);
                    break;
                }
            }
        }
        if (x == used.size()) break;
    }
    return used.size() == w.size();
}

int main() {
    list_t vals{ {'B','O'}, {'X','K'}, {'D','Q'}, {'C','P'}, {'N','A'}, {'G','T'}, {'R','E'}, {'T','G'}, {'Q','D'}, {'F','S'}, {'J','W'}, {'H','U'}, {'V','I'}, {'A','N'}, {'O','B'}, {'E','R'}, {'F','S'}, {'L','Y'}, {'P','C'}, {'Z','M'} };
    std::vector<std::string> words{"A","BARK","BOOK","TREAT","COMMON","SQUAD","CONFUSE"};
    for (const std::string& w : words) {
        std::cout << w << ": " << std::boolalpha << can_make_word(w,vals) << ".\n";
    }
}







VB: dim Blocks as string
dim InWord as string

Function CanMakeWord (FInWord as string, FBlocks as string) as integer
    dim WIndex as integer, BIndex as integer
    
    FBlocks = UCase$(FBlocks) - " " - ","
    FInWord = UCase$(FInWord)
    
    for WIndex = 1 to len(FInWord)
        BIndex = instr(FBlocks, FInWord[WIndex])
        
        if BIndex then
            FBlocks = Replace$(FBlocks,"**",iif(BIndex mod 2,BIndex,BIndex-1))
        else
            Result = 0
            exit function
        end if
    next
    
    Result = 1            
end function 

InWord = "Confuse"
Blocks = "BO, XK, DQ, CP, NA, GT, RE, TG, QD, FS, JW, HU, VI, AN, OB, ER, FS, LY, PC, ZM"
showmessage "Can make: " + InWord + " = " + iif(CanMakeWord(InWord, Blocks), "True", "False")
Task: ABC problem



C#: using System;
using System.IO;

using System.Text.RegularExpressions;
using System.Collections.Generic;

void Main()
{
   string blocks = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM";
   List<string> words = new List<string>() {
      "A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"
   };

   foreach(var word in words)
   {
      Console.WriteLine("{0}: {1}", word, CheckWord(blocks, word));
   }
}

bool CheckWord(string blocks, string word)
{
   for(int i = 0; i < word.Length; ++i)
   {
      int length = blocks.Length;
      Regex rgx = new Regex("([a-z]"+word[i]+"|"+word[i]+"[a-z])", RegexOptions.IgnoreCase);
      blocks = rgx.Replace(blocks, "", 1);
      if(blocks.Length == length) return false;
   }
   return true;
}



Java: static Boolean canMakeWord(List<String> src_blocks, String word) {
    if (String.isEmpty(word)) {
        return true;
    }

    List<String> blocks = new List<String>();
    for (String block : src_blocks) {
        blocks.add(block.toUpperCase());
    }
    
    for (Integer i = 0; i < word.length(); i++) {
        Integer blockIndex = -1;
        String c = word.mid(i, 1).toUpperCase();
        
        for (Integer j = 0; j < blocks.size(); j++) {
            if (blocks.get(j).contains(c)) {
                blockIndex = j;
                break;
            }
        }
        
        if (blockIndex == -1) {
            return false;
        } else {
            blocks.remove(blockIndex);
        }
    }
        
    return true;
}

List<String> blocks = new List<String>{
    'BO', 'XK', 'DQ', 'CP', 'NA',
    'GT', 'RE', 'TG', 'QD', 'FS', 
    'JW', 'HU', 'VI', 'AN', 'OB', 
    'ER', 'FS', 'LY', 'PC', 'ZM'
};
System.debug('"": ' + canMakeWord(blocks, ''));
System.debug('"A": ' + canMakeWord(blocks, 'A'));
System.debug('"BARK": ' + canMakeWord(blocks, 'BARK'));
System.debug('"book": ' + canMakeWord(blocks, 'book'));
System.debug('"treat": ' + canMakeWord(blocks, 'treat'));
System.debug('"COMMON": ' + canMakeWord(blocks, 'COMMON'));
System.debug('"SQuAd": ' + canMakeWord(blocks, 'SQuAd'));
System.debug('"CONFUSE": ' + canMakeWord(blocks, 'CONFUSE'));
Task: ABC problem



C#: using System;
using System.IO;

using System.Text.RegularExpressions;
using System.Collections.Generic;

void Main()
{
   string blocks = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM";
   List<string> words = new List<string>() {
      "A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"
   };

   foreach(var word in words)
   {
      Console.WriteLine("{0}: {1}", word, CheckWord(blocks, word));
   }
}

bool CheckWord(string blocks, string word)
{
   for(int i = 0; i < word.Length; ++i)
   {
      int length = blocks.Length;
      Regex rgx = new Regex("([a-z]"+word[i]+"|"+word[i]+"[a-z])", RegexOptions.IgnoreCase);
      blocks = rgx.Replace(blocks, "", 1);
      if(blocks.Length == length) return false;
   }
   return true;
}





Python:     >>> can_make_word("A")
    True
    >>> can_make_word("BARK")
    True
    >>> can_make_word("BOOK")
    False
    >>> can_make_word("TREAT")
    True
    >>> can_make_word("COMMON")
    False
    >>> can_make_word("SQUAD")
    True
    >>> can_make_word("CONFUSE")
    True
Task: ABC problem



C#: using System;
using System.IO;

using System.Text.RegularExpressions;
using System.Collections.Generic;

void Main()
{
   string blocks = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM";
   List<string> words = new List<string>() {
      "A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"
   };

   foreach(var word in words)
   {
      Console.WriteLine("{0}: {1}", word, CheckWord(blocks, word));
   }
}

bool CheckWord(string blocks, string word)
{
   for(int i = 0; i < word.Length; ++i)
   {
      int length = blocks.Length;
      Regex rgx = new Regex("([a-z]"+word[i]+"|"+word[i]+"[a-z])", RegexOptions.IgnoreCase);
      blocks = rgx.Replace(blocks, "", 1);
      if(blocks.Length == length) return false;
   }
   return true;
}






VB: dim Blocks as string
dim InWord as string

Function CanMakeWord (FInWord as string, FBlocks as string) as integer
    dim WIndex as integer, BIndex as integer
    
    FBlocks = UCase$(FBlocks) - " " - ","
    FInWord = UCase$(FInWord)
    
    for WIndex = 1 to len(FInWord)
        BIndex = instr(FBlocks, FInWord[WIndex])
        
        if BIndex then
            FBlocks = Replace$(FBlocks,"**",iif(BIndex mod 2,BIndex,BIndex-1))
        else
            Result = 0
            exit function
        end if
    next
    
    Result = 1            
end function 

InWord = "Confuse"
Blocks = "BO, XK, DQ, CP, NA, GT, RE, TG, QD, FS, JW, HU, VI, AN, OB, ER, FS, LY, PC, ZM"
showmessage "Can make: " + InWord + " = " + iif(CanMakeWord(InWord, Blocks), "True", "False")
Task: ABC problem





Java: static Boolean canMakeWord(List<String> src_blocks, String word) {
    if (String.isEmpty(word)) {
        return true;
    }

    List<String> blocks = new List<String>();
    for (String block : src_blocks) {
        blocks.add(block.toUpperCase());
    }
    
    for (Integer i = 0; i < word.length(); i++) {
        Integer blockIndex = -1;
        String c = word.mid(i, 1).toUpperCase();
        
        for (Integer j = 0; j < blocks.size(); j++) {
            if (blocks.get(j).contains(c)) {
                blockIndex = j;
                break;
            }
        }
        
        if (blockIndex == -1) {
            return false;
        } else {
            blocks.remove(blockIndex);
        }
    }
        
    return true;
}

List<String> blocks = new List<String>{
    'BO', 'XK', 'DQ', 'CP', 'NA',
    'GT', 'RE', 'TG', 'QD', 'FS', 
    'JW', 'HU', 'VI', 'AN', 'OB', 
    'ER', 'FS', 'LY', 'PC', 'ZM'
};
System.debug('"": ' + canMakeWord(blocks, ''));
System.debug('"A": ' + canMakeWord(blocks, 'A'));
System.debug('"BARK": ' + canMakeWord(blocks, 'BARK'));
System.debug('"book": ' + canMakeWord(blocks, 'book'));
System.debug('"treat": ' + canMakeWord(blocks, 'treat'));
System.debug('"COMMON": ' + canMakeWord(blocks, 'COMMON'));
System.debug('"SQuAd": ' + canMakeWord(blocks, 'SQuAd'));
System.debug('"CONFUSE": ' + canMakeWord(blocks, 'CONFUSE'));



Python:     >>> can_make_word("A")
    True
    >>> can_make_word("BARK")
    True
    >>> can_make_word("BOOK")
    False
    >>> can_make_word("TREAT")
    True
    >>> can_make_word("COMMON")
    False
    >>> can_make_word("SQUAD")
    True
    >>> can_make_word("CONFUSE")
    True