> For the complete documentation index, see [llms.txt](https://anton-veselskyi.gitbook.io/codding-problems-solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/7-kyu/indexed-capitalization.md).

# Indexed capitalization

## [Indexed capitalization](https://www.codewars.com/kata/59cfc09a86a6fdf6df0000f1)

Given a string and an array of integers representing indices, capitalize all letters at the given indices.

For example:

* `capitalize("abcdef",[1,2,5]) = "aBCdeF"`
* `capitalize("abcdef",[1,2,5,100]) = "aBCdeF"`. There is no index 100.

The input will be a lowercase string with no spaces and an array of digits.

Good luck!

Be sure to also try:

[Alternate capitalization](https://www.codewars.com/kata/59cfc000aeb2844d16000075)

[String array revisal](https://www.codewars.com/kata/59f08f89a5e129c543000069)

## Solutions

### 🌔 Lua

```lua
table = require 'table'

myf = function (s,arr) 
  for i=1,#arr do
    j = arr[i]+1 --Lua arr starts from 1
    if j > #s then ::continue:: end
    s = s:sub(1,j-1)..string.upper(s:sub(j,j))..s:sub(j+1,#s);
  end
  return s
end

indexcap = {capitalize = myf}
return indexcap
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/7-kyu/indexed-capitalization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
