Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,601 members, 7,816,493 topics. Date: Friday, 03 May 2024 at 11:56 AM

Codewars.com Coding Challenges - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Codewars.com Coding Challenges (2369 Views)

Coding Challenges As A Newbie. / CODELAGOS: 337 Schools To Participate In Coding Competition / Do We Have Coding Bootcamps In Nigeria? / Faster Way To Learn Web Development. (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Codewars.com Coding Challenges by Fr4nk(m): 1:03am On May 16, 2022
I really love this site Codewars.com and their coding challenges, I wonder if there are coders here who use the platform, let's meet and maybe we might just form our own clan (maybe we could call it "Naira code ninjas" grin lol)

2 Likes

Re: Codewars.com Coding Challenges by Altairx440: 1:40pm On May 17, 2022
Fr4nk:
I really love this site Codewars.com and their coding challenges, I wonder if there are coders here who use the platform, let's meet and maybe we might just form our own clan (maybe we could call it "Naira code ninjas" grin lol)
I have stopped Codewars.com, but I'm in for some coding challenges, you interested?

1 Like

Re: Codewars.com Coding Challenges by Fr4nk(m): 1:58pm On May 17, 2022
Altairx440:

I have stopped Codewars.com, but I'm in for some coding challenges, you interested?

Sure
Re: Codewars.com Coding Challenges by Altairx440: 2:19pm On May 17, 2022
Fr4nk:


Sure
Say, I give a coding challenge, you solve and post your solution, if possible with the Big O/complexity and you do same. Is this approach ok?

1 Like

Re: Codewars.com Coding Challenges by Fr4nk(m): 3:44pm On May 17, 2022
Altairx440:

Say, I give a coding challenge, you solve and post your solution, if possible with the Big O/complexity and you do same. Is this approach ok?

Maybe, just to be clear I no too sabi, but I love a good challenge, so expect rubbish code that works lol grin

4 Likes

Re: Codewars.com Coding Challenges by Altairx440: 6:19pm On May 17, 2022
Fr4nk:


Maybe, just to be clear I no too sabi, but I love a good challenge, so expect rubbish code that works lol grin
Lol its OK, you should go first then, post a challenge you are comfortable solving, we could just be on the same level since we are age mates.

1 Like

Re: Codewars.com Coding Challenges by Fr4nk(m): 8:29pm On May 17, 2022
Altairx440:

Lol its OK, you should go first then, post a challenge you are comfortable solving, we could just be on the same level since we are age mates.

Age mates (I'm guessing you checked my profile).
Okay bro
My main language is python,
I'm still in limbo between intermediate and advanced but I'll try best.
I just started Data structures and algorithms so I haven't really learnt Asymptotic notation and all those Big O analysis stuff

1 Like

Re: Codewars.com Coding Challenges by Fr4nk(m): 8:33pm On May 17, 2022
You are given an integer, . Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.)

Different sizes of alphabet rangoli are shown below:

#size 3

----c----
--c-b-c--
c-b-a-b-c
--c-b-c--
----c----

#size 5

--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------

#size 10

------------------j------------------
----------------j-i-j----------------
--------------j-i-h-i-j--------------
------------j-i-h-g-h-i-j------------
----------j-i-h-g-f-g-h-i-j----------
--------j-i-h-g-f-e-f-g-h-i-j--------
------j-i-h-g-f-e-d-e-f-g-h-i-j------
----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----
--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--
j-i-h-g-f-e-d-c-b-a-b-c-d-e-f-g-h-i-j
--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--
----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----
------j-i-h-g-f-e-d-e-f-g-h-i-j------
--------j-i-h-g-f-e-f-g-h-i-j--------
----------j-i-h-g-f-g-h-i-j----------
------------j-i-h-g-h-i-j------------
--------------j-i-h-i-j--------------
----------------j-i-j----------------
------------------j------------------
The center of the rangoli has the first alphabet letter a, and the boundary has the alphabet letter (in alphabetical order).

Function Description

Complete the rangoli function in the editor below.

rangoli has the following parameters:

int size: the size of the rangoli
Returns

string: a single string made up of each of the lines of the rangoli separated by a newline character (\n)
Input Format

Only one line of input containing , the size of the rangoli.

Constraints


Sample Input

5
Sample Output

--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------

https://www.hackerrank.com/challenges/alphabet-rangoli/problem?isFullScreen=false

I got this from hackerrank, check out the link for better understanding
Re: Codewars.com Coding Challenges by Altairx440: 11:08pm On May 17, 2022
Fr4nk:


Age mates (I'm guessing you checked my profile).
Okay bro
My main language is python,
I'm still in limbo between intermediate and advanced but I'll try best.
I just started Data structures and algorithms so I haven't really learnt Asymptotic notation and all those Big O analysis stuff
I saw your post on some data science thread, that's how I found out. I use python too though just for the time being, I too have not taking a DSA course but I've already got the hang of Big O, so just ignore it.
Re: Codewars.com Coding Challenges by Altairx440: 11:21pm On May 17, 2022
I came up with two different ways to solve this problem, and after implementing them they both work just fine, So I'm posting both solutions.
Re: Codewars.com Coding Challenges by Altairx440: 11:23pm On May 17, 2022
I'm unable to post the python code, I'll try again tomorrow.

1 Like

Re: Codewars.com Coding Challenges by Altairx440: 12:15pm On May 18, 2022
# solution 1:
def segment(i, n):
result, m = [n], n
for _ in range(i):
m -= 1
result.append(m)
for j in range(len(result)-2, -1, -1):
result.append(result[j])
return result

def fill(arr, n):
str = "-".join(arr)
i = len(str)
while i < n:
str += "-"
str = "-" + str
i += 2
return str

def print_rangoli(n):
size = n + (n - 1) * 3
base = []
for i in range(n):
arr = segment(i, n)
for i in range(len(arr)):
k = arr[i] % 27
f = chr
arr[i] = f(96 + k)
str = fill(arr, size)
base.append(str)
for j in range(n-2, -1, -1):
base.append(base[j])
base = "\n".join(base)
print(base)

Re: Codewars.com Coding Challenges by Altairx440: 12:38pm On May 18, 2022
.
Re: Codewars.com Coding Challenges by Altairx440: 12:39pm On May 18, 2022
.
Re: Codewars.com Coding Challenges by Altairx440: 12:39pm On May 18, 2022
.
Re: Codewars.com Coding Challenges by Altairx440: 12:40pm On May 18, 2022
# solution 2:
def print_rangoli(x):
f = chr
for i in range(x-1, -1, -1):
for j in range(i):
print("-", end="-" )
for k in range(x, i, -1):
k = f(96 + (k % (27)))
print(k, end=("-" if x != 1 else ""wink)
for l in range(i+1, x):
ll = f(96 + (l+1 % (27)))
print(ll, end=("" if (i==0 and l==x-1) else "-"wink)
for m in range(i):
print("-", end=("-" if m != 0 else ""wink)
print()

for i in range(1, x):
for j in range(i):
print("-", end="-" )
for k in range(x, i, -1):
k = f(96 + (k % (27)))
print(k, end="-" )
for l in range(i+1, x):
l = f(96 + (l+1 % (27)))
print(l, end="-" )
for m in range(i):
print("-", end=("-" if m != 0 else ""wink)
print()
Re: Codewars.com Coding Challenges by Fr4nk(m): 2:08pm On May 18, 2022
These are way too complex bro,
I'll test them out
Re: Codewars.com Coding Challenges by Fr4nk(m): 2:10pm On May 18, 2022
The first one worked well
Re: Codewars.com Coding Challenges by Fr4nk(m): 2:13pm On May 18, 2022
Second one worked well too
Re: Codewars.com Coding Challenges by Fr4nk(m): 2:13pm On May 18, 2022
Here's my solution

Re: Codewars.com Coding Challenges by Altairx440: 2:26pm On May 18, 2022
Fr4nk:
Here's my solution
Nice solution bro, You should also be the posting the source code of your solutions so I can test yours as well.
Nairaland flags the "chr" function call, so you'll have to swap names in your solutions just like i did.
Re: Codewars.com Coding Challenges by Altairx440: 2:42pm On May 18, 2022
You're given s, a string with an arbitrary number of headers and rows in the formats below;

s1 = "Country\tState\tTown\r\nNigeria\tLagos
State\tLagos\r\nUSA\tTexas\tDallas\r\n"
s2 = "Country\r\nUSA\r\nChina;
s3 = "Name\tAge\r\n"

return an array of objects in the format below;
# s1
[
{
'Country': 'Nigeria',
'State': 'Lagos State',
'Town': 'Lagos'
},
{
'Country': 'USA',
'State': 'Texas',
'Town': 'Dallas'
}
]
# s2
[
{
'Country': USA'
},
{
'Country': 'China'
}
]
# s3
[]

1 Like

Re: Codewars.com Coding Challenges by Fr4nk(m): 6:47pm On May 18, 2022
Altairx440:
You're given s, a string with an arbitrary number of headers and rows in the formats below;

s1 = "Country\tState\tTown\r\nNigeria\tLagos
State\tLagos\r\nUSA\tTexas\tDallas\r\n"
s2 = "Country\r\nUSA\r\nChina;
s3 = "Name\tAge\r\n"

return an array of objects in the format below;
# s1
[
{
'Country': 'Nigeria',
'State': 'Lagos State',
'Town': 'Lagos'
},
{
'Country': 'USA',
'State': 'Texas',
'Town': 'Dallas'
}
]
# s2
[
{
'Country': USA'
},
{
'Country': 'China'
}
]
# s3
[]

Why is s3 an empty list?
Re: Codewars.com Coding Challenges by Altairx440: 8:54pm On May 18, 2022
Fr4nk:


Why is s3 an empty list?
List s3 is an empty list because string s3 contains a header with no accompanying rows, specifically, string s3 has a "Name" and "Age" column, but no rows, you should not create an empty object.
Re: Codewars.com Coding Challenges by Fr4nk(m): 12:55am On May 19, 2022
Okay cool,
Your calling them objects, aren't they dictionaries lol
You sound like someone coming from JavaScript grin
Re: Codewars.com Coding Challenges by Altairx440: 5:52am On May 19, 2022
Fr4nk:
Okay cool,
Your calling them objects, aren't they dictionaries lol
You sound like someone coming from JavaScript grin
Of course, JavaScript was my first language lol, plus it's mostly called "object" or "map/hashmap" in other languages.

1 Like

Re: Codewars.com Coding Challenges by excanny: 1:22pm On May 19, 2022
Is any other language allowed?
Re: Codewars.com Coding Challenges by Fr4nk(m): 2:03pm On May 19, 2022
Altairx440:

Of course, JavaScript was my first language lol, plus it's mostly called "object" or "map/hashmap" in other languages.

Yeah dictionaries / objects are Hashmaps,
Any language is allowed sir

1 Like

Re: Codewars.com Coding Challenges by Altairx440: 2:10pm On May 19, 2022
excanny:
Is any other language allowed?
Yes!
Re: Codewars.com Coding Challenges by Altairx440: 2:15pm On May 19, 2022
Fr4nk:


Yeah dictionaries / objects are Hashmaps
Yeah, also seems like you did not learn JavaScript, is Python the only language you know?

1 Like

Re: Codewars.com Coding Challenges by excanny: 5:08pm On May 19, 2022
Got it working in C#

2 Likes

Re: Codewars.com Coding Challenges by Fr4nk(m): 7:43pm On May 19, 2022
Altairx440:

Yeah, also seems like you did not learn JavaScript, is Python the only language you know?
Yes sir, python only, I may learn other languages like Javascript(soon because I want to work with flask or Django), R, C++ or Java or C# later, but being a python expert is d main goal

1 Like

(1) (2) (3) (Reply)

Whats The Difference B/w Mysql And Sql: Do They Relate? / Junit: How To Set Classpath On Windows Xp / Oracle Primavera P6-introduction To Basic Pdf(with Screenshots) Free

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.