Code Monkey home page Code Monkey logo

paiza_test's Introduction

Paiza coding test: Rank B projects

Project: B096 爆弾の大爆発

Given the position of a "#" char in the array, replace/delete the other elements in the column and row. Count the number of elements replaced/deleted in the array.

Challenge:

Input desired size of 2D array (H,W). Then, input elements of the array.

e.g.: if H=rows=4 and W=cols=5, then

  4 5
  #.#..
  .....
  ..#..
  .....

solution

The code first searches for the "#" input and saves its position (i,j) in a new array. With that info, replace "#" and corresponding "."s by another char, say "x" in the column and row. Finally, count how many "x"s are in the modified 2D array.

Output:

x x x x x 
x . x . .
x x x x x
x . x . .
14

File fill_row_col.py

Project D04 Replace "at" by "@"

Given any word that contains "at", search for "at" word and replace it by "@" char.

solution

Working code available here

atpaizaattest
['a', 't', 'p', 'a', 'i', 'z', 'a', 'a', 't', 't', 'e', 's', 't']
['@', '', 'p', 'a', 'i', 'z', 'a', '@', '', 't', 'e', 's', 't']

@paiza@test

File replace_val.py

Project B104:データのクレンジング

Given the input, output the average.

N M

|s_{1,1} |s_{1,2}| ... |s_{1,M}| |s_{2,1} |s_{2,2}| ... |s_{2,M}| |...||| |s_{N,1} |s_{N,2}| ... |s_{N,M}|

Where: N= number of surveyed people, M = number of questions, s_{i,j} answer (number, string). If s_{i,j} > 100 should be considered as string. The result should be the average of the input numbers.

e.g: Input

5 3
80 -50 30
90 50 xxx
120 40 50
40 90 90
50 1 80

Output:

65
45
62

solution

Identify whether the input is a number or not with Python's: isnumeric() function, then count those that meet this requirement and store them in a 1D array, together with the accumulated sum. The result meets the requirements of paiza, all outputs are integers.

File: data_clean.py

Project B015 7-segment display

Representation of a number in a 7-segment display.

- 1 -
1 - 1
- 0 -	represents number "0"
1 - 1
- 1 -

index position:

- 1 -
6 - 2
- 7 -
5 - 3
- 4 -

The user will input as:

1 1 1 1 1 1 0

Challenge

Given two user inputs return "Yes" or "No" for the following cases:

  1. Both inputs must represent numbers in the 7-segment display.
  2. By mirroring their positions they both must represent numbers.
  3. By rotating their positions they both must represent numbers.

Example

Input:

0 0 0 0 1 1 0
1 1 0 1 1 1 1

Output: No Yes No

solution

First, list all the numbers (0~9), in text format, in an array. Then build a function to make string comparison and return "Yes"/"No" depending of the match. Next, mirror the positions and call the function that finds the match and return the answer. Finally, build another function to rotate the positions and return also the answer.

File sieben_seg.py

Result from paiza.jp

Click here to see score.

B032:デジタル計算機

そろばんでの足し算をシミュレーションするプログラムを書

Based on the input (size of object) build a digital abaqus to add up two numbers.

Input:

6
**|***
||*|||
======
*|*|*|
****|*
******
**|***
|*****
**|***
||*|||
======
||*|*|
****|*
******
**|***
******

Output:

**|***
||*|||
======
***|*|
*||***
****|*
******
|*****

solution

Since I have never used an abaqus, I don't know how it works, on Wikipedia there's information about how the 0~9 numbers are represented and how to add up, subtract and multiply.

In any way, I will only identify the input and compare it with its respective representation. Then add up both inputs and the output will like this:

Sum: ['4', '1', '6', '0', '2', '0']

Those numbers in fact represent the index of the base matrix. The only thing left to do is print those corresponding index strings in vertical.

File: abaqus.py

Result from paiza.jp

Click here to see score.

A021 海岸線 再チャレンジ採点結果

Based on input map, find the Area and Perimeter of all the islands. Diagonal islands are not counted. Sort them by Area and Perimeter size.

Input is given as:

H W
s_1
s_2
.
.
.
s_H

Where: H is the height of the map, W is the width. s_1, ..., s_H are the string representations where the island might be.

Example:

4 4
....
.#..
..#.
....

Here # represents the island and . represents the surrounding env.(probably water).

Output:

1 4
1 4

These mean, there are two islands, in diagonal. The area of each island is 1 and its perimeter is 4.

Solution

The challenge was already taken by another user, provided solution A021.cpp so it was timed-out. In any way I decided to take the challenge and find another solution.

By searching all the islands position, the perimeter can be calculated. But, how to find those that are on the same row or column?

Decided to challenge it in Ruby!

Thus far, lots of difficulties found. For instance when islands are in diagonal the area and perimeter are returned just fine. However, when, they are on the same row or column the output returns for each island, not the total area and perimeter of it.

Example:

4 4
#...
#...
....
....

[2, 3]
[0, 3]	 

The correct output should have been:

[2,6]

The solution is still under way.

Wordle Challenge

Attempt to make "wordle" less challenging.

By using Python's english_words module search and return only those words with length = 5

If already in the wordle page, then input only those letters marked in grey
If any position is marked in green it is possible to input too.

Working code is available on my Repl.it

At run-time this is the menu:

1 : Random 5-letter word
2 : Exclude these letters
3 : List only words ending with
Option Number?: 

Output:

Input letters not in the word: b o z s t a v
Position and letter: 5 e
passe sieve engle midge etude crane levee steve tithe stave title chine cause lance lethe argue chide lycee reave clive ankle guise sprue agree rupee aware cadre cycle lathe niece wedge grape

BTW, Wordle #255 was RUPEE


Environment:

OS: Linux Fedora 34

Language: Python3.8

Editor: Emacs

paiza_test's People

Contributors

ndlopez avatar

Watchers

James Cloos avatar  avatar

paiza_test's Issues

Challenge A021

I have stopped working on this challenge, lots of other things to concentrate.

The current issue is:
Ruby code outputs the following for diagonal and neighbor islands:

[2, 3]
[0, 3]

The correct output should have been:

[2,6]

I will resume this challenge some other day.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.