6 kyu

The Hackers’ Taunt

Description:

Decrypt the System – The Hackers’ Taunt

Description:

Your website has been hacked! A group of witty and arrogant cybercriminals infiltrated your server, stole all vital credentials, and encrypted your system. To make matters worse, they’ve covered their tracks so well that no immediate recovery is possible.

But instead of demanding a ransom, these hackers are taunting you. They’ve left a cryptic challenge—solve it, and you'll get the decryption password!

The Challenge:

The hackers have hidden the password deep inside a nested structure. Your task is to extract and join in the reversed order all strings that are located at a specific depth level in the nested structure.

Input:

  • A list of lists, which may contain either:
    • Other sub-lists (representing deeper levels).
    • Strings, which are the values stored in the structure.
  • An integer depth level (N) that indicates which level you need to extract strings from.

Output:

  • A single string, formed by joining all strings found at depth N, in the reversed order of appearing.
  • If there are no strings at the given depth ( Oops, hackers lied :[ ), return an empty string ("").

Notes:

  1. Only strings at depth N should be considered. Ignore strings at any other depth.
  2. Nested lists can go arbitrarily deep.
  3. Strings must be concatenated in the reversed order they appear at the correct depth.

Understanding Depth:

The depth is zero-based, meaning:

  • Depth 0:

    • Strings that are directly in the main list are at depth 0.
  • Depth 1:

    • Strings that are inside a sublist of the main list are at depth 1.
  • Depth 2 and beyond:

    • Strings that are in a sublist of a sublist are at depth 2, and so on.

Examples:

[ ["hello", [ [], [], "hiya", ["hiii", [[["lol"]]] ] ],"hi", [ [["he", "world"] ], [ ["hi", "!" ] ] ] ] , [ ["hi", "!","lol!",["lol"] ] ]], 3 -> "lol!!hihiya"

[ [ ["b"] , ["a"] ], ["world", "hello"]], 1 -> "helloworld"

[["a"], ["b]", ["c"], ["world", "hello"]], 2 -> ""

[ ["a", [[[["here"]]]] , ["hello"] ], ["b",[ [], [[]],[] ], "c",[]], ["world", "hello",[[[[[[]]]]]] ], ["?",[[[["also", "here"]],["not here"]]]],"not"], 5 -> "herealsohere"

["a", "b", ["c"], ["world", "hello"]], 0 -> "ba"

Let's go!!!

Please, be sure to check out my other katas:

Lists
Arrays
Recursion

More By Author:

Check out these other kata created by DrillToHeaven

Stats:

CreatedFeb 7, 2025
PublishedMar 2, 2025
Warriors Trained146
Total Skips8
Total Code Submissions151
Total Times Completed75
Python Completions75
Total Stars3
% of votes with a positive feedback rating90% of 25
Total "Very Satisfied" Votes20
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • DrillToHeaven Avatar
  • dfhwze Avatar
Ad