당신은 어느 한 학교를 다니고 있다.
이 학교의 이름은 공평 학교.
공평 학교는 이름 그대로 공평을 최우선의 가치로 삼는다.
그러나 발표 순서, 급식 순서, 자리 배치 등이 학교의 교훈과 맞지 않다는 학생들의 불만이 들어왔고,
선생님들은 몇 날 며칠의 회의 끝에 무작위로 정하자고 하였다.
그러나 전자 기기에 익숙하지 않은 선생님들은 수동으로 해서 과정에 심각한 지연을 불러왔고,
고민하던 교장은 당신이 코딩을 잘한다는 소문을 듣고 당신을 불렀다.
교장의 부탁은 다양한 업무에서 입력값만 주어지면 무작위로 순서 등을 출력하는 프로그램을 만들어달라 하였고,
당신은 손해가 없기에 이를 수락했다.
그러므로 다음 제시된 업무에 따라 프로그램을 만드시오.
첫 번째 프로그램 - 순서
2^32-1(4,294,967,295) 이하의 정수를 입력받고 그 정수의 범위 안에 있는 수들을 무작위로 출력하는 프로그램을 작성하시오.
입력
100
출력
82 62 100 56 26 72 84 25 31 35 58 6 41 17 71 23 93 68 57 15 88 77 21 37 48 8 30 81 2 24 95 64 12 78 16 55 86 47 50 33 90 91 65 38 28 98 54 80 44 13 3 18 42 61 60 75 40 94 45 19 73 92 29 5 52 4 22 34 74 36 66 70 9 1 67 51 53 83 39 14 32 85 96 43 97 49 7 76 27 63 99 20 11 87 79 10 89 59 46 69
두 번째 프로그램 - 자리 배치
전체 학생의 수와 분단의 수를 입력받고 그에 따라 출력하시오
분단은 한 분단 당 두개의 세로줄을 의미하며 분단의 수는 짝수여야 한다.
빈자리는 하단 좌측부터 채워나간다.
입력
12 4
29 6
출력
4 8 10 9
7 3 11 6
12 2 1 5
8 16 4 6 14 29
23 15 12 19 24 10
28 17 2 13 11 21
3 27 9 20 5 18
7 25 22 26 1
모든 프로그램은 출력 결과가 그 때마다 달라야 한다.
27개의 풀이가 있습니다.
파이썬 3.
#공평학교-1.py
import random
def List_Under_Max(Max): # Max이하 1이상 숫자를 랜덤으로 담은 리스트 반환 함수
counter = 0 # Max가 되면 반복 중단 하기 위한 도구
a = list(range(1,Max+1)) # 뽑을 리스트
b = list() # 받을 리스트
while counter<Max:
index = random.randrange(0,Max-counter)
b.append(a[index])
del a[index]
counter += 1
return b #리스트 반환
print("<공평학교 자리 순서 바꾸기>")
Max = int(input("100000이하의 정수를 입력하세요. :"))
Presentation_List = List_Under_Max(Max)
print("발표순서:", end =' ')
for x in range(Max):
print(Presentation_List[x], end=' ')
#공평학교-2.py (1과 이어짐)
print() # 한줄 띄고
print() # 두줄 띄고
print("<공평학교 자리 바꾸기>")
Max_Students = int(input("전체 학생 수를 입력해주세요.: "))
Hor_Line = int(input("가로줄의 수를 입력해주세요.: "))
List_Students = List_Under_Max(Max_Students)
Line_Per_Students = 2 * Hor_Line
student = 0 # while문 들어가기 전 , student수 초기화
while List_Students: # List가 비어있지 않다면 루프를 돈다.
counter = student % 2 # 0, 1 의 값을 가진다.
if counter == 0:
print(List_Students.pop(),end=' ') # 한칸 띄고
student += 1
elif counter == 1:
print(List_Students.pop(),end=' ') # 두칸 띄고
student += 1
if student % Line_Per_Students == 0: # student수가 한 줄당 학생수의 배수가 되면
print() # 엔터
넘파이를 써서 풀어봤습니다~
import numpy as np
#첫 번째 프로그램 - 발표 순서
a = int(input("급식 인원? "))
if a > 1000000 :
exit()
a_list = np.arange(1, a+1)
np.random.shuffle(a_list)
print(str(a_list))
#두 번째 프로그램 - 자리 배치
matrix = input("자리 배치: ").split()
a, b = int(matrix[0]), int(matrix[1])
b_list = np.arange(a)
np.random.shuffle(b_list)
c = ''
for r in range(len(b_list)):
c += str(b_list[r]) + ' '+ '\t' * (r%2)
if not (r+1) % b:
c += "\n"
print(c)
결과
급식 인원? 100
[ 99 66 56 90 87 34 9 32 61 92 38 27 84 49 52 85 11 74
26 98 19 25 14 33 20 12 44 17 100 5 36 96 83 77 86 88
3 8 73 15 70 68 91 1 10 57 40 67 79 31 37 43 4 95
13 7 97 45 24 72 35 18 93 47 39 94 64 53 71 16 65 54
6 59 76 22 28 80 30 46 75 29 55 23 69 42 48 51 82 58
78 62 63 50 60 81 21 89 41 2]
자리 배치: 29 6
2 15 14 16 19 27
9 7 23 4 25 11
5 26 3 21 12 24
13 6 28 22 8 0
20 17 18 1 10
from random import *
def clshuffle(n):
a = [i for i in range(1,n+1)]
shuffle(a)
return a
print('문제 1')
m = int(input('학생수: '))
for i in clshuffle(m): print(f'{i} ',end='')
print('\n\n문제 2')
n, w = map(int,input('학생수 가로줄: ').split())
h = n//w + (1 if n%w else 0)
st = clshuffle(n)
for i in range(h):
for j in range(w):
try: print('{:{}}'.format(st[i*w+j],len(str(n)))+' '*(1+j%2*len(str(n))),end='')
except: break
print()
문제 1
학생수: 100
30 40 24 100 76 47 61 8 60 16 55 93 72 77 88 65 3 35 17 36 49 51 10 57 42 62 14 29 18 6 74 89 59 27 54 25 71 82 31 68 1 98 99 13 32 50 75 15 21 87 9 85 94 12 41 23 96 26 81 48 95 34 91 33 69 92 67 20 11 58 4 84 90 83 53 39 44 37 70 46 80 66 86 73 5 64 43 79 2 52 28 22 78 7 97 38 63 19 45 56
문제 2
학생수 가로줄: 128 16
95 6 52 88 128 17 61 62 67 27 56 91 28 11 48 32
49 71 85 70 79 94 81 78 31 127 125 44 77 126 34 30
45 60 57 63 103 113 43 39 89 14 33 1 102 46 51 87
86 53 20 122 115 101 116 118 41 24 42 38 100 72 106 75
97 36 123 109 121 105 68 124 59 23 5 55 35 108 66 22
15 98 90 83 65 47 50 119 111 76 112 84 82 120 8 73
12 93 92 104 117 58 3 16 13 21 99 4 107 40 96 10
19 7 25 29 54 37 80 64 69 110 26 18 74 114 9 2
import random
def randomOrder(n, end = True):
l = [_ for _ in range(1,n+1)]
random.shuffle(l)
if end : print(" ".join([str(x) for x in l]))
else : return l
def randomSeat(n, s):
l = randomOrder(n, end = False)
for i in range(0, len(l), s) :
line = l[i : i + s]
print(" ".join([" ".join([str(x) for x in line[_: _ + 2]]) for _ in range(0, len(line), 2)]))
from random import sample
def location(a,b):
le = len(str(a))
Class = list(map(lambda x : ' ' * abs(len(str(x)) - le) + str(x), sample(range(1,a+1),a)))
for x in range(a):
if x%b == 0:
print('\n', end = ' ')
elif x%2 == 0:
print(end = ' ')
print(Class[x-1], end = ' ')
def order(n):
print(" ".join(list(map(str , sample(range(1,n+1), n)))))
import random as rd
student_cnt,col_num = map(int,raw_input().split(' '))
l = [ i for i in range(1,student_cnt+1) ]
rd.shuffle(l)
s = ''
for i in range(len(l)):
s += (str(l[i]) + ' ')
if (i+1) % 2 == 0: s += ' '
if (i+1) % col_num == 0:
print(s)
s = ''
if s != '': print(s)
파이썬 3.
import random
#발표 순서
n = int(input("자연수 입력:"))
list1 = list(range(1, n+1))
random.shuffle(list1)
print(list1) #리스트 출력
print(" ".join(list(map(str, list1)))) #스페이스 삽입해서 출력
#자리 배치
data = input("학생수 책상줄수:")
n, col = list(map(int, data.split(" ")))
list1 = list(range(1, n+1))
random.shuffle(list1)
result = ""
for i, v in enumerate(list1):
result += str(v)
# 각 수 뒤에 위치에 따라 엔터, 스페이스, 더블스페이스 삽입
if (i+1) % col == 0:
result += "\n"
elif (i+1) % col % 2 == 1:
result += " "
elif (i+1) % col % 2 == 0:
result += " "
print(result)
import java.util.*;
public class Javatutorial {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int cols = sc.nextInt();
sc.close();
List<Integer> lst = new ArrayList<Integer>(n);
for (int i = 1; i <= n; i++)
lst.add(i);
Collections.shuffle(lst);
//System.out.println(lst.toString());
for(int i = 1; i <= n; i++)
System.out.print(lst.remove(0) + " " + (i % 2 == 0 ? " ":"") + (i % cols == 0 ? "\n":""));
}
}
import java.util.*;
class h2 { public static void main(String[] args) { int b,c,i; Random r = new Random(); Scanner s = new Scanner(System.in);
b = s.nextInt();
int[] a = new int[b];
if(b<=1000000)
for(i=0;i<b;i++)
{
a[i]=r.nextInt(b)+1;
System.out.print(a[i]+" ");
}
}
}```{.java}
```
using System;
using System.Collections.Generic;
namespace CD178
{
class Program
{
static void Main(string[] args)
{
Problem1();
Problem2();
}
// 입력 인자 수 만큼의 학생 순서 랜덤 반환
static List<int> StudentsInLine(int aNumberOfStudents)
{
var order = new HashSet<int>();
var random = new Random();
while (order.Count < aNumberOfStudents)
{
order.Add(random.Next(1, aNumberOfStudents + 1));
}
return new List<int>(order);
}
static void Problem1() // 문제1
{
Console.Write("학생 수: ");
int numOfStudent = int.Parse(Console.ReadLine());
if (numOfStudent > 1000000) return;
foreach (var val in StudentsInLine(numOfStudent))
{
Console.Write($"{val} ");
}
Console.WriteLine();
}
static void Problem2() // 문제2
{
Console.Write("학생 수(A), 가로줄 당 학생 수(B): ");
string input = Console.ReadLine();
int numOfStudent = int.Parse(input.Split()[0]);
int numOfStudentPerLine = int.Parse(input.Split()[1]);
var students = StudentsInLine(numOfStudent);
for (int i = 0; i < students.Count; i++)
{
Console.Write($"{students[i],5} ");
if (i % numOfStudentPerLine == numOfStudentPerLine - 1) { Console.WriteLine(); }
}
Console.WriteLine();
}
}
}
학생 수: 100
80 65 90 48 21 15 66 94 79 2 74 61 64 11 10 42 75 72 98 58 9 5 91 8 87 99 81 38 96 55 29 49 28 6 100 22 59 92 97 73 17 77 50 71 60 40 35 36 67 13 85 63 62 70 18 76 84 12 14 83 4 45 52 78 88 46 7 30 37 34 82 27 20 54 16 41 86 23 53 1 57 39 25 31 44 19 51 24 89 43 95 26 69 56 3 68 32 47 93 33
학생 수(A), 가로줄 당 학생 수(B): 26 9
4 8 26 22 11 6 20 21 5
17 3 2 18 16 10 24 12 19
9 14 1 23 15 7 13 25
# 1. 공평한 발표 순서
# 1000000 이하의 정수 n을 입력받고 0부터 n까지의 순서를 무작위로 출력
# 2. 공평한 자리 배치
# 전체 학생 수와 세로줄 수를 입력받고 무작위로 자리 출력.
# 실제 자리 배치처럼 학생과 학생 사이에는 공백을 넣고, 세로줄은 되도록 짝수로 한다.
import random
# 1
def presentation(n):
list = [i for i in range(1, n+1)]
random.shuffle(list)
print(*list)
presentation(int(input('Input number(0~1000000):')))
# 2
def fairSeat(student, line):
list = [i for i in range(1, student+1)]
random.shuffle(list)
for row in range(student//line):
for col in range(line):
print(list[row*line+col], end=' ')
print()
student = int(input('Student:'))
line = int(input('Line:'))
fairSeat(student, line)
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
void Rand_Num(int arr[], int size)
{
bool flag;
int count = 0;
int num;
srand((unsigned)time(NULL)); // 난수 생성
// 난수 중복 제거
while (true)
{
flag = false; // 반복할때 처음에는 flag는 false
if (count == size) // count가 size와 같으면 반복문 빠져나오기
break;
num = rand() % size + 1; // 1~size까지의 난수 생성
arr[count] = num; // 배열에 저장
for (int i = 0; i < count; i++) // 난수 중복제거
{
if (arr[i] == num) // 배열의 값과 생성된 난수을 비교
{
flag = true; // 같으면 flag는 true이고 break로 빠져나옴
break;
}
}
if (flag) // flag가 true면 반복 처음으로 돌아감
continue;
else
count++; // false면 count++
}
}
void student_Num(int a[], int size)
{
for (int i = 0; i < size; i++)
{
cout << a[i] << " ";
if (i % 10 == 0) // 나머지값이 0일경우 endl라인 추가
cout << endl;
}
cout << endl << "자리배치>>";
}
void Position(int a[], int size ,int num)
{
int i = 0;
for (i; i < size;)
{
for (int j = 0; j < num / 2; j++)
{
cout << " " << a[i++];
if (i == size) // i가 size와 같으면 빠져나온다.
break;
cout << " " << a[i++] << " ";
}
cout << endl;
}
}
int main()
{
cout << "발표 순서>>";
int size;
int num;
cin >> size; // 발표 순서 입력
int *Lotto = new int[size];
Rand_Num(Lotto, size); // 난수 생성
student_Num(Lotto, size); // 학생수 출력
cin >> size >> num; // 자리 배치 사이즈 입력
Position(Lotto, size, num); // 자리 배치 출력
delete[]Lotto;
}
class Program
{
static int[] nArray;
static void Main(string[] args)
{
Console.Write("학생수 : ");
int nNumber = int.Parse(Console.ReadLine());
PresentationOrder(nNumber, true);
Console.Write("학생수 가로줄: ");
PosionSeat();
}
public static void PresentationOrder(int nNumber, bool bCheckd)
{
Random random = new Random();
if (nNumber > 1000000)
return;
nArray = new int[nNumber];
for (int i = 0; i < nArray.Length - 1; i++)
{
nArray[i] = random.Next(1, nNumber);
for (int j = 0; j < i; j++)
{
if (nArray[i] == nArray[j])
i--;
}
}
if (bCheckd)
{
Array.ForEach(nArray, x => Console.Write(x + 1 + " "));
Console.WriteLine();
}
}
public static void PosionSeat()
{
int nFst, nSec;
int nCnt = 1;
string[] strInput = Console.ReadLine().Split(' ');
bool result1 = int.TryParse(strInput[0], out nFst);
bool result2 = int.TryParse(strInput[1], out nSec);
if (result1 && result2)
{
PresentationOrder(nFst, false);
for (int i = 0; i < nArray.Length; i++)
{
if (i % 2 == 0)
Console.Write(nArray[i] + " ");
else
Console.Write(nArray[i] + " ");
if (nCnt % nSec == 0)
Console.WriteLine();
nCnt++;
}
}
else
Console.WriteLine("숫자를 입력하세요");
}
}
```{.python}
import random random.seed() #초기화 no = int(input('숫자 1000000 이하 숫자: ')) klist = [i for i in range(1,no+1)] random.shuffle(klist) print(klist) ``````{.python}
import random random.seed() #초기화 stno = int(input('학생수: ')) cono = int(input('줄 수: ')) klist = [i for i in range(1,stno+1)] random.shuffle(klist) ncnt=0
while ncnt < stno: blank=" " for i in range(cono): if ncnt < stno : print(klist[ncnt],end=blank) ncnt +=1 if blank==" ": blank=" " else: blank=" " else: break print()
n <- 10
sample(n)
n <- 14
c <- 4
s <- sample(n)
seat <- matrix(ncol = (c * 5 / 2) - 2, nrow = ceiling(n / c))
s_i <- 1
for (i in 1:ceiling(n / c)){
for (j in 1:(ncol(seat))){
if (j %% 5 == 1){
seat[i, j] <- s[s_i]
s_i <- s_i + 1
} else if (j %% 5 == 2){
seat[i, j] <- 0
} else if (j %% 5 == 3){
seat[i, j] <- s[s_i]
s_i <- s_i + 1
} else if (j %% 5 == 4){
seat[i, j] <- 0
} else if (j %% 5 == 0){
seat[i, j] <- 0
}
}
}
seat[seat == 0] <- ' '
seat[is.na(seat)] <- ' '
for (i in 1:nrow(seat)){
te <- paste(seat[i, ], sep = '', collapse = '')
print(te)
}
import random
import math
#1
n = int(input())
L = list(i for i in range(1, n+1))
random.shuffle(L)
for i in L:
print(i, end=' ')
#2
student, line = map(int, input().split())
M = list(i for i in range(1, student+1))
random.shuffle(M)
if student % line == 0:
limit = student // line
else:
limit = student // line + 1
for i in range(limit):
for j in range(0, line, 2):
if len(M) == 1:
print(M.pop())
else:
print(M.pop(), M.pop(), end = ' ')
print()
public class 공평학교 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
Random r = new Random();
int[] arr = new int[N];
for(int i=0; i<N; i++) {
arr[i] = r.nextInt(N)+1;
for(int j=0; j<i; j++) {
if(arr[i]==arr[j]) {
i--;
}
}
}
for(int i=0; i<N; i++) {
System.out.print(arr[i]+" ");
}
System.out.println("");
//여기까지 첫 번째 프로그램
int a = scan.nextInt();
int b = scan.nextInt();
int[] arr2 = new int[a];
for(int i=0; i<a; i++) {
arr2[i] = r.nextInt(a)+1;
for(int j=0; j<i; j++) {
if(arr2[i]==arr2[j]) {
i--;
}
}
}
for(int i=1; i<=a; i++) {
System.out.print(arr2[i-1]+" ");
if(i%2==0) {
System.out.print(" ");
}
if(i%b==0) {
System.out.println("\n");
}
}
}
}
import random
print('1.')
n=int(input())
num=[]
while (len(num)<n):
ran=random.randint(1,n)
if ran not in num:
num.append(ran)
print (num)
print()
print('2.')
n1,n2=input().split()
n1=int(n1)
n2=int(n2)
num=[]
num2=[]
while (len(num)<n1):
ran=random.randint(1,n1)
if ran not in num:
num.append(ran)
#print('num=',num)
while (len(num)>=n2):
temp=[]
for i in range (0,n2):
temp.append(num[0])
del num[0]
num2.append(temp)
if len(num)!=0:
num2.append(num)
if n1%n2==0:
n3=n1//n2
else:
n3=(n1//n2)+1
for i in range (0,n3):
for j in range(0,len(num2[i])):
print(num2[i][j],end='')
if j%2==0:
print(' ',end='')
else:
print(' ',end='')
print ()
import random
import numpy as np
num = int(input("Input Number : "))
list_value = list(i for i in range(1,num+1))
value = len(list_value)
for x in range(value):
n=random.randint(1,len(list_value))
print(list_value[n-1], end =" ")
del list_value[n-1]
print("\n")
matrix = input("Input Num & location(ex)32 4) : ").split()
value, location = int(matrix[0]), int(matrix[1])
value_list = np.arange(1,value+1)
np.random.shuffle(value_list)
ar = ''
for i in range(len(value_list)):
ar += str(value_list[i]) + " " + "\t"*(i%2)
if not(i+1)%location :
ar += '\n'
print(ar)
2자리 배치는 앞의 풀이 과정(재즐보프님)을 보고 넣었습니다.
import random
def p1(s):
L = [i for i in range(1, s+1)]
random.shuffle(L)
return L
def p2(s, d):
seat_num = p1(s)
print(seat_num)
pair = (int(s / d) + 1, s / d)[s % d == 0]
for r in range(pair+1):
c = 1
while seat_num and c != d+1:
print(seat_num.pop(), end=' ') if c%2 != 0 else print(seat_num.pop(), end=' ')
c += 1
print('')
if __name__ == '__main__':
s, d = 29, 6
print(*p1(s))
p2(s, d)
import random
def p1(n): return [random.randint(0,n) for i in range(n)]
def p2(n,s):
two = ''
for i in [p1(n)[0:s] for i in range(s)]:
two += f'{i[0:2]} {i[2:4]}\n'
return two
print(p2(12,4))
import random
def shuffle(n):
List = [i for i in range(1,n+1)]
random.shuffle(List)
return List
# 1. 정수를 입력받고 그 정수의 범위 안에 있는 수들을 무작위로 출력하기
n=int(input('발표할 학생 수: '))
pre=shuffle(n)
while pre:
print(pre.pop(),end = ' ')
# 2. 전체 학생 수와 분단의 수를 입력받고 출력하기
student = int(input('총 학생수: '))
row = int(input('총 분단수(짝수로):'))
student=shuffle(student)
while student:
if (len(student)-row-1)%row==0:
print(student.pop())
elif len(student)%2==0:
print(student.pop(),end =' ')
else:
print(student.pop(),end=' ')
#codingdojing_fair_school
import random
import math
#1
a = [i for i in range(1, eval(input('N: '))+1)]
random.shuffle(a)
print(a)
#2
student = [i for i in range(1, eval(input('student n: '))+1)]
random.shuffle(student)
section = eval(input('section: '))
line = math.ceil(len(student)/section)
for i in range(line):
for j in range(section):
try:
if j%2 ==1:
print(student[section*i + j], end = ' ')
else:
print(student[section*i + j], end = ' ')
if j == section-1: print()
except IndexError:
pass
#1
import random
n = int(input("정수를 입력하시오"))
arr =[]
while len(arr)!=n+1:
a = random.randint(0,n)
if a not in arr :
arr.append(a)
print(a,end=" ")
#2
student = int(input("전체 학생수:"))
while True:
column = int(input("전체 분단수:"))
if column%2 ==0:
break
arr =[]
col =[]
while len(arr)!=student:
a = random.randint(1,student)
if a not in arr :
arr.append(a)
arr1 =list(map(str,arr))
for i in range(0,len(arr1),2):
try :
col.append([arr1[i],arr1[i+1]])
except IndexError:
col.append([arr1[i]])
for i in range(len(col)):
print(" ".join(col[i]),end=" ")
if (i+1)%(column/2) ==0:
print('\n')
import random
tn = total_student_number = 29
np = number_per_room = 6
rn = room_number = int(tn/np)+1
a=[x for x in range(1, n+1)]
random.shuffle(a)
arr=[]
for i in range(rn):
arr.append(a[i*np:i*np+np])
print(arr)
package org.javaturotials.ex;
import java.util.*;
import java.util.stream.Collectors;
public class test {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int num = sc.nextInt();
int count=0;
int ed = 0;
int[] arr = new int[num];
for(int i=0; i<100; i++) {
int z =(int)(Math.random()*num +1);
arr[i] = z;
for(int j=0; j<i; j++) {
if(arr[i]==arr[j]) {i--;}
} // 첫번째 프로그램 - 순서
}
int stdc = sc.nextInt();
int bc=sc.nextInt();
for(int i=0; i<stdc; i++) {
if(count%2==0) System.out.print(" ");
if(count%bc==0) System.out.print("\n");
System.out.print(arr[i] + " ");
count++;
} // 두번째 프로그램 - 자리배치
}
}
from random import *
def randomSort(n):
nums = [n for n in range(1, n+1)]
shuffle(nums)
return nums
# 첫 번째 프로그램 - 순서
su = int(input('2^32-1(4,294,967,295) 이하의 정수를 입력: '))
print(randomSort(su))
# 두 번째 프로그램 - 자리 배치
sn, dv = map(int, input('전체 학생의 수와 분단의 수를 입력: ').split())
col = sn // dv + (0 if sn % dv == 0 else 1)
map = [['' for _ in range(col)] for _ in range(dv)]
rs = randomSort(sn)
idx = 0
for c in range(col):
for r in range(dv):
if idx < sn:
map[r][c] = rs[idx]
idx += 1
print('{:4}'.format(map[r][c]), end='')
print()