## What can I do as a beginner cybersecurity professional?

I am scheduled to graduate college with a BS in cybersecurity in October. However, whenever I look up different cybersecurity topics and such I find that there are many many topics that I have no exposure to. I understand that there is a lot to cybersecurity and I am trying to be the best of the best. So my question is, what can I do further enhance myself and become a great cybersecurity professional? Any and all suggestions are much appreciated. Thank you

-Samuel

## beginner – A little Python roguelike with mostly using standard libraries

So, I made this in order to practice my Python OOP and algorithms skills, and refactored it a bit after a few months of s tale. May anybody review it in a PR please? Want to see the flaws that could be fixed, considering I didn’t improve much since the initial development of this.
https://github.com/fen0s/TABSlike/
One that especially makes me worries is the implementation of getting a 3×3 area around the unit to check for enemy units… Is it fine, and can you understand it overall?

``````def check_surroundings(self, y_coord, x_coord):
y_coord -= 1 #to check y level above unit
enemies = ()
for _ in range(3):
if self.engine.check_inbounds(y_coord, x_coord-1) and self.engine.check_inbounds(y_coord, x_coord+2):
for entity in self.engine.techmap(y_coord)(x_coord-1:x_coord+1):
if entity and entity.team != self.team:
enemies.append(entity)
y_coord+=1
return enemies
``````

## beginner – Caesar Cipher [The Odin Project-Javascript Exercise]

Very new to coding, so please don’t bully me.

Implement the legendary caesar cipher:

In cryptography, a Caesar cipher, also known as Caesar’s cipher, the shift cipher, Caesar’s code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

Question: Write a function that takes a string to be encoded and a shift factor and then returns the encoded string:

caesar(‘A’, 1) // simply shifts the letter by 1: returns ‘B’ the cipher should retain capitalization:

caesar(‘Hey’, 5) // returns ‘Mjd; should not shift punctuation:

caesar(‘Hello, World!’, 5) //returns ‘Mjqqt, Btwqi!’ the shift should wrap around the alphabet:

caesar(‘Z’, 1) // returns ‘A’ negative numbers should work as well:

caesar(‘Mjqqt, Btwqi!’, -5) // returns ‘Hello, World!’

My Solution:

``````function caesar(string, num) {
let arr = ();
for(let i=0;i<string.length;i++)
{if(!(/(a-zA-Z)/.test(string(i))))
{arr(i)=string(i); continue;}
let n = string.charCodeAt(i) + num;
if (string(i) == string(i).toLowerCase())
{if(n>122)
{while(n>122)
{n-=26;}}
else
{while(n<97)
{n+=26;}
}
}
else
{if(n>90)
{while(n>90)
{n-=26;}
}
else
{while(n<65)
{n+=26;}
}
}
arr(i)=String.fromCharCode(n);
}
console.log(arr.join(''));
}
caesar("Hello, World!", 2);
caesar("Hello, World!", 75);
``````

The code is working perfectly as per requirement, but please help me with a better solution if possible.

And if you do, please use comments to extensively explain the working process, as I’m quite the noob.

## beginner – Rotating Matrix in Python with a For loop (90 degrees)

So the image of a matrix can be transformed, for the rows and columns to this rule:

The Values in the first row of the original matrix become the values of the last column of the image matrix. The Values in the second row of the original matrix become the values of the second last column of the image matrix …. and so on …until the values in the last row of the original matrix become the values of the first column of the image matrix.

As a diagram, the left hand matrix is the original and the right hand matrix is its image.

``````(('a', 'b', 'c'),          (('g', 'd', 'a'),
('d', 'e', 'f'),            ('h', 'e', 'b'),
('g', 'h', 'i')  )          ('i', 'f', 'c')  )

``````

Assume the following already exist in Python:

matrix: a 3 x 3 list of lists representing a matrix of numbers (similar to the examples above)

image: a list the same size as matrix, containing only empty sub-lists (for storing the matrix image)

indexes: a list containing the integers 0, 1 and 2 (i.e., valid index positions of both matrix, and image)

Complete the following code to return the image of matrix according to the above rule.

``````for row in indexes:
for ____ in ____:
image(row).append(matrix(____) (____))
``````

The options are:

row

col

0

1

2

len(indexes)

indexes

2 – col

2 – row

col – 2

row – 2

len(matrix)

Any of the options can be used above in any of the blank spots. My gut after my times of learning python tells me that I should try to answer the question as such:

``````for row in indexes:
for col in indexes:
image(row).append(matrix(col)(row))
``````

What i think will happen is that it’ll take all the values, and switch em out for row -> column and column -> row. Am i somewhat correct or completely off?

## beginner – Basic tic-tac-toe matrix in Haskell

Beginner functional programmer… (but not beginner programmer)

Currently, I have the following code:

``````import Control.Monad (mapM_)

main = gridMaker 3

gridMaker :: Int -> IO ()
{-Creates a nxn matrix filling the lower triangle with "O"'s
and filling the rest with "X"s
Example:
O --- X --- X
O --- O --- X
O --- O --- O
-}
gridMaker gridSize =
-- Creates the indicators
let startingIter = 1
indicators = indicatorListCreator gridSize startingIter
-- Print each indicator out to IO
in mapM_ linePrinter indicators

indicatorListCreator :: Int -> Int -> ((String))
{- Build the indicators of
(("O", "X", "X"),("O", "O", "X") ... and so forth.
Recursively determines how many iterations we've been through,
and determines how many "X"s and "O"s we should have
per each line. -}
indicatorListCreator gridLen iterNum
| iterNum > gridLen = ()
| otherwise =
let itersRemaining = gridLen - iterNum
indicator = replicate iterNum "O" ++
replicate itersRemaining "X"
in
indicator: indicatorListCreator gridLen (iterNum + 1)

linePrinter :: (String) -> IO ()
{- Takes the indicators and prints each line accordingly. -}
linePrinter (indicator1, indicator2, indicator3) =
let between = " --- "
outString = indicator1 ++ between ++
indicator2 ++ between ++
indicator3
in putStrLn outString
linePrinter _ = error"Stupidly hardcoded to only show 3x3"
``````

Running and compiling this code results in:

``````O --- X --- X
O --- O --- X
O --- O --- O
``````

Some of my thoughts…

• Is it possible to build indicatorListCreator out of folds?
• How can I circumvent hardcoding linePrinter
• Is this optimal?
• Where should I improve on coding conventions / style?
• Any other glaring shortcomings?

## beginner – Catching star game, specific clicks

so i’m doing a catching star game. Its really simple basically there is around 20 stars, and at the stop there is text counting every time you click on the star. I’ve been trying really hard to figure out how to make it so if you click on the inside of the star that will be the only time it counts up points. I have to use a circle because that is the closest thing i can use to the star shape, which i took from google. here is what i have so far. In my main is where i am having the most trouble and errors saying this “if star1.check_hit(star1):
TypeError: check_hit() missing 1 required positional argument: ‘obj'”
if you have any suggestions please let me know thank you!

class Stars(object):

``````def __init__(self, win):
self.xloc = random.randrange(750)
self.yloc = random.randrange(750)
self.win = win
self.star = None
self.pt = win.checkMouse()
self.star_graphic = None
self.center = self.win.getCurrentMouseLocation()
self.graphic = self.creategraphic()

def creategraphic(self):
star_graphic = Image(Point(self.xloc, self.yloc), 'graphic_assets2/animated_stars .png')
star_graphic.draw(self.win)

def check_hit(self, obj):
inside = (obj.xloc - obj.center.getX())**2 + (obj.yloc - obj.center.getY())**2
return True
else:
return False
``````

def main():

``````global star_count, star_list
star1 = Stars(win)
star_list.append(Stars)
keys = ''
while 'Escape' not in keys:
time.sleep(1 / framerate)
win.update()
keys = win.checkKeys()
for star1 in star_list:
if star1.check_hit(star1):
star_list.append(star1)
star_count += 1
star_counter.setText('you have caught ' + str(star_count) + ' stars.')
``````

## I am beginner : TypeError between instancesin Python language

I am new in python and I have a problem. I convert tarih indexes to integer but I guess Error is in substraction . Details are in photo. What sohuld I do ? Please help me .

## beginner – Object oriented Snake Javascript

I have implemented a little snake game with Javascript and Html but unfortunately it doesent really work.
It would be really nice if someone could look over it and give me some feedback about my mistakes.

The Snake Game:

``````class Snake
{
constructor (x, y, pressedKey, cellSize, context)
{
this.x = x;
this.y = y;
this.pressedKey = pressedKey;
this.cellSize = cellSize;
this.context = context;
this.body = ();

}

handleKeyUp(event)
{
if (event.code === 'ArrowRight' || event.code === 'ArrowLeft' || event.code === 'ArrowUp' || event.code === 'ArrowDown')
{
this.pressedKey = event.code;
}
}

updateBody()
{
if (this.body.length > 0)
{
this.body.pop();
}
}

{
this.body.unshift(new Body(this.x, this.y, this.cellSize));
}

changeDirection(newpressedKey)
{
this.pressedKey = newpressedKey;
}

move()
{
if (this.pressedKey === 'ArrowRight')
{
this.x += 1;
}
else if (this.pressedKey === 'ArrowDown')
{
this.y += 1;
}
else if (this.pressedKey === 'ArrowLeft')
{
this.x -= 1;
}
else if (this.pressedKey === 'ArrowUp')
{
this.y -= 1;
}
}

draw()
{
this.context.fillStyle = 'yellow';
this.context.fillRect(this.x * this.cellSize, this.y * this.cellSize, this.cellSize, this.cellSize);

//b wie body
this.body.forEach(b => {
this.context.fillStyle = 'black';
this.context.fillRect(b.x * b.cellSize, b.y * b.cellSize, b.cellSize, b.cellSize);
});
}

eatApple(apple)
{
return apple.x === this.x && apple.y === this.y;
}

eatSnake()
{
let gameOver = false;
this.body.forEach(b => {
if (b.x === this.x && b.y === this.y)
gameOver = true;
});
return gameOver;
}

eatWall()
{
let gameOver = false;
this.body.forEach(b =>
{
if (b.x < 0)
{
gameOver = true;
}
if (b.y < 0)
{
gameOver = true;
}
if (b.x > 8)
{
gameOver = true;
}
if (b.y > 8)
{
gameOver = true;
}
});
return gameOver;
}

update()
{
let gameOver = false;
gameOver = this.eatSnake() || this.eatWall();
if (!gameOver)
{
if (this.eatApple(apple))
{
apple.newPosition();
}
this.updateBody();
this.move();
}
}
}

class Body
{
constructor(x, y, cellSize)
{
this.x = x;
this.y = y;
this.cellSize = cellSize;
}
}

class Apple
{
constructor(cellSize, context)
{
this.x = Math.floor(Math.random() * 8);
this.y = Math.floor(Math.random() * 8);
this.cellSize = cellSize;
this.context = context;
}

newPosition()
{
this.x = Math.floor(Math.random() * 8);
this.y = Math.floor(Math.random() * 8);
}

draw()
{
this.context.fillStyle = 'red';
this.context.fillRect(this.x * this.cellSize, this.y * this.cellSize, this.cellSize, this.cellSize);
}
}

class Game
{
constructor(canvas, extent)
{
this.canvas = canvas;
this.context = this.canvas.getContext('2d');
this.extent = extent;
this.cellSize = this.canvas.width / this.extent;

this.snake = new Snake(0, 0, 'ArrowDown', this.cellSize, this.context, this.extent);
this.apple = new Apple(this.cellSize, this.context, this.extent)

setInterval(this.loop.bind(this), 250);
}

drawLine(x1, y1, x2, y2)
{
this.context.beginPath();
this.context.moveTo(x1, y1);
this.context.lineTo(x2, y2);
this.context.stroke();
}

drawGrid()
{
for(let i = 1; i < this.extent; i++)
{
this.drawLine(0, i * this.cellSize, this.canvas.width, i * this.cellSize);
this.drawLine(i * this.cellSize, 0, i * this.cellSize, this.canvas.height);
}
}

draw()
{
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);

this.drawGrid();
this.apple.draw();
this.snake.draw();
}

update()
{
this.snake.update();
}

loop() {
this.update();
this.draw();
}
}
new Game(document.getElementById('myCanvas'), 8)
``````

The HTML:

``````<!DOCTYPE html>
<html>
<title>test</title>
<body>
<canvas id="myCanvas" width="640" height="640"></canvas>
<script  type="text/javascript" src="https://codereview.stackexchange.com/main.js"></script>
</body>
</html>
``````

## beginner – Please comment on my first program c

``````#include
#include
``````

int main (void) {

`````` long long card;
int i;
int otherdigs;
int multiply;
int sum = 0;
int sumofothers = 0;
int length;
int card_length;
long long get_card;

get_card = get_long_long(" Enter credit card: ");
card = get_card;

for (i = 0; i < 16; i++)
{

sumofothers += card % 10;

card /= 10;
otherdigs = card % 10;
card /= 10;

if (otherdigs*2 < 10)
{
multiply = otherdigs * 2;
sum += multiply;
}

else
{
otherdigs = otherdigs*2-9;
sum += otherdigs;
}

}

if (finaladd % 10 == 0)
{
for (length = 0; length < 14; length++)
{
get_card /= 10;
}

if ( get_card >= 51 && get_card < 56 ) {

printf("MasterCartn");
}

else if ( get_card >= 3 && get_card < 4)
{
printf("AmericanExpressn");
}

else if ( get_card < 0 || (get_card/10 >= 4 && get_card/10 < 5) )
{
printf("VIZAn");
}

else {

printf(" Sorry, We Don't Support This Payment Companyn");
}
}

else
{
printf("This credit card is not valid n");
}

return 0;
``````

}

hi guys ... i recently took a cs50 online course and here is my solution for (pset1) (1) (credit)
this is my very first program which i have thought about and done everything myself.
the goal is to get the user's card number and check if it is valid (Luhn's algorithm)

I know the style is awful and the code is very complicated too, but your opinion is very important to me ... I spent maybe 5.6 hours for this. the question is: do you think i can code? become a programmer? I mean do I have the right mind for that? (since this is my first without guide code)
btw I have no programming experience (read only a few pages of k & R 2 years ago),

I don't even know half of the syntax c yet. I know that talent is a myth and everything, but based on this code, do you think I'm good at it?
PS: sorry for my bad english guys, i am not good at making sentences, i hope the code is at least readable

## beginner – Tic Tac Toe game logic

I’ve implemented tic-tac-toe in TypeScript before; now I’m porting it to Elixir. As before, this is pure game logic, no UI involved. I’m very new to Elixir, so any suggestions are appreciated.

``````defmodule MassivelyMultiplayerTtt.Game do
defstruct current_player: :player_x,
winning_player: :unfinished,
board: Tuple.duplicate(:empty, 9)

def make_move(game, cell_num) do
case elem(game.board, cell_num) do
:x ->
{:square_filled, game}

:o ->
{:square_filled, game}

:empty ->
if game.winning_player != :unfinished do
else
game =
if game.current_player == :player_x do
%{game | board: put_elem(game.board, cell_num, :x), current_player: :player_o}
else
%{game | board: put_elem(game.board, cell_num, :o), current_player: :player_x}
end

game = check_for_end(game)

case game.winning_player do
:unfinished ->
{:waiting_for_move, game}

_ ->
{:game_finished, game}
end
end
end
end

defp check_for_end(game) do
case game.board do
{:x, :x, :x, _, _, _, _, _, _} ->
%{game | winning_player: :player_x}

{_, _, _, :x, :x, :x, _, _, _} ->
%{game | winning_player: :player_x}

{_, _, _, _, _, _, :x, :x, :x} ->
%{game | winning_player: :player_x}

{:x, _, _, :x, _, _, :x, _, _} ->
%{game | winning_player: :player_x}

{_, :x, _, _, :x, _, _, :x, _} ->
%{game | winning_player: :player_x}

{_, _, :x, _, _, :x, _, _, :x} ->
%{game | winning_player: :player_x}

{:x, _, _, _, :x, _, _, _, :x} ->
%{game | winning_player: :player_x}

{_, _, :x, _, :x, _, :x, _, _} ->
%{game | winning_player: :player_x}

{:o, :o, :o, _, _, _, _, _, _} ->
%{game | winning_player: :player_o}

{_, _, _, :o, :o, :o, _, _, _} ->
%{game | winning_player: :player_o}

{_, _, _, _, _, _, :o, :o, :o} ->
%{game | winning_player: :player_o}

{:o, _, _, :o, _, _, :o, _, _} ->
%{game | winning_player: :player_o}

{_, :o, _, _, :o, _, _, :o, _} ->
%{game | winning_player: :player_o}

{_, _, :o, _, _, :o, _, _, :o} ->
%{game | winning_player: :player_o}

{:o, _, _, _, :o, _, _, _, :o} ->
%{game | winning_player: :player_o}

{_, _, :o, _, :o, _, :o, _, _} ->
%{game | winning_player: :player_o}

board ->
if Enum.any?(Tuple.to_list(board), &match?(:empty, &1)) do
game
else
%{game | winning_player: :drawn}
end
end
end
end
$$```$$
``````