<commit_before># Title

Tile Shuffling

# Difficulty 

Intermediate

# Description

As I get my house repainted, all sorts of weird things pop into my mind. For example, what would happen if too many pieces were the same color? Would my house become unstable? Would bugs or other unwanted pests have big places to hide and harm me? 

For this challenge, we'll work with the assumption that we don't want contiguous color tiles. We need to rearrange them - so we have to keep the tile counts per color the same - to find a stable arrangement where none of the adjacent ones are the same color. We're only concerned about the 4 cardinal directions - up, down, left, right - so diagonals are OK. 

This problem actually has relevance to topics like contagion spread, where you want as heterogenous a connected population as possible. 

# Input  Description

You'll be given a single integer, *N*, on a line, and then a matrix of colors in the next *N* rows, with *N* tiles per row - you get an *N* by *N* square. Example:

    3
    RRR
    GGG
    BBB

# Output Description

Your program should emit a solution within the constraints - tiles rearranged so that no two adjacent ones are the same color. Here's one possible solution to the above challenge. 

    RGB
    BRG
    GBR

# Challenge Input

    75
        GYGOYRVYRBBIOGIYIRBRYBYRRRIVBOVIVIROVIOOOOOGROYVYYOIBIIOOGIYORRIIGRBYIVYOI
    YOVBGVGRYRVYRVBORIBBVGYRIRVYVIVRGYOGIGYGROBGVIIOGGBGBIOBYYOOOROVIVVBVIIRBY
    IOGVGYIIVOYGGBGVGBBGIGGVIRGIYGRIRIBRIGRBOYIVVYRGOVOGYRBIRIOBGYVIYBORVBOVIB
    IGGGIGOIBORVVORIIRROOIVOVYOGYRRVRRVYOGBYVVIYIYGRRGRORRBBRBOIYIBBRYOBGGRRBR
    OGIBYROIYGRYBYGBVRBBIVVIYVBYRIIBROBVRIYVYIVOVYRVRRBRIYORBIBBYRYOYGVIYRYROY
    VOGBGGRBIGYBBIIRBIVIVGYYORIYRIROOIOYRBGGBIYGVVGIGOGVGOYBRRBROYBOOVRVVROBYI
    OGBOYVROOROBVYGBYRVRRRRVIGGYGOGRVVVOGIBBIOVOOGIOIOIGBBVBBIRVRVGBROOOGBBRIY
    IVGYOVOGOIYBGROROGIOYBBIGBIOYYBBGIYIBYGIBIRIOYIRBBGIOVGVBIVRYRGBGVVVIOYVGI
    YBVOOOVIVROVIOOYRROYYYIIVYBGRBOORYIBBRYGRVRRBYVBOROIYIBOVGVVBROGGOYBOYRVOR
    GRRGYYYYYYVVRYIBGGGGVBIVGGGYYRYRGIOVIGGYGGVVBYYYIGVRYBIRYOOORYIORGBRYBGGGR
    OIGBOIVYVBGYVOGIIRBYVYRVOOVOVIBBRYVIIOGRRIOIOOOOBVVIOIRGIYIOOBRRRBIBGGRYRY
    BRVBORBGBOGOVBOIGRGIOVBIYVBYYOIVRIVBRGRBRBVGRIIBVVVOVVRYIVYRYYYOOOOIROGYRV<commit_msg>Update tile_shuffling.md<commit_after># Title

Tile Shuffling

# Difficulty 

Intermediate

# Description

As I get my house repainted, all sorts of weird things pop into my mind. For example, what would happen if too many pieces were the same color? Would my house become unstable? Would bugs or other unwanted pests have big places to hide and harm me? 

For this challenge, we'll work with the assumption that we don't want contiguous color tiles. We need to rearrange them - so we have to keep the tile counts per color the same - to find a stable arrangement where none of the adjacent ones are the same color. We're only concerned about the 4 cardinal directions - up, down, left, right - so diagonals are OK. 

This problem actually has relevance to topics like contagion spread, where you want as heterogenous a connected population as possible. 

# Input  Description

You'll be given a single integer, *N*, on a line, and then a matrix of colors in the next *N* rows, with *N* tiles per row - you get an *N* by *N* square. Example:

    3
    RRR
    GGG
    BBB

# Output Description

Your program should emit a solution within the constraints - tiles rearranged so that no two adjacent ones are the same color. Here's one possible solution to the above challenge. 

    RGB
    BRG
    GBR

# Challenge Input

    75
    GYGOYRVYRBBIOGIYIRBRYBYRRRIVBOVIVIROVIOOOOOGROYVYYOIBIIOOGIYORRIIGRBYIVYOI
    YOVBGVGRYRVYRVBORIBBVGYRIRVYVIVRGYOGIGYGROBGVIIOGGBGBIOBYYOOOROVIVVBVIIRBY
    IOGVGYIIVOYGGBGVGBBGIGGVIRGIYGRIRIBRIGRBOYIVVYRGOVOGYRBIRIOBGYVIYBORVBOVIB
    IGGGIGOIBORVVORIIRROOIVOVYOGYRRVRRVYOGBYVVIYIYGRRGRORRBBRBOIYIBBRYOBGGRRBR
    OGIBYROIYGRYBYGBVRBBIVVIYVBYRIIBROBVRIYVYIVOVYRVRRBRIYORBIBBYRYOYGVIYRYROY
    VOGBGGRBIGYBBIIRBIVIVGYYORIYRIROOIOYRBGGBIYGVVGIGOGVGOYBRRBROYBOOVRVVROBYI
    OGBOYVROOROBVYGBYRVRRRRVIGGYGOGRVVVOGIBBIOVOOGIOIOIGBBVBBIRVRVGBROOOGBBRIY
    IVGYOVOGOIYBGROROGIOYBBIGBIOYYBBGIYIBYGIBIRIOYIRBBGIOVGVBIVRYRGBGVVVIOYVGI
    YBVOOOVIVROVIOOYRROYYYIIVYBGRBOORYIBBRYGRVRRBYVBOROIYIBOVGVVBROGGOYBOYRVOR
    GRRGYYYYYYVVRYIBGGGGVBIVGGGYYRYRGIOVIGGYGGVVBYYYIGVRYBIRYOOORYIORGBRYBGGGR
    OIGBOIVYVBGYVOGIIRBYVYRVOOVOVIBBRYVIIOGRRIOIOOOOBVVIOIRGIYIOOBRRRBIBGGRYRY
    BRVBORBGBOGOVBOIGRGIOVBIYVBYYOIVRIVBRGRBRBVGRIIBVVVOVVRYIVYRYYYOOOOIROGYRV
{'fraction_non_alphanumeric': 0.023542354235423543, 'fraction_numerical': 0.0017601760176017601, 'mean_word_length': 5.411847672778562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4601256', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1758, 'n_words': 452}